private static void AddLocalFile(StartupInfo info, string[] args)
        {
            string          path = args[0];
            ArchiveOpenMode mode =
                File.Exists(path) ? ArchiveOpenMode.OPEN : ArchiveOpenMode.CREATE;
            Archiver a = new Archiver(path, mode);

            a.AddLocal(args[1], args[2]);
            a.Dispose(true);
        }
Esempio n. 2
0
        private static void AddWebDirectory(StartupInfo info, string[] args)
        {
            string          path = args[0];
            ArchiveOpenMode mode =
                File.Exists(path) ? ArchiveOpenMode.OPEN : ArchiveOpenMode.CREATE;
            Archiver a      = new Archiver(path, mode);
            string   target = args.Length > 3 ? args[3] : "";

            a.AddWebFolder(args[1], args[2], target);
            a.Dispose(true);
        }
        private static void AddLocalDirectory(StartupInfo info, string[] args)
        {
            string          path = args[0];
            ArchiveOpenMode mode =
                File.Exists(path) ? ArchiveOpenMode.OPEN : ArchiveOpenMode.CREATE;
            Archiver a      = new Archiver(path, mode);
            string   target = args.Length > 2 ? args[2] : "";

            a.AddFolder(Path.GetFullPath(args[1]), target);
            a.Dispose(true);
        }
Esempio n. 4
0
        /// <summary>
        /// Creates an Archiver instance from a file and a read mode
        /// </summary>
        /// <param name="path">The path to open</param>
        /// <param name="mode">The Open Mode</param>
        public Archiver(string path, ArchiveOpenMode mode)
        {
            SourceFile = path;
            Console.WriteLine($"Created Archiver with path: {path}");

            _archiveStream = GetStream(path, mode);

            _archiveHeader = mode == ArchiveOpenMode.CREATE
                ? new ArchiveHeader()
                : ReadArchiveHeader();
            //Read Header
        }
Esempio n. 5
0
        /// <summary>
        /// Returns a Stream that is readable for the Archive Implementation.
        /// This contains the logic that works out if the archive is compressed
        /// </summary>
        /// <param name="path">Path of the File</param>
        /// <param name="mode">The Open mode</param>
        /// <returns></returns>
        private Stream GetStream(string path, ArchiveOpenMode mode)
        {
            if (mode == ArchiveOpenMode.CREATE)
            {
                return(File.Open(TempFile, FileMode.Create));
            }

            string s = Path.GetFileName(path);
            bool   c = IsCompressed(s);

            return(HandleArchiveCompression(File.Open(path, FileMode.Open), c));
        }