public static async Task <ListedItem> GetFolder( WIN32_FIND_DATA findData, string pathRoot, string dateReturnFormat, CancellationToken cancellationToken ) { if (cancellationToken.IsCancellationRequested) { return(null); } DateTime itemModifiedDate; DateTime itemCreatedDate; try { FileTimeToSystemTime(ref findData.ftLastWriteTime, out SYSTEMTIME systemModifiedTimeOutput); itemModifiedDate = systemModifiedTimeOutput.ToDateTime(); FileTimeToSystemTime(ref findData.ftCreationTime, out SYSTEMTIME systemCreatedTimeOutput); itemCreatedDate = systemCreatedTimeOutput.ToDateTime(); } catch (ArgumentException) { // Invalid date means invalid findData, do not add to list return(null); } var itemPath = Path.Combine(pathRoot, findData.cFileName); string itemName = await fileListCache.ReadFileDisplayNameFromCache(itemPath, cancellationToken); if (string.IsNullOrEmpty(itemName)) { itemName = findData.cFileName; } bool isHidden = (((FileAttributes)findData.dwFileAttributes & FileAttributes.Hidden) == FileAttributes.Hidden); double opacity = 1; if (isHidden) { opacity = Constants.UI.DimItemOpacity; } return(new ListedItem(null, dateReturnFormat) { PrimaryItemAttribute = StorageItemTypes.Folder, ItemNameRaw = itemName, ItemDateModifiedReal = itemModifiedDate, ItemDateCreatedReal = itemCreatedDate, ItemType = folderTypeTextLocalized, FileImage = null, IsHiddenItem = isHidden, Opacity = opacity, LoadFileIcon = false, ItemPath = itemPath, FileSize = null, FileSizeBytes = 0, }); }
public async Task <string> ReadFileDisplayNameFromCache(string path, CancellationToken cancellationToken) { var displayName = fileNamesCache.Get(path, (string)null); if (displayName == null) { displayName = await persistentAdapter.ReadFileDisplayNameFromCache(path, cancellationToken); if (displayName != null) { fileNamesCache[path] = displayName; } } return(displayName); }
public static async Task <ListedItem> GetFolder( WIN32_FIND_DATA findData, string pathRoot, string dateReturnFormat, CancellationToken cancellationToken ) { if (cancellationToken.IsCancellationRequested) { return(null); } DateTime itemModifiedDate; DateTime itemCreatedDate; try { FileTimeToSystemTime(ref findData.ftLastWriteTime, out SYSTEMTIME systemModifiedTimeOutput); itemModifiedDate = new DateTime( systemModifiedTimeOutput.Year, systemModifiedTimeOutput.Month, systemModifiedTimeOutput.Day, systemModifiedTimeOutput.Hour, systemModifiedTimeOutput.Minute, systemModifiedTimeOutput.Second, systemModifiedTimeOutput.Milliseconds, DateTimeKind.Utc); FileTimeToSystemTime(ref findData.ftCreationTime, out SYSTEMTIME systemCreatedTimeOutput); itemCreatedDate = new DateTime( systemCreatedTimeOutput.Year, systemCreatedTimeOutput.Month, systemCreatedTimeOutput.Day, systemCreatedTimeOutput.Hour, systemCreatedTimeOutput.Minute, systemCreatedTimeOutput.Second, systemCreatedTimeOutput.Milliseconds, DateTimeKind.Utc); } catch (ArgumentException) { // Invalid date means invalid findData, do not add to list return(null); } var itemPath = Path.Combine(pathRoot, findData.cFileName); string itemName = await fileListCache.ReadFileDisplayNameFromCache(itemPath, cancellationToken); if (string.IsNullOrEmpty(itemName)) { itemName = findData.cFileName; } bool isHidden = (((FileAttributes)findData.dwFileAttributes & FileAttributes.Hidden) == FileAttributes.Hidden); double opacity = 1; if (isHidden) { opacity = 0.4; } return(new ListedItem(null, dateReturnFormat) { PrimaryItemAttribute = StorageItemTypes.Folder, ItemName = itemName, ItemDateModifiedReal = itemModifiedDate, ItemDateCreatedReal = itemCreatedDate, ItemType = "FileFolderListItem".GetLocalized(), LoadFolderGlyph = true, FileImage = null, IsHiddenItem = isHidden, Opacity = opacity, LoadFileIcon = false, ItemPath = itemPath, LoadUnknownTypeGlyph = false, FileSize = null, FileSizeBytes = 0, ContainsFilesOrFolders = FolderHelpers.CheckForFilesFolders(itemPath), //FolderTooltipText = tooltipString, }); }