상속: IDisposable
예제 #1
0
        public string OutputFile(string path, string content, string outputPath)
        {
            try
            {
                using (SevenZipFile sevenZipFile = new SevenZipFile(path))
                {
                    lock (sevenZipFile.Extractor)
                    {
                        outputPath = outputPath + Utility.GetExtension(content).ToLowerInvariant();
                        using (FileStream outputFile = File.Open(outputPath, FileMode.Create))
                        {
                            try
                            {
                                sevenZipFile.Extractor.ExtractFile(content, outputFile);
                            }
                            catch (SevenZipException sevenZipException)
                            {
                                throw new MangaContentMismatchException(path, sevenZipException);
                            }
                        }
                    }
                }
            }
            catch (SevenZipException sevenZipException)
            {
                throw new MangaWrongFormatException(path, sevenZipException);
            }

            return outputPath;
        }
예제 #2
0
        public string[] GetContent(string path)
        {
            List<string> content = new List<string>();

            try
            {
                using (SevenZipFile sevenZipFile = new SevenZipFile(path))
                {
                    lock (sevenZipFile.Extractor)
                    {
                        foreach (string fileName in sevenZipFile.Extractor.ArchiveFileNames)
                        {
                            string extension = Utility.GetExtension(fileName).ToLowerInvariant();

                            if (Constants.FileExtensionsInArchive.Contains(extension))
                            {
                                content.Add(fileName);
                            }
                        }
                    }
                }

                content.Sort((f1, f2) => Utility.StrCmpLogicalW(f1, f2));
            }
            catch (SevenZipException)
            {
            }

            return content.ToArray();
        }
예제 #3
0
        public bool TryOpen(string path)
        {
            bool validFile = false;

            try
            {
                using (SevenZipFile sevenZipFile = new SevenZipFile(path))
                {
                    lock (sevenZipFile.Extractor)
                    {
                        foreach (string fileName in sevenZipFile.Extractor.ArchiveFileNames)
                        {
                            string extension = Utility.GetExtension(fileName).ToLowerInvariant();

                            if (Constants.FileExtensionsInArchive.Contains(extension))
                            {
                                validFile = true;
                                break;
                            }
                        }
                    }
                }
            }
            catch (SevenZipException)
            {
            }

            return validFile;
        }