bool DlgCompareDir::FetchDir(String dir, VectorMap<String, FileInfo>& files, VectorMap<String, String>& dirs) { FindFile ff; if(!ff.Search(AppendFileName(dir, "*"))) return false; do if(ff.IsFile() && PatternMatchMulti(fm, ff.GetName())) files.Add(NormalizePathCase(ff.GetName()), FileInfo(ff.GetName(), ff.GetLength(), ff.GetLastWriteTime())); else if(ff.IsFolder()) dirs.Add(NormalizePathCase(ff.GetName()), ff.GetName()); while(ff.Next()); return true; }
Array<FileSystemInfo::FileInfo> FileSystemInfo::Find(String mask, int max_count, bool unmounted) const { Array<FileInfo> fi; if(IsNull(mask)) { // root #ifdef PLATFORM_WINCE FileInfo& f = fi.Add(); f.filename = "\\"; f.root_style = ROOT_FIXED; #elif defined(PLATFORM_WIN32) char drive[4] = "?:\\"; for(int c = 'A'; c <= 'Z'; c++) { *drive = c; int n = GetDriveType(drive); if(n == DRIVE_NO_ROOT_DIR) continue; FileInfo& f = fi.Add(); f.filename = drive; char name[256], system[256]; DWORD d; if(c != 'A' && c != 'B' && n != DRIVE_REMOTE && n != DRIVE_UNKNOWN) { bool b = GetVolumeInformation(drive, name, 256, &d, &d, &d, system, 256); if(b) { if(*name) f.root_desc << " " << FromSystemCharset(name); } else if(n == DRIVE_REMOVABLE || n == DRIVE_CDROM) { if(unmounted) { f.root_desc = t_("Empty drive"); } else { fi.Drop(); continue; } } } switch(n) { default: case DRIVE_UNKNOWN: f.root_style = ROOT_UNKNOWN; break; case DRIVE_NO_ROOT_DIR: f.root_style = ROOT_NO_ROOT_DIR; break; case DRIVE_REMOVABLE: f.root_style = ROOT_REMOVABLE; break; case DRIVE_FIXED: f.root_style = ROOT_FIXED; break; case DRIVE_REMOTE: f.root_style = ROOT_REMOTE; break; case DRIVE_CDROM: f.root_style = ROOT_CDROM; break; case DRIVE_RAMDISK: f.root_style = ROOT_RAMDISK; break; } } #elif defined(PLATFORM_POSIX) FileInfo& f = fi.Add(); f.filename = "/"; f.root_style = ROOT_FIXED; #endif } else { FindFile ff; if(ff.Search(mask)) do { FileInfo& f = fi.Add(); f.filename = ff.GetName(); #ifndef PLATFORM_POSIX f.is_archive = ff.IsArchive(); f.is_compressed = ff.IsCompressed(); f.is_hidden = ff.IsHidden(); f.is_system = ff.IsSystem(); f.is_temporary = ff.IsTemporary(); #endif f.is_read_only = ff.IsReadOnly(); f.length = ff.GetLength(); #ifdef PLATFORM_POSIX f.creation_time = ff.GetLastChangeTime(); f.unix_mode = ff.GetMode(); #endif f.last_access_time = ff.GetLastAccessTime(); f.last_write_time = ff.GetLastWriteTime(); #ifdef PLATFORM_WIN32 f.creation_time = ff.GetCreationTime(); f.unix_mode = 0; #endif f.read_only = ff.IsReadOnly(); f.is_directory = ff.IsDirectory(); f.is_folder = ff.IsFolder(); f.is_file = ff.IsFile(); #ifdef PLATFORM_POSIX f.is_symlink = ff.IsSymLink(); #endif } while(ff.Next() && fi.GetCount() < max_count); } return fi; }