Exemple #1
0
        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);
                }
            }
        }
Exemple #2
0
        private void addDirectory(RARFileInfo rarEntry)
        {
            string path = rarEntry.FileName;

            if (path.EndsWith("\\")) // w drug¹ stronê slash
            {
                path = path.Substring(0, path.Length - 1);
            }
            string[] pathParts      = path.Split('\\');
            IFolder  searchInFolder = this;

            foreach (string pathPart in pathParts)
            {
                searchInFolder = findOrCreateFolder(pathPart, searchInFolder, rarEntry);
            }
        }
Exemple #3
0
        private static IFolder findOrCreateFolder(string folderName, IFolder searchInFolder, RARFileInfo rarEntry)
        {
            foreach (IFolder folder in searchInFolder.Folders)
            {
                if ((folder as ItemInDatabase).Name == folderName)
                {
                    return(folder);
                }
            }
            FolderInDatabase newFolder = new FolderInDatabase(searchInFolder);

            // newFolder.Description = zipEntry.Comment;
            newFolder.CreationTime = rarEntry.FileTime;
            newFolder.Name         = folderName;
            if (rarEntry.FileAttributes > 0)
            {
                newFolder.Attributes = (FileAttributes)rarEntry.FileAttributes;
            }
            else
            {
                newFolder.Attributes = FileAttributes.Directory;
            }
            searchInFolder.AddToFolders(newFolder);
            return(newFolder);
        }
Exemple #4
0
        private static void FillFolder(string Path, string[] Names, int index, CFolder rarfolder, RARFileInfo RE)
        {
            if (!(rarfolder.Folders.Contains(Names[index])))
            {
                if ((Names.Length <= index + 1) && (!RE.IsDirectory))
                {
                    rarfolder.Files.Add(Names[index]);
                    rarfolder.Files[rarfolder.Files.Count - 1].Size             = RE.UnpackedSize;
                    rarfolder.Files[rarfolder.Files.Count - 1].LastModifiedTime = RE.FileTime;
                }
                else
                {
                    rarfolder.Folders[rarfolder.Folders.Add(Names[index])].CreatedTime = RE.FileTime;
                }
            }

            index++;
            if (Names.Length <= index)
            {
                return;
            }
            FillFolder(Path, Names, index, rarfolder.Folders[Names[index - 1]], RE);
        }
Exemple #5
0
 public NewFileEventArgs(RARFileInfo fileInfo)
 {
     this.fileInfo = fileInfo;
 }