コード例 #1
0
        public string FormateVolumeFolder(Volume volume)
        {
            var name = string.IsNullOrWhiteSpace(volume.Name) ? AppConfig.VolumePrefix : volume.Name;

            name = DirectoryHelpers.MakeValidPath(name);
            return(volume.Number.ToString(CultureInfo.InvariantCulture).PadLeft(3, '0') + " " + name);
        }
コード例 #2
0
        /// <summary>
        /// Упаковка всех томов.
        /// </summary>
        /// <param name="message">Папка манги.</param>
        public static List <string> CompressVolumes(string message)
        {
            var files = new List <string>();

            message = DirectoryHelpers.MakeValidPath(message) + Path.DirectorySeparatorChar;
            if (!Directory.Exists(message))
            {
                return(files);
            }

#warning Проверка не учитывает возможность переопределения папки в настройках типа манги.
            // Нельзя сжимать папку со всей мангой.
            if (message.Trim(Path.DirectorySeparatorChar) == AppConfig.DownloadFolder.Trim(Path.DirectorySeparatorChar))
            {
                return(files);
            }

            Log.AddFormat("Compression: Start {0}.", message);
            var volumes = Directory.GetDirectories(message);
            foreach (var volume in volumes)
            {
                var acr = string.Concat(message, GetFolderName(volume), ArchiveFormat);
                files = AddToArchive(acr, volume);
                DeleteCompressedFiles(files, volume);
            }
            Log.AddFormat("Compression: End {0}.", message);
            return(files);
        }
コード例 #3
0
        public string FormateChapterFolder(Chapter chapter)
        {
            var name = string.IsNullOrWhiteSpace(chapter.Name) ? AppConfig.ChapterPrefix : chapter.Name;

            name = DirectoryHelpers.MakeValidPath(name);
            return(chapter.Number.ToString(CultureInfo.InvariantCulture).PadLeft(chapter.Number % 1 == 0 ? 4 : 6, '0') + " " + name);
        }
コード例 #4
0
        /// <summary>
        /// Упаковка всех глав.
        /// </summary>
        /// <param name="message">Папка манги.</param>
        public static List <string> CompressChapters(string message)
        {
            var files = new List <string>();

            message = DirectoryHelpers.MakeValidPath(message) + Path.DirectorySeparatorChar;
            if (!Directory.Exists(message))
            {
                return(files);
            }

            // Нельзя сжимать папку со всей мангой.
            if (message.Trim(Path.DirectorySeparatorChar) == AppConfig.DownloadFolder.Trim(Path.DirectorySeparatorChar))
            {
                return(files);
            }

            Log.AddFormat("Compression: Start {0}.", message);
            var volumes = Directory.GetDirectories(message);

            foreach (var volume in volumes)
            {
                var chapters = Directory.GetDirectories(volume);
                foreach (var chapter in chapters)
                {
                    var acr = string.Concat(volume, Path.DirectorySeparatorChar,
                                            GetFolderName(chapter), ArchiveFormat);
                    files = AddToArchive(acr, chapter);
                    DeleteCompressedFiles(files, chapter);
                }
            }
            Log.AddFormat("Compression: End {0}.", message);
            return(files);
        }