public static MediaInsertionPromptGuard Enter()
                {
                    MediaInsertionPromptGuard prompt = default;

                    prompt._disableSuccess = WindowsNative.SetThreadErrorMode(WindowsNative.SEM_FAILCRITICALERRORS, out prompt._oldMode);
                    return(prompt);
                }
コード例 #2
0
 public static void GetSpace(IAbsoluteDirectoryPath.Impl path, out long availableBytes, out long totalBytes, out long freeBytes)
 {
     using (MediaInsertionPromptGuard.Enter()) {
         if (!WindowsNative.GetDiskFreeSpaceEx(path.PathExport, out availableBytes, out totalBytes, out freeBytes))
         {
             throw GetLastWin32ErrorException(path);
         }
     }
 }
コード例 #3
0
            public static unsafe string GetFileSystem(IAbsoluteDirectoryPath.Impl rootDir)
            {
                // rootDir must be a symlink or root drive

                const int MAX_LENGTH = 261; // MAX_PATH + 1

                char *fileSystemName = stackalloc char[MAX_LENGTH];

                using (MediaInsertionPromptGuard.Enter()) {
                    if (!WindowsNative.GetVolumeInformation(rootDir.PathExportWithTrailingSeparator, null, 0, null, null, out int fileSystemFlags, fileSystemName, MAX_LENGTH))
                    {
                        throw GetLastWin32ErrorException(rootDir);
                    }
                }

                return(new string(fileSystemName));
            }