Пример #1
0
        public async Task Install()
        {
            Console.WriteLine("Getting link to latest ffmpeg");
            string link = await GetLinkFromWebPage();

            Console.WriteLine("Downloading ffmpeg");
            using (MemoryStream stream = await Download(link))
                using (SevenZipArchive archive = SevenZipArchive.Open(stream))
                {
                    Console.WriteLine("Unpacking ffmpeg");
                    string[] files = new string[] { "ffmpeg.exe", "ffprobe.exe" };
                    foreach (string file in files)
                    {
                        SevenZipArchiveEntry f = archive.Entries.First(x => x.Key.Contains(file));
                        string name            = f.Key.Substring(f.Key.LastIndexOf('/') + 1);
                        CheckDirAndCreate(FolderPath);
                        using (Stream entryStream = f.OpenEntryStream())
                            using (FileStream fileStream = File.OpenWrite(Path.Combine(FolderPath, name)))
                                await entryStream.CopyToAsync(fileStream);
                    }
                }
            Console.WriteLine("Update enviroment");
            SetEnvironment();
            Console.WriteLine("Set fontconfig");
            SetFontConfig();
            Console.WriteLine("Copying vp9.exe to " + FolderPath);
            string location = System.Reflection.Assembly.GetEntryAssembly().Location;

            File.Copy(location, Path.Combine(FolderPath, Path.GetFileName(location)));
        }
Пример #2
0
        public SqlDumpReader(string filePath)
        {
            string fileExtension = Path.GetExtension(filePath).ToLower();

            if (!SUPPORTED_DUMP_FILE_EXTENSIONS.Contains(fileExtension))
            {
                throw new Exception($"{fileExtension} is not in the list of supported database dump file extensions.");
            }
            switch (fileExtension.ToLower())
            {
            case ".zip":
                zipArchive = ZipArchive.Open(filePath);
                ZipArchiveEntry firstZipArchiveEntry = zipArchive.Entries.First();
                FileSize     = firstZipArchiveEntry.Size;
                streamReader = new StreamReader(firstZipArchiveEntry.OpenEntryStream());
                break;

            case ".rar":
                rarArchive = RarArchive.Open(filePath);
                RarArchiveEntry firstRarArchiveEntry = rarArchive.Entries.First();
                FileSize     = firstRarArchiveEntry.Size;
                streamReader = new StreamReader(firstRarArchiveEntry.OpenEntryStream());
                break;

            case ".gz":
                gZipArchive = GZipArchive.Open(filePath);
                GZipArchiveEntry firstGZipArchiveEntry = gZipArchive.Entries.First();
                FileSize     = firstGZipArchiveEntry.Size;
                streamReader = new StreamReader(firstGZipArchiveEntry.OpenEntryStream());
                break;

            case ".7z":
                sevenZipArchive = SevenZipArchive.Open(filePath);
                SevenZipArchiveEntry firstSevenZipArchiveEntry = sevenZipArchive.Entries.First();
                FileSize     = firstSevenZipArchiveEntry.Size;
                streamReader = new StreamReader(new PositioningStream(firstSevenZipArchiveEntry.OpenEntryStream()));
                break;

            default:
                FileSize     = new FileInfo(filePath).Length;
                streamReader = new StreamReader(filePath);
                break;
            }
            CurrentFilePosition = 0;
        }
Пример #3
0
        public SqlDumpReader(string filePath)
        {
            string fileExtension = Path.GetExtension(filePath);

            switch (fileExtension.ToLower())
            {
            case ".zip":
                zipArchive = ZipArchive.Open(filePath);
                ZipArchiveEntry firstZipArchiveEntry = zipArchive.Entries.First();
                FileSize     = firstZipArchiveEntry.Size;
                streamReader = new StreamReader(firstZipArchiveEntry.OpenEntryStream());
                break;

            case ".rar":
                rarArchive = RarArchive.Open(filePath);
                RarArchiveEntry firstRarArchiveEntry = rarArchive.Entries.First();
                FileSize     = firstRarArchiveEntry.Size;
                streamReader = new StreamReader(firstRarArchiveEntry.OpenEntryStream());
                break;

            case ".gz":
                gZipArchive = GZipArchive.Open(filePath);
                GZipArchiveEntry firstGZipArchiveEntry = gZipArchive.Entries.First();
                FileSize     = firstGZipArchiveEntry.Size;
                streamReader = new StreamReader(firstGZipArchiveEntry.OpenEntryStream());
                break;

            case ".7z":
                sevenZipArchive = SevenZipArchive.Open(filePath);
                SevenZipArchiveEntry firstSevenZipArchiveEntry = sevenZipArchive.Entries.First();
                FileSize     = firstSevenZipArchiveEntry.Size;
                streamReader = new StreamReader(firstSevenZipArchiveEntry.OpenEntryStream());
                break;

            default:
                FileSize     = new FileInfo(filePath).Length;
                streamReader = new StreamReader(filePath);
                break;
            }
            CurrentFilePosition = 0;
        }