-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented preemptive caching (#2944)
- Loading branch information
Showing
16 changed files
with
1,081 additions
and
662 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System.Threading.Tasks; | ||
|
||
namespace Files.Extensions | ||
{ | ||
internal static class TaskExtensions | ||
{ | ||
#pragma warning disable RCS1175 // Unused this parameter. | ||
#pragma warning disable IDE0060 // Remove unused parameter | ||
/// <summary> | ||
/// This function is to explicitly state that we know that we're runnign task without awaiting. | ||
/// This makes visual studio to drop warning, but the programmer intent is still clearly stated. | ||
/// </summary> | ||
/// <param name="task"></param> | ||
internal static void Forget(this Task task) | ||
{ | ||
// do nothing, just forget about the task | ||
} | ||
#pragma warning restore IDE0060 // Remove unused parameter | ||
#pragma warning restore RCS1175 // Unused this parameter. | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Threading.Tasks; | ||
using Windows.Storage; | ||
using static Files.Helpers.NativeFindStorageItemHelper; | ||
using FileAttributes = System.IO.FileAttributes; | ||
|
||
namespace Files.Filesystem | ||
{ | ||
public static class FolderHelpers | ||
{ | ||
public static bool CheckFolderAccessWithWin32(string path) | ||
{ | ||
FINDEX_INFO_LEVELS findInfoLevel = FINDEX_INFO_LEVELS.FindExInfoBasic; | ||
int additionalFlags = FIND_FIRST_EX_LARGE_FETCH; | ||
IntPtr hFileTsk = FindFirstFileExFromApp(path + "\\*.*", findInfoLevel, out WIN32_FIND_DATA findDataTsk, FINDEX_SEARCH_OPS.FindExSearchNameMatch, IntPtr.Zero, | ||
additionalFlags); | ||
if (hFileTsk.ToInt64() != -1) | ||
{ | ||
FindClose(hFileTsk); | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
public static bool CheckFolderForHiddenAttribute(string path) | ||
{ | ||
if (string.IsNullOrEmpty(path)) | ||
{ | ||
return false; | ||
} | ||
FINDEX_INFO_LEVELS findInfoLevel = FINDEX_INFO_LEVELS.FindExInfoBasic; | ||
int additionalFlags = FIND_FIRST_EX_LARGE_FETCH; | ||
IntPtr hFileTsk = FindFirstFileExFromApp(path + "\\*.*", findInfoLevel, out WIN32_FIND_DATA findDataTsk, FINDEX_SEARCH_OPS.FindExSearchNameMatch, IntPtr.Zero, | ||
additionalFlags); | ||
if (hFileTsk.ToInt64() == -1) | ||
{ | ||
return false; | ||
} | ||
var isHidden = ((FileAttributes)findDataTsk.dwFileAttributes & FileAttributes.Hidden) == FileAttributes.Hidden; | ||
FindClose(hFileTsk); | ||
return isHidden; | ||
} | ||
|
||
public static async Task<bool> CheckBitlockerStatusAsync(StorageFolder rootFolder, string path) | ||
{ | ||
if (rootFolder == null || rootFolder.Properties == null) | ||
{ | ||
return false; | ||
} | ||
if (Path.IsPathRooted(path) && Path.GetPathRoot(path) == path) | ||
{ | ||
IDictionary<string, object> extraProperties = await rootFolder.Properties.RetrievePropertiesAsync(new string[] { "System.Volume.BitLockerProtection" }); | ||
return (int?)extraProperties["System.Volume.BitLockerProtection"] == 6; // Drive is bitlocker protected and locked | ||
} | ||
return false; | ||
} | ||
|
||
/// <summary> | ||
/// This function is used to determine whether or not a folder has any contents. | ||
/// </summary> | ||
/// <param name="targetPath">The path to the target folder</param> | ||
/// | ||
public static bool CheckForFilesFolders(string targetPath) | ||
{ | ||
FINDEX_INFO_LEVELS findInfoLevel = FINDEX_INFO_LEVELS.FindExInfoBasic; | ||
int additionalFlags = FIND_FIRST_EX_LARGE_FETCH; | ||
|
||
IntPtr hFile = FindFirstFileExFromApp(targetPath + "\\*.*", findInfoLevel, out WIN32_FIND_DATA _, FINDEX_SEARCH_OPS.FindExSearchNameMatch, IntPtr.Zero, additionalFlags); | ||
FindNextFile(hFile, out _); | ||
var result = FindNextFile(hFile, out _); | ||
FindClose(hFile); | ||
return result; | ||
} | ||
} | ||
} |
Oops, something went wrong.