Update the job cache location on on windows platforms (#1740)

* Update the job cache location on non-windows platforms
This commit is contained in:
chunqingchen 2016-08-12 16:54:05 -07:00 committed by Jason Shirk
parent 585b83387c
commit 2764b31c07
2 changed files with 19 additions and 5 deletions

View file

@ -424,8 +424,11 @@ namespace Microsoft.PowerShell.ScheduledJob
/// <returns>Directory Path</returns>
public static string GetJobDefinitionLocation()
{
return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
ScheduledJobsPath);
#if UNIX
return Path.Combine(Platform.SelectProductNameForDirectory(Platform.XDG_Type.CACHE), "ScheduledJobs"));
#else
return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), ScheduledJobsPath);
#endif
}
public static void CreateDirectoryIfNotExists()
@ -444,9 +447,12 @@ namespace Microsoft.PowerShell.ScheduledJob
/// <returns>Directory Path</returns>
private static string GetDirectoryPath()
{
string pathName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
ScheduledJobsPath);
string pathName;
#if UNIX
pathName = Path.Combine(Platform.SelectProductNameForDirectory(Platform.XDG_Type.CACHE), "ScheduledJobs"));
#else
pathName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), ScheduledJobsPath);
#endif
if (!Directory.Exists(pathName))
{
Directory.CreateDirectory(pathName);
@ -499,9 +505,13 @@ namespace Microsoft.PowerShell.ScheduledJob
/// <returns>Directory Path</returns>
private static string GetJobDefinitionPath(string definitionName)
{
#if UNIX
return Path.Combine(Platform.SelectProductNameForDirectory(Platform.XDG_Type.CACHE), "ScheduledJobs", definitionName);
#else
return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
ScheduledJobsPath,
definitionName);
#endif
}
/// <summary>

View file

@ -3106,10 +3106,14 @@ namespace System.Management.Automation.Runspaces
// Or for virtual accounts
// WinDir\System32\Microsoft\Windows\PowerShell\DriveRoots\[UserName]
string directoryName = MakeUserNamePath();
#if UNIX
string userDrivePath = Path.Combine(Platform.SelectProductNameForDirectory(Platform.XDG_Type.CACHE), "DriveRoots", directoryName);
#else
string userDrivePath = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
@"Microsoft\Windows\PowerShell\DriveRoots",
directoryName);
#endif
// Create directory if it doesn't exist.
if (!System.IO.Directory.Exists(userDrivePath))