コード例 #1
0
        private static void genFile(string inputDir, string outputDir)
        {
            DirectoryInfo inputDirInfo  = new DirectoryInfo(inputDir);
            DirectoryInfo outputDirInfo = new DirectoryInfo(outputDir);

            if (!outputDirInfo.Exists)
            {
                outputDirInfo.Create();
            }

            string fileCfgPath = outputDir + "\\files.cfg";

            using (StreamWriter sw = new StreamWriter(fileCfgPath, true)) {
                foreach (FileInfo file in inputDirInfo.GetFiles())
                {
                    string name     = file.Name;
                    string path     = file.FullName;
                    string zipName  = name + ".7z";
                    string zipPath  = outputDir + "\\" + zipName;
                    string hashPath = outputDir + "\\" + name + ".hash";
                    File.WriteAllText(hashPath, md5Calc(path));
                    Zippy.compress(path, zipPath);
                    //string[] temp = {path, zipPath};
                    //queue.Enqueue(temp);
                    sw.WriteLine(name);
                }
            }
        }
コード例 #2
0
 public static void deQueue()
 {
     if (queue.Any())
     {
         string[] temp = queue.Dequeue();
         Zippy.compress(temp[0], temp[1]);
     }
     else
     {
         WindowManager.mainWindow.IsEnabled = true;
     }
 }
コード例 #3
0
        private static void generate(object sender, DoWorkEventArgs e)
        {
            bw1.DoWork -= generate;
            BitmapImage modRed   = new BitmapImage(new Uri(@"pack://*****:*****@"pack://application:,,,/Slick Updater Beta;component/Resources/modGreen.png"));

            DataGrid listView = WindowManager.mainWindow.outputDirListBox;

            string        outputDir     = ConfigManager.fetch("repoGen", "outputDir");
            DirectoryInfo outputDirInfo = new DirectoryInfo(outputDir);

            if (!Directory.Exists(outputDir))
            {
                Directory.CreateDirectory(outputDir);
            }

            outputDirInfo.Delete(true);



            Directory.CreateDirectory(outputDir);
            using (StreamWriter modsw = new StreamWriter(outputDir + "\\modlist.cfg", true)) {
                for (int i = 0; i < listView.Items.Count; i++)
                {
                    modSourceFolder modSource        = listView.Items.GetItemAt(i) as modSourceFolder;
                    string          modFolderName    = modSource.modFolderName;
                    string          modVersionNumber = modSource.modVersion;
                    string          inputDir         = ConfigManager.fetch("repoGen", "inputDir");
                    if (Directory.Exists(inputDir))
                    {
                        string inputModDir = inputDir + "\\" + modFolderName;
                        //genFile(inputModDir);
                        DirectoryInfo dir = new DirectoryInfo(inputModDir);
                        if (dir.Exists)
                        {
                            modsw.WriteLine(modFolderName);
                            //Create output Directory if it doesn't exist.
                            //Create modfolder in outputdir if it doesn't exits
                            if (!Directory.Exists(outputDir + "\\" + modFolderName))
                            {
                                Directory.CreateDirectory(outputDir + "\\" + modFolderName);
                            }
                            string fileCfgPath = outputDir + "\\" + modFolderName + "\\files.cfg";
                            using (StreamWriter sw = new StreamWriter(fileCfgPath, true)) {
                                foreach (FileInfo fileInfo in dir.GetFiles())
                                {
                                    if (fileInfo.Name != "SU.version")
                                    {
                                        string name     = fileInfo.Name;
                                        string path     = fileInfo.FullName;
                                        string zipName  = name + ".7z";
                                        string zipPath  = outputDir + "\\" + modFolderName + "\\" + zipName;
                                        string hashPath = outputDir + "\\" + modFolderName + "\\" + name + ".hash";
                                        File.WriteAllText(hashPath, md5Calc(path));
                                        //string[] temp = {path, zipPath};
                                        //queue.Enqueue(temp);
                                        Zippy.compress(path, zipPath);
                                        sw.WriteLine(name);
                                    }
                                }
                            }
                            string dirCfgPath = outputDir + "\\" + modFolderName + "\\dirs.cfg";
                            using (StreamWriter sw = new StreamWriter(dirCfgPath, true)) {
                                foreach (DirectoryInfo directory in dir.GetDirectories())
                                {
                                    string sourcePath = directory.FullName;
                                    string sourceName = directory.Name;
                                    string outDir     = outputDir + "\\" + modFolderName + "\\" + sourceName;
                                    genFile(sourcePath, outDir);
                                    genDir(sourcePath, outDir);
                                    sw.WriteLine(sourceName);
                                }
                            }
                            File.WriteAllText(outputDir + "\\" + modFolderName + "\\SU.version", modVersionNumber);
                            DirectoryInfo source      = new DirectoryInfo(inputDir + "\\" + modFolderName);
                            FileInfo[]    sourceFiles = source.GetFiles("*", SearchOption.AllDirectories);
                            File.WriteAllText(outputDir + "\\" + modFolderName + "\\count.txt", sourceFiles.Length.ToString());
                        }
                    }
                }
            }
        }