Esempio n. 1
0
        /// <summary>
        /// Packages a Folder with a maximum size for the archive files.
        /// </summary>
        /// <param name="folderPath">Folder to Archive</param>
        /// <param name="compression">Use Compression?</param>
        /// <returns>All archives paths that were created</returns>
        private static string[] PackageSplitted(string folderPath, bool compression)
        {
            List <string> ArchivePaths = new List <string>();

            int    cur    = 0;
            string tmpDir = Path.Combine(Path.GetTempPath(), Path.GetFileNameWithoutExtension(Path.GetTempFileName()));

            Directory.CreateDirectory(tmpDir);
            string[] files = Directory.GetFiles(Path.GetFullPath(folderPath), "*", SearchOption.AllDirectories);
            Archiver a     = null;

            for (int i = 0; i < files.Length; i++)
            {
                if (a == null || a._archiveHeader.LastEnd > MAX_SFX_ARCHIVE_SIZE_B)
                {
                    string f = Path.Combine(tmpDir, "sfxarchive.arch." + cur);
                    a?.Dispose(true, compression);
                    a = new Archiver(f, ArchiveOpenMode.CREATE);
                    ArchivePaths.Add(f);
                    cur++;
                }
                a.AddLocal(files[i], files[i].Replace(Path.GetFullPath(folderPath), ""));
            }
            a.Dispose(true, compression);

            return(ArchivePaths.ToArray());
        }
Esempio n. 2
0
        /// <summary>
        /// IInitializes the SFX Creation Process.
        /// </summary>
        /// <returns>The directory that the Source is unpacked to.</returns>
        private static string InitializeSFXSource()
        {
#if DEBUG
            string path = Path.GetFullPath(".\\sfx\\");
#else
            string path = Path.Combine(Path.GetTempPath(), Path.GetFileNameWithoutExtension(Path.GetTempFileName())) + "\\";
#endif
            Directory.CreateDirectory(path);
            Stream s = Assembly.GetExecutingAssembly().GetManifestResourceStream("Byt3.Archive.content.sfx-src.arch");
            if (s == null)
            {
                throw new Exception("This Version of Byt3.Archive was compiled without SFX Source.");
            }
            Archiver a = new Archiver(s, false);
            a.Extract(path);
            a.Dispose();
            return(path);
        }