@@ -19,23 +19,27 @@ public WindowsPowerShell() {}
19
19
// This string needs to end up being a multiple of 3 bytes after conversion to UTF-16. (It is currently 1200 bytes.)
20
20
// This is because Base64 converts 3 bytes to 4 letters; other numbers of bytes would introduce padding, which
21
21
// would make it harder to simply concatenate this precomputed string with whatever directories the user requests.
22
- static final String SCRIPT_START_BASE64 = Constants .operatingSystem == 'w' ? toUTF16LEBase64 ("& {\n " +
23
- "[Console]::OutputEncoding = [System.Text.Encoding]::UTF8\n " +
24
- "Add-Type @\" \n " +
25
- "using System;\n " +
26
- "using System.Runtime.InteropServices;\n " +
27
- "public class Dir {\n " +
28
- " [DllImport(\" shell32.dll\" )]\n " +
29
- " private static extern int SHGetKnownFolderPath([MarshalAs(UnmanagedType.LPStruct)] Guid rfid, uint dwFlags, IntPtr hToken, out IntPtr pszPath);\n " +
30
- " public static string GetKnownFolderPath(string rfid) {\n " +
31
- " IntPtr pszPath;\n " +
32
- " if (SHGetKnownFolderPath(new Guid(rfid), 0, IntPtr.Zero, out pszPath) != 0) return \" \" ;\n " +
33
- " string path = Marshal.PtrToStringUni(pszPath);\n " +
34
- " Marshal.FreeCoTaskMem(pszPath);\n " +
35
- " return path;\n " +
36
- " }\n " +
37
- "}\n " +
38
- "\" @\n " ) : null ;
22
+ static final String SCRIPT_START_BASE64 = Constants .operatingSystem == 'w' ? toUTF16LEBase64 (
23
+ """
24
+ & {
25
+ [Console]::OutputEncoding = [System.Text.Encoding]::UTF8
26
+ Add-Type @"
27
+ using System;
28
+ using System.Runtime.InteropServices;
29
+ public class Dir {
30
+ [DllImport("shell32.dll")]
31
+ private static extern int SHGetKnownFolderPath([MarshalAs(UnmanagedType.LPStruct)] Guid rfid, uint dwFlags, IntPtr hToken, out IntPtr pszPath);
32
+ public static string GetKnownFolderPath(string rfid) {
33
+ IntPtr pszPath;
34
+ if (SHGetKnownFolderPath(new Guid(rfid), 0, IntPtr.Zero, out pszPath) != 0) return "";
35
+ string path = Marshal.PtrToStringUni(pszPath);
36
+ Marshal.FreeCoTaskMem(pszPath);
37
+ return path;
38
+ }
39
+ }
40
+ "@
41
+ """
42
+ ) : null ;
39
43
40
44
public String [] winDirs (String ... guids ) {
41
45
int guidsLength = guids .length ;
0 commit comments