protected override async Task <FileSystemEntity[]> EnumDirectoryImplAsync(string directoryPath, EnumDirectoryFlags flags, CancellationToken cancel = default) { directoryPath = MapPathVirtualToPhysical(directoryPath); FileSystemEntity[] entries = await base.EnumDirectoryImplAsync(directoryPath, flags, cancel); foreach (FileSystemEntity entry in entries) { entry.FullPath = MapPathPhysicalToVirtual(entry.FullPath); if (FileSystem.GetSpecialFileNameKind(entry.Name) == SpecialFileNameKind.Normal) { entry.Name = PathParser.GetFileName(entry.FullPath); } if (entry.SymbolicLinkTarget._IsFilled()) { // リライト時はシンボリックリンク非対応 entry.SymbolicLinkTarget = null; entry.Attributes.BitRemove(FileAttributes.ReparsePoint); } } return(entries); }
protected override async Task <FileSystemEntity[]> EnumDirectoryImplAsync(string directoryPath, EnumDirectoryFlags flags, CancellationToken cancel = default) { directoryPath = MapPathVirtualToPhysical(directoryPath); FileSystemEntity[] entries = await base.EnumDirectoryImplAsync(directoryPath, flags, cancel); foreach (FileSystemEntity entry in entries) { entry.FullPath = MapPathPhysicalToVirtual(entry.FullPath); if (FileSystem.GetSpecialFileNameKind(entry.Name) == SpecialFileNameKind.Normal) { entry.Name = PathParser.GetFileName(entry.FullPath); } entry.SymbolicLinkTarget = MapPathPhysicalToVirtual(entry.SymbolicLinkTarget); } return(entries); }
protected override async Task <FileSystemEntity[]> EnumDirectoryImplAsync(string directoryPath, EnumDirectoryFlags flags, CancellationToken cancel = default) { checked { FileSystemEntity[] dirEntities = await UnderlayFileSystem.EnumDirectoryAsync(directoryPath, false, flags, cancel); var relatedFiles = dirEntities.Where(x => x.IsDirectory == false).Where(x => x.Name.IndexOf(Params.SplitStr) != -1); var sortedRelatedFiles = relatedFiles.ToList(); sortedRelatedFiles.Sort((x, y) => x.Name._Cmp(y.Name, PathParser.PathStringComparison)); sortedRelatedFiles.Reverse(); Dictionary <string, FileSystemEntity> parsedFileDictionaly = new Dictionary <string, FileSystemEntity>(PathParser.PathStringComparer); var normalFiles = dirEntities.Where(x => x.IsDirectory == false).Where(x => x.Name.IndexOf(Params.SplitStr) == -1); var normalFileHashSet = new HashSet <string>(normalFiles.Select(x => x.Name), PathParser.PathStringComparer); foreach (FileSystemEntity f in sortedRelatedFiles) { try { // Split files ParsedPath parsed = new ParsedPath(this, f.FullPath, f); if (parsedFileDictionaly.ContainsKey(parsed.LogicalFileName) == false) { FileSystemEntity newFileEntity = new FileSystemEntity( fullPath: parsed.LogicalFilePath, name: PathParser.GetFileName(parsed.LogicalFileName), size: f.Size + parsed.FileNumber * Params.MaxSinglePhysicalFileSize, physicalSize: f.PhysicalSize, attributes: f.Attributes, creationTime: f.CreationTime, lastWriteTime: f.LastWriteTime, lastAccessTime: f.LastAccessTime ); parsedFileDictionaly.Add(parsed.LogicalFileName, newFileEntity); } else { var fileEntity = parsedFileDictionaly[parsed.LogicalFileName]; fileEntity.PhysicalSize += f.PhysicalSize; if (fileEntity.CreationTime > f.CreationTime) { fileEntity.CreationTime = f.CreationTime; } if (fileEntity.LastWriteTime < f.LastWriteTime) { fileEntity.LastWriteTime = f.LastWriteTime; } if (fileEntity.LastAccessTime < f.LastAccessTime) { fileEntity.LastAccessTime = f.LastAccessTime; } } } catch { } } var logicalFiles = parsedFileDictionaly.Values.Where(x => normalFileHashSet.Contains(x.Name) == false); var retList = dirEntities.Where(x => x.IsDirectory) .Concat(logicalFiles) .Concat(normalFiles) .OrderByDescending(x => x.IsDirectory) .ThenBy(x => x.Name); return(retList._ToArrayList()); } }