コード例 #1
0
        public void GetArchiveFilenames()
        {
            string archiveName = "./Test.vol";

            VolFile.CreateArchive(archiveName, new string[0]);

            // Scope block to ensures ResourceManager is destructed after use
            // This ensures the VOL file is closed before attempting to delete it
            // This is needed for Windows filesystem semantics
            using (ResourceManager resourceManager = new ResourceManager("./"))
            {
                CollectionAssert.AreEqual(new string[] { archiveName }, resourceManager.GetArchiveFilenames());
            }

            File.Delete(archiveName);
        }
コード例 #2
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.");
            }
        }
コード例 #3
0
        public void VolFile_EmptyArchive()
        {
            const string archiveFilename = "EmptyArchive.vol";

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

                using (VolFile archiveFile = new VolFile(archiveFilename))
                {
                    //SCOPED_TRACE("Empty Volume File");
                    TestEmptyArchive(archiveFile, archiveFilename);

                    Assert.ThrowsException <ArgumentOutOfRangeException>(() => archiveFile.GetCompressionCode(0));
                }
            }

            File.Delete(archiveFilename);
        }