private void addFile(TarEntry tarEntry) { string path = tarEntry.Name; if (path.EndsWith("/")) { path = path.Substring(0, path.Length - 1); } string[] pathParts = path.Split('/'); IFolder searchInFolder = this; for (int i = 0; i < pathParts.Length; i++) { if (i != pathParts.Length - 1) { searchInFolder = findOrCreateFolder(pathParts[i], searchInFolder, tarEntry); } else // ostatnia nazwa to nazwa pliku { FileInDatabase file = new FileInDatabase(searchInFolder); file.CreationTime = tarEntry.ModTime; file.Name = pathParts[i]; file.Length = tarEntry.Size; file.Extension = Path.GetExtension(file.Name); searchInFolder.AddToFiles(file); } } }
private void addFile(RARFileInfo rarEntry) { string path = rarEntry.FileName; if (path.EndsWith("\\")) // backslash { path = path.Substring(0, path.Length - 1); } string[] pathParts = path.Split('\\'); IFolder searchInFolder = this; for (int i = 0; i < pathParts.Length; i++) { if (i != pathParts.Length - 1) { searchInFolder = findOrCreateFolder(pathParts[i], searchInFolder, rarEntry); } else // ostatnia nazwa to nazwa pliku { FileInDatabase file = new FileInDatabase(searchInFolder); if (rarEntry.FileAttributes > 0) { file.Attributes = (FileAttributes)rarEntry.FileAttributes; } file.Crc = (uint)rarEntry.FileCRC; file.CreationTime = rarEntry.FileTime; file.Name = pathParts[i]; file.Length = rarEntry.UnpackedSize; file.Extension = Path.GetExtension(file.Name); searchInFolder.AddToFiles(file); } } }
private void addFile(ZipEntry zipEntry) { string path = zipEntry.Name; if (path.EndsWith("/")) { path = path.Substring(0, path.Length - 1); } string[] pathParts = path.Split('/'); IFolder searchInFolder = this; for (int i = 0; i < pathParts.Length; i++) { if (i != pathParts.Length - 1) { searchInFolder = findOrCreateFolder(pathParts[i], searchInFolder, zipEntry); } else // ostatnia nazwa to nazwa pliku { FileInDatabase file = new FileInDatabase(searchInFolder); file.Description = zipEntry.Comment; if (zipEntry.HasCrc) { file.Crc = (uint)zipEntry.Crc; } file.CreationTime = zipEntry.DateTime; //if (zipEntry.ExternalFileAttributes < 1) // file.Attributes = FileAttributes.Normal; //else if (zipEntry.ExternalFileAttributes > 0) { file.Attributes = (FileAttributes)zipEntry.ExternalFileAttributes; } file.Name = pathParts[i]; file.Length = zipEntry.Size; file.Extension = Path.GetExtension(file.Name); searchInFolder.AddToFiles(file); } } }
private static void ReadAllFiles(SQLiteConnection conn, VolumeDatabase mem) { // All folders have been read. // Read ALL the file rows, and push them into the correct folder // NOTE: this is *only* faster if folder-by-id lookup is fast enough, which the HashTable gives us string txt = "SELECT * FROM [FILES]"; using (SQLiteCommand cmd = new SQLiteCommand(txt, conn)) { using (SQLiteDataReader rdr = cmd.ExecuteReader()) { while (rdr.Read()) { int ownerId; var afile = FileFromRow(rdr, out ownerId); IFolder fid = _foldHash[ownerId] as IFolder; fid.AddToFiles(afile); _fileHash.Add(afile.DbId, afile); } } } }