Beispiel #1
0
        private void OnExtractFileArchivePath(string path)
        {
            // Get the appropriate archive type
            string      extension = Path.GetExtension(path);
            ArchiveFile archive;

            switch (extension.ToLower())
            {
            case ".vol":    archive = new VolFile(path);    break;

            case ".clm":    archive = new ClmFile(path);    break;

            default:
                interactable = true;
                Debug.Log("Invalid archive selected.");
                return;
            }

            // Get list of files from the archive
            List <string> fileNames = new List <string>();

            for (int i = 0; i < archive.GetCount(); ++i)
            {
                fileNames.Add(archive.GetName(i));
            }

            // Open list of file names for selection
            ListSelectDialog.Create(fileNames, "Extract File", "Select", (string fileName) => OnExtractFileSelected(archive, fileName), () => OnExtractFileCanceled(archive));
        }
Beispiel #2
0
        public void ClmFile_EmptyArchive()
        {
            const string archiveFilename = "EmptyArchive.clm";

            {
                // Create an empty archive
                List <string> filesToPack = new List <string>();
                ClmFile.CreateArchive(archiveFilename, filesToPack);

                using (ClmFile archiveFile = new ClmFile(archiveFilename))
                {
                    //SCOPED_TRACE("Empty CLM File");
                    TestEmptyArchive(archiveFile, archiveFilename);
                }
            }

            File.Delete(archiveFilename);
        }
Beispiel #3
0
        private void CreateArchive(string srcDirectory, string archivePath)
        {
            interactable = true;

            string[] files = Directory.GetFiles(srcDirectory, "*.*", SearchOption.TopDirectoryOnly);

            // Cull file names that are too long
            List <string> culledFiles = new List <string>(files.Length);

            foreach (string name in files)
            {
                string noExt = Path.GetFileNameWithoutExtension(name);

                if (noExt.Length <= 8)
                {
                    culledFiles.Add(name);
                }
            }


            string extension = Path.GetExtension(archivePath);

            switch (extension)
            {
            case ".vol":    VolFile.CreateArchive(archivePath, culledFiles);        break;

            case ".clm":    ClmFile.CreateArchive(archivePath, culledFiles);        break;

            default:
                Debug.Log("Invalid archive type selected.");
                return;
            }

            if (files.Length == culledFiles.Count)
            {
                Debug.Log(Path.GetFileName(archivePath) + " created successfully.");
            }
            else
            {
                int filesRemoved = files.Length - culledFiles.Count;
                Debug.Log(filesRemoved.ToString() + " files exceeded 8 character limit and were not archived.");
            }
        }
Beispiel #4
0
        private void OnExtractAllFilesSavePathSelected(string archivePath, string destDirectory)
        {
            interactable = true;

            // Get the appropriate archive type
            string      extension = Path.GetExtension(archivePath);
            ArchiveFile archive;

            switch (extension.ToLower())
            {
            case ".vol":    archive = new VolFile(archivePath);     break;

            case ".clm":    archive = new ClmFile(archivePath);     break;

            default:
                Debug.Log("Invalid archive selected.");
                return;
            }

            archive.ExtractAllFiles(destDirectory);
            archive.Dispose();

            Debug.Log("Files extracted successfully.");
        }