Exemple #1
0
 public IHtmlString InitThisJs()
 {
     return(InitFiles(IOExtension.MakeUri("Areas",
                                          ViewContext.RouteData.Values["area"].ToString(),
                                          ViewContext.RouteData.Values["controller"].ToString(),
                                          ViewContext.RouteData.Values["action"].ToString() + ".js")));
 }
 public void IntroScreensCreator_Dispose(object sender, EventArgs e)
 {
     if (Directory.Exists(tmpWorkDir))
     {
         IOExtension.DeleteDirectory(tmpWorkDir);
     }
 }
Exemple #3
0
        public IHtmlString InitFiles(params string[] files)
        {
            StringBuilder sb = new StringBuilder();

            files.ForEach(path =>
            {
                if (!path.StartsWith("HTTP", true, null))
                {
                    path = IOExtension.MakeUri(Request.Url.Scheme + "://" + Request.Url.Authority, Request.ApplicationPath, path);
                }
                Uri uri      = new Uri(path);
                string query = uri.Query;
                if (string.IsNullOrEmpty(query))
                {
                    path += "?" + GetTm(path);
                }
                else
                {
                    path += "&" + GetTm(path);
                }
                if (uri.LocalPath.ToLower().EndsWith(".css"))
                {
                    sb.Append(Styles.Render(path));
                }
                else if (uri.LocalPath.ToLower().EndsWith(".js"))
                {
                    sb.Append(Scripts.Render(path));
                }
                else
                {
                    throw new Exception($"引用的文件{path}后缀不是js或css");
                }
            });
            return(Html.Raw(sb.ToString()));
        }
        /// <summary>
        /// Converts CDLC packages between platforms
        /// </summary>
        /// <param name="sourcePackage"></param>
        /// <param name="sourcePlatform"></param>
        /// <param name="targetPlatform"></param>
        /// <param name="appId"></param>
        /// <returns>Errors if any</returns>
        public static string Convert(string sourcePackage, Platform sourcePlatform, Platform targetPlatform, string appId)
        {
            var needRebuildPackage = sourcePlatform.IsConsole != targetPlatform.IsConsole;
            var tmpDir             = Path.GetTempPath();

            // key to good conversion is to overwriteSongXml
            var unpackedDir = Packer.Unpack(sourcePackage, tmpDir, sourcePlatform, false, true);

            // DESTINATION
            var nameTemplate = (!targetPlatform.IsConsole) ? "{0}{1}.psarc" : "{0}{1}";
            var packageName  = Path.GetFileNameWithoutExtension(sourcePackage).StripPlatformEndName();

            packageName = packageName.Replace(".", "_");
            var targetFileName = String.Format(nameTemplate, Path.Combine(Path.GetDirectoryName(sourcePackage), packageName), targetPlatform.GetPathName()[2]);

            // force package rebuilding for testing
            // needRebuildPackage = true;
            // CONVERSION
            if (needRebuildPackage)
            {
                ConvertPackageRebuilding(unpackedDir, targetFileName, sourcePlatform, targetPlatform, appId);
            }
            else
            {
                ConvertPackageForSimilarPlatform(unpackedDir, targetFileName, sourcePlatform, targetPlatform, appId);
            }

            IOExtension.DeleteDirectory(unpackedDir);

            return(String.Empty);
        }
 public void DLCInlayCreator_Dispose(object sender, EventArgs e)
 {
     if (Directory.Exists(defaultDir))
     {
         IOExtension.DeleteDirectory(defaultDir);
     }
 }
Exemple #6
0
 public SaveSetting(string tag, SaveReadingType type = SaveReadingType.Delete)
 {
     path = SaveDefaultData.Path + tag;
     if (type == SaveReadingType.Delete)
     {
         IOExtension.DeleteFileIfExists(path);
     }
 }
        private static void ConvertPackageForSimilarPlatform(string unpackedDir, string targetFileName, Platform sourcePlatform, Platform targetPlatform, string appId)
        {
            // Old and new paths
            var sourceDir0 = sourcePlatform.GetPathName()[0].ToLower();
            var sourceDir1 = sourcePlatform.GetPathName()[1].ToLower();
            var targetDir0 = targetPlatform.GetPathName()[0].ToLower();
            var targetDir1 = targetPlatform.GetPathName()[1].ToLower();

            if (!targetPlatform.IsConsole)
            {
                // Replace AppId
                var appIdFile = Path.Combine(unpackedDir, "appid.appid");
                File.WriteAllText(appIdFile, appId);
            }

            // Replace aggregate graph values
            var aggregateFile      = Directory.EnumerateFiles(unpackedDir, "*.nt", SearchOption.AllDirectories).FirstOrDefault();
            var aggregateGraphText = File.ReadAllText(aggregateFile);

            // Tags
            aggregateGraphText = Regex.Replace(aggregateGraphText, GraphItem.GetPlatformTagDescription(sourcePlatform.platform), GraphItem.GetPlatformTagDescription(targetPlatform.platform), RegexOptions.Multiline);
            // Paths
            aggregateGraphText = Regex.Replace(aggregateGraphText, sourceDir0, targetDir0, RegexOptions.Multiline);
            aggregateGraphText = Regex.Replace(aggregateGraphText, sourceDir1, targetDir1, RegexOptions.Multiline);
            File.WriteAllText(aggregateFile, aggregateGraphText);

            // Rename directories
            foreach (var dir in Directory.GetDirectories(unpackedDir, "*.*", SearchOption.AllDirectories))
            {
                if (dir.EndsWith(sourceDir0))
                {
                    var newDir = dir.Substring(0, dir.LastIndexOf(sourceDir0)) + targetDir0;
                    IOExtension.DeleteDirectory(newDir);
                    IOExtension.MoveDirectory(dir, newDir);
                }
                else if (dir.EndsWith(sourceDir1))
                {
                    var newDir = dir.Substring(0, dir.LastIndexOf(sourceDir1)) + targetDir1;
                    IOExtension.DeleteDirectory(newDir);
                    IOExtension.MoveDirectory(dir, newDir);
                }
            }

            // Recreates SNG because SNG have different keys in PC and Mac
            bool updateSNG = ((sourcePlatform.platform == GamePlatform.Pc && targetPlatform.platform == GamePlatform.Mac) || (sourcePlatform.platform == GamePlatform.Mac && targetPlatform.platform == GamePlatform.Pc));

            // Packing
            var dirToPack = unpackedDir;

            if (sourcePlatform.platform == GamePlatform.XBox360)
            {
                dirToPack = Directory.GetDirectories(Path.Combine(unpackedDir, Packer.ROOT_XBOX360))[0];
            }

            Packer.Pack(dirToPack, targetFileName, targetPlatform, updateSNG);
            IOExtension.DeleteDirectory(unpackedDir);
        }
Exemple #8
0
 public bool IsExists(string tag)
 {
     path = SaveDefaultData.Path + tag;
     if (!string.IsNullOrEmpty(path))
     {
         return(IOExtension.HasFileIfExists(path));
     }
     return(false);
 }
Exemple #9
0
        public override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            if (filterContext.HttpContext.Request.IsAjaxRequest())
            {
                UIResult res;
                //异常处理
                if (filterContext.Exception != null)
                {
                    filterContext.ExceptionHandled = true;
                    if (filterContext.Exception.GetInnerException() is zExceptionBase)
                    {
                        zExceptionBase ex = filterContext.Exception.GetInnerException() as zExceptionBase;
                        res = new UIResult()
                        {
                            Flag = ex.Flag,
                            Msg  = ex.Message
                        };
                    }
                    else
                    {
                        res = new UIResult()
                        {
                            Flag = -1,
                            Msg  = filterContext.Exception.InnerMessage()
                        };
                    }
                    filterContext.Result = res;
                }


                if (filterContext.Result is EmptyResult)
                {
                    filterContext.Result = new UIResult();
                }
                if (filterContext.Result is UIResult)
                {
                    filterContext.Result = new UIResult()
                    {
                        Data = (filterContext.Result as UIResult).GetData()
                    };
                }
            }
            else
            {
                filterContext.Controller.ViewBag.ControllerUrl =
                    IOExtension.MakeUri(
                        HttpExtension.GetWebBasePath(),
                        filterContext.RouteData.Values["area"].ToString(),
                        filterContext.RouteData.Values["controller"].ToString()) + "/";
                filterContext.Controller.ViewBag.CommonControllerUrl =
                    IOExtension.MakeUri(
                        HttpExtension.GetWebBasePath(),
                        "Base",
                        "Common") + "/";
            }
        }
            public Process CreateProcess(FileInfo texFile)
            {
                Process process = new Process();

                process.StartInfo.FileName        = IOExtension.FindExePath(this.Command);
                process.StartInfo.Arguments       = this.Arguments.Concat(new string[] { "\"" + texFile.FullName + "\"" }).Implode(" ");
                process.StartInfo.UseShellExecute = false;
                process.StartInfo.CreateNoWindow  = true;
                return(process);
            }
Exemple #11
0
 protected virtual void Dispose(Boolean disposing)
 {
     if (disposing)
     {
         if (_deleteOnClose && Directory.Exists(packageDir))
         {
             IOExtension.DeleteDirectory(packageDir);
         }
     }
 }
Exemple #12
0
 public void Do()
 {
     while (true)
     {
         try
         {
             string          configFilePath = IOExtension.GetBaesDir() + @"\Settings.Json";
             List <Settings> sets           = TxtReader.ReadToModel <Settings>(new JsonReaderSettings()
             {
                 FilePath = configFilePath,
                 Encoding = encoding
             });
             bool hasRun = false;
             if (sets != null)
             {
                 sets.ForEach(set =>
                 {
                     try
                     {
                         if (!set.CanDo())
                         {
                             return;
                         }
                         ServicesBase sb = new ServicesBase();
                         MethodInfo m    = sb.AutoService.GetType().GetMethod(set.MethodName);
                         if (m == null)
                         {
                             throw new Exception($"找不到方法{set.MethodName}");
                         }
                         m.Invoke(sb.AutoService, null);
                         set.LastRunTime = DateTime.Now;
                         Log.Info($"已执行{set.Name}");
                         hasRun = true;
                     }
                     catch (Exception ex)
                     {
                         Log.Error($"执行{set.Name}异常", ex.InnerMessage());
                     }
                 });
             }
             if (hasRun)
             {
                 TxtWriter.Write(configFilePath, sets.ToJson(true), encoding);
             }
         }
         catch (Exception ex)
         {
             Log.Error("服务异常", ex.InnerMessage());
         }
         finally
         {
             Thread.Sleep(SleepSecond * 1000);
         }
     }
 }
        private void btnPackSongPack_Click(object sender, EventArgs e)
        {
            var srcPath = String.Empty;
            var errMsg  = String.Empty;

            using (var fbd = new VistaFolderBrowserDialog())
            {
                fbd.Description  = "Select the Song Pack folder created in Step #1.";
                fbd.SelectedPath = destPath;

                if (fbd.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                srcPath = fbd.SelectedPath;
            }

            ToggleUIControls(false);
            GlobalExtension.UpdateProgress        = this.pbUpdateProgress;
            GlobalExtension.CurrentOperationLabel = this.lblCurrentOperation;
            Thread.Sleep(100); // give Globals a chance to initialize
            GlobalExtension.ShowProgress("Packing archive ...", 30);
            Application.DoEvents();

            try
            {
                Stopwatch sw = new Stopwatch();
                sw.Restart();

                var songPackDir = AggregateGraph2014.DoLikeSongPack(srcPath, NewAppId);
                destPath = Path.Combine(Path.GetDirectoryName(srcPath), String.Format("{0}_songpack_p.psarc", Path.GetFileName(srcPath)));
                // PC Only for now can't mix platform packages
                Packer.Pack(songPackDir, destPath, predefinedPlatform: new Platform(GamePlatform.Pc, GameVersion.RS2014));

                // clean up now (song pack folder)
                if (Directory.Exists(songPackDir))
                {
                    IOExtension.DeleteDirectory(songPackDir);
                }

                sw.Stop();
                GlobalExtension.ShowProgress("Finished packing archive (elapsed time): " + sw.Elapsed, 100);
            }
            catch (Exception ex)
            {
                errMsg  = String.Format("{0}\n{1}", ex.Message, ex.InnerException);
                errMsg += Environment.NewLine + "Make sure there aren't any non-PC CDLC in the SongPacks folder.";
            }

            PromptComplete(destPath, true, errMsg);
            GlobalExtension.Dispose();
            ToggleUIControls(true);
        }
Exemple #14
0
 private static void CSharpExtensions()
 {
     ClassExtention.Example();
     FuncOrActionOrEventExtension.Example();
     GenericExtention.Example();
     IEnumerableExtension.Example();
     IOExtension.Example();
     OOPExtension.Example();
     ReflectionExtension.Example();
     StringExtention.Example();
 }
Exemple #15
0
        private string TransformPath(MediaFile media)
        {
            string moviePath;

            moviePath = _fileNameTransformer.GetTokenizedFilePath(media.FullPath,
                                                                  new PathToken(media, LookupMovie(media)));
            moviePath = IOExtension.CleanFilePath(moviePath);
            moviePath = IOExtension.EnsureNonDuplicateName(moviePath, out int duplicateCount);
            Log.InfoFormat("Target moviePath sanitized. Possible {0} duplicates.", duplicateCount);

            return(moviePath);
        }
        private void UpdateStatic()
        {
            // unpack static.psarc
            const int numSteps = 5; // max number of times ReportProgress will be called
            var       step     = (int)Math.Round(1.0 / (numSteps + 2) * 100, 0);
            var       progress = 0;

            progress += step;
            ProcessStarted(progress, "Unpacking static file ... ");

            var srcPath  = Path.Combine(rsDir, "static.psarc");
            var destPath = Path.Combine(rsDir, "static.psarc.org");

            // backup the original static.psarc and never overwrite it
            if (!File.Exists(destPath))
            {
                File.Copy(srcPath, destPath, false);
            }

            var tmpModDir = Path.Combine(tmpWorkDir, "cis_static");

            if (Directory.Exists(tmpModDir))
            {
                IOExtension.DeleteDirectory(tmpModDir, true);
            }
            Directory.CreateDirectory(tmpModDir);

            destPath = tmpModDir;
            // Packer.Unpack(srcPath, destPath); // not working here
            ExternalApps.UnpackPsarc(srcPath, destPath, DLCInlayCreator.GlobalTitlePlatform);

            // convert user png images to dds images
            progress += step * 3;
            ProcessStarted(progress, "Converting user PNG images ...");

            // CRITICAL PATH AND ARGS
            var rootDir = string.Format("static_{0}", DLCInlayCreator.GlobalTitlePlatform);

            srcPath  = imageArray[6, 3];
            destPath = Path.Combine(tmpModDir, rootDir, "gfxassets\\views", Path.GetFileName(imageArray[6, 2]));
            ExternalApps.Png2Dds(srcPath, destPath, ImageHandler.Size2IntX(imageArray[6, 1]), ImageHandler.Size2IntY(imageArray[6, 1]));

            // repack static.psarc
            progress += step;
            ProcessStarted(progress, "Repacking static file ...");
            srcPath  = Path.Combine(tmpModDir, rootDir);
            destPath = Path.Combine(rsDir, "static.psarc");
            // Packer.Pack(srcPath, destPath);  // not working
            ExternalApps.RepackPsarc(srcPath, destPath, DLCInlayCreator.GlobalTitlePlatform);

            ProcessCompleted(null, null);
        }
Exemple #17
0
        public void IOUtilsTest_GetDirSubDirNameList_Count()
        {
            //Arrange
            int count = 0;

            //Act
            //Try to rename the GameObject
            count = IOExtension.GetDirSubDirNameList(testPath).Count;

            //Assert
            //The object has a new name
            Assert.AreEqual(1, count);
        }
Exemple #18
0
        public string GetExport(string filename, Action <ExcelWriter> ew)
        {
            string newname = $@"{filename}_{DateTime.Now.ToString("yyyy年MM月dd日HH时mm分ss秒")}.xlsx";

            IOExtension.MakeDir(true, $@"{IOExtension.GetBaesDir()}\File\Output\");
            string outpath = $@"{IOExtension.GetBaesDir()}\File\Output\{newname}";
            string tmppath = $@"{IOExtension.GetBaesDir()}\File\Template\{filename}.xlsx";

            ExcelWriter e = new ExcelWriter(tmppath, outpath);

            ew?.Invoke(e);
            e.Process();
            return("/File/Output/" + newname);
        }
        public void Init()
        {
            TestSettings.Instance.Load();
            if (!TestSettings.Instance.ResourcePaths.Any())
            {
                Assert.Fail("TestSettings Load Failed ...");
            }

            ConfigGlobals.IsUnitTest = true;
            packageCreator           = new DLCPackageCreator.DLCPackageCreator();

            // empty the 'Local Settings/Temp/UnitTest' directory before starting
            IOExtension.DeleteDirectory(TestSettings.Instance.TmpDestDir);
        }
Exemple #20
0
        public List <YHDZJL> GetYHDZJL(string merchant_no, string chkDate)
        {
            List <YHDZJL>      ret = new List <YHDZJL>();
            ReportFormResponse t   = new ReportFormResponse()
            {
                merchant_no = merchant_no,
                chkDate     = chkDate
            };
            ReportFormRequest res = Post <ReportFormResponse, ReportFormRequest>(Url, t);

            if (res.return_code != "00")
            {
                throw new Exception(res.return_msg);
            }
            using (Stream st = new MemoryStream(Convert.FromBase64String(res.fileData)))
            {
                IOExtension.GetTempPathAndDo(path =>
                {
                    CompressBase cm = new ZipCompress();
                    cm.DeCompression(st, path);
                    IOExtension.GetAllFiles(path).ForEach(file =>
                    {
                        ret = TxtReader.ReadToModel <YHDZJL>(new TableReaderSettings()
                        {
                            ColumnSplit = new string[] { "|" },
                            FilePath    = file.FullName,
                            RowSplit    = new string[] { "\n" },
                            RowSettings = new Dictionary <int, string>()   //这里处理格式
                            {
                                { 1, "SHBH" },
                                { 2, "ZDBH" },
                                { 3, "YHKH" },
                                { 4, "JYJE" },
                                { 5, "SXF" },
                                { 6, "JYRQ" },
                                { 7, "JYSJ" },
                                { 8, "JYLBH" },
                                { 9, "JYLBM" },
                                { 10, "QFSJ" },
                                { 11, "JGM" },
                                { 12, "ZFFS" },
                                { 13, "LSBH" }
                            }
                        });
                    });
                });
            }
            return(ret);
        }
Exemple #21
0
        /// <inheritdoc />
        public async Task <AnalyzedFile> Analyze(string filePath)
        {
            var file = new FileInfo(filePath);
            var item = new AnalyzedFile(filePath);

            Log.DebugFormat("Analyzing: {0}", file.Name);

            using (var db = new LiteDatabase(GlobalSettings.Default.ConnectionString))
            {
                var hashCollection = db.GetCollection <MediaFileHash>();
                var fileCollection = db.GetCollection <MediaFile>();

                // lookup for hash
                var hash = IOExtension.QuickHash(filePath);
                item.Hash = hash;
                var hashEntity = hashCollection.FindOne(x => x.Hash == hash);

                // the file has recognized hash on database and has matching movie information
                if (hashEntity != null && fileCollection.Exists(x => x.Hash == hashEntity.Hash))
                {
                    item.Title   = hashEntity.Title;
                    item.Year    = hashEntity.Year;
                    item.ImdbId  = hashEntity.ImdbId;
                    item.IsKnown = true;

                    Log.DebugFormat("File found on hash table: {0}", hash);
                }
                else
                {
                    // the file only has one information on database, guessing is needed
                    var cleaned = await _provider.GuessTitle(item.FullPath);

                    item.Title   = cleaned.Title;
                    item.Year    = cleaned.Year;
                    item.ImdbId  = cleaned.ImdbId;
                    item.IsKnown = false;

                    Log.DebugFormat("File hash recorded: {0}", hash);
                }
            }

            // find subtitle and poster
            var extraFile = FindAssociatedFiles(Path.GetDirectoryName(filePath));

            item.SubtitlePath = extraFile.Item1;
            item.PosterPath   = extraFile.Item2;

            return(item);
        }
        public void CreatePdf(string template, dynamic context, FileInfo destination)
        {
            // run in temporary directory
            var tempDir = IOExtension.CreateTempDirectory();

            try {
                var texFile = new FileInfo(Path.Combine(tempDir.FullName, "template.tex"));
                using (var writer = new StreamWriter(texFile.FullName))
                    writer.Write(template);
                this.CreatePdf(texFile, context, destination);
            } finally {
                // cleanup temporary directory
                Directory.Delete(tempDir.FullName, true);
            }
        }
Exemple #23
0
        public void ExtractBeforeConvert(string inputPath, string outputDir, bool allDif)
        {
            // unpacker creates the sng2tabDir directory if it doesn't exist
            string sng2tabDir  = Path.Combine(tmpWorkDir, "sng2tab");
            string unpackedDir = Packer.Unpack(inputPath, sng2tabDir);

            var sngFiles = Directory.EnumerateFiles(unpackedDir, "*.sng", SearchOption.AllDirectories);

            foreach (var sngFilePath in sngFiles)
            {
                Convert(sngFilePath, outputDir, allDif);
            }

            IOExtension.DeleteDirectory(sng2tabDir);
        }
Exemple #24
0
        int copy(string path_s, string path_t)
        {
            List <DirectoryInfo> dics = IOExtension.GetAllDirectorys(IOExtension.MakeDir(path_s));

            dics.ForEach((inx, dic) =>
            {
                IOExtension.MakeDir(true, dic.FullName.Replace(path_s, path_t));
            });
            _setlog($"创建完成{dics.Count}个文件夹");
            List <FileInfo> allfile = IOExtension.GetAllFiles(IOExtension.MakeDir(path_s));

            return(ShellFileOperation.Copy(
                       allfile.Select(a => a.FullName),
                       allfile.Select(a => a.FullName.Replace(path_s, path_t))
                       ));
        }
        public void Load()
        {
            ResourcesDir = Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase, "Resources");
            string[] fileExt = new string[] { "_p.psarc", "_m.psarc", "_ps3.psarc.edat", "_xbox", ".dat" };
            ResourcePaths = Directory.EnumerateFiles(ResourcesDir, "*", SearchOption.TopDirectoryOnly).Where(fi => fileExt.Any(fi.ToLower().EndsWith)).ToList();
            if (!ResourcePaths.Any())
            {
                throw new Exception("The 'Resources' directory contains no valid archive files ...");
            }

            TmpDestDir = Path.Combine(Path.GetTempPath(), "UnitTest");

            // start with clean 'Local Settings/Temp/UnitTest' directory
            IOExtension.DeleteDirectory(TmpDestDir);
            Directory.CreateDirectory(TmpDestDir);
        }
        public override void GenerateDynamic(Stream template, dynamic context, Stream output)
        {
            // run in temporary directory
            var tempDir = IOExtension.CreateTempDirectory();

            try {
                var pdfFile = new FileInfo(Path.Combine(tempDir.FullName, "output.pdf"));
                using (var stream = new StreamReader(template, Encoding.UTF8, true, 1024, leaveOpen: true))
                    this.CreatePdf(stream.ReadToEnd(), context, pdfFile);
                using (var stream = File.OpenRead(pdfFile.FullName))
                    stream.WriteTo(output);
            } finally {
                // cleanup temporary directory
                Directory.Delete(tempDir.FullName, true);
            }
        }
        private void SaveImages(object sender, DoWorkEventArgs e)
        {
            // method using Background Worker to report progress
            var       savePath = e.Argument as string;
            const int numSteps = 7; // max number of times progress change is reported
            var       step     = (int)Math.Round(1.0 / (numSteps + 2) * 100, 0);
            var       progress = 0;

            // Create temp folder for zipping files
            var tmpZipDir = Path.Combine(tmpWorkDir, "cis_zip");

            if (Directory.Exists(tmpZipDir))
            {
                IOExtension.DeleteDirectory(tmpZipDir, true);
            }
            Directory.CreateDirectory(tmpZipDir);

            // convert user png images to dds images
            for (int i = 0; i < imageArray.GetUpperBound(0); i++)
            {
                progress += step;
                bwSaveImages.ReportProgress(progress, "Converting user PNG images ... " + i.ToString());

                if (imageArray[i, 3] != null) // user has specified a replacement image
                {
                    // CRITICAL PATH AND ARGS
                    var srcPath  = imageArray[i, 3];
                    var destPath = Path.Combine(tmpZipDir, Path.GetFileName(imageArray[i, 2]));
                    ExternalApps.Png2Dds(srcPath, destPath, ImageHandler.Size2IntX(imageArray[i, 1]), ImageHandler.Size2IntY(imageArray[i, 1]));
                }
            }
            progress += step;
            bwSaveImages.ReportProgress(progress, "Saving Intro Screens Template file ... ");

            // Write ini file setup.smb
            var           iniFile = Path.Combine(tmpZipDir, "setup.smb");
            Configuration iniCFG  = new Configuration();

            iniCFG["General"].Add(new Setting("author", String.IsNullOrEmpty(txtAuthor.Text) ? "CSC" : txtAuthor.Text));
            iniCFG["General"].Add(new Setting("seqname", String.IsNullOrEmpty(txtSeqName.Text) ? "SystemSaved" : txtSeqName.Text));
            iniCFG["General"].Add(new Setting("cscvers", ToolkitVersion.RSTKGuiVersion));
            iniCFG["General"].Add(new Setting("modified", DateTime.Now.ToShortDateString()));
            iniCFG.Save(iniFile);

            // Zip intro sequence *.cis file
            ExternalApps.InjectZip(tmpZipDir, savePath, false, true);
        }
        private static List <Tone> ReadFromPackage(string packagePath, Platform platform)
        {
            List <Tone> tones       = new List <Tone>();
            string      appDir      = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            string      unpackedDir = Packer.Unpack(packagePath, appDir);

            string[] toneManifestFiles = Directory.GetFiles(unpackedDir, "tone*.manifest.json", SearchOption.AllDirectories);

            foreach (var file in toneManifestFiles)
            {
                tones.Add(ReadFromManifest(file));
            }

            IOExtension.DeleteDirectory(unpackedDir);

            return(tones);
        }
Exemple #29
0
        public static void GeneratePathScript()
        {
            AssetDatabase.SaveAssets();

            IOExtension.CreateDirIfNotExists(EditorPathManager.DefaultPathScriptGenerateForder);

            string[] fullPathFileNames = Directory.GetFiles(EditorPathManager.DefaultPathConfigGenerateForder, "*PathDefine.asset", SearchOption.AllDirectories);

            foreach (string fullPathFileName in fullPathFileNames)
            {
                Debug.Log(fullPathFileName);
                if (!fullPathFileName.EndsWith(".meta"))
                {
                    Debug.Log("gen: " + fullPathFileName);

                    PathConfig        config    = AssetDatabase.LoadAssetAtPath <PathConfig> (fullPathFileName);
                    PTNamespaceDefine nameSpace = new PTNamespaceDefine();
                    nameSpace.Name        = string.IsNullOrEmpty(config.NameSpace) ? "QFramework" : config.NameSpace;
                    nameSpace.FileName    = config.name + ".cs";
                    nameSpace.GenerateDir = string.IsNullOrEmpty(config.ScriptGeneratePath) ? EditorPathManager.DefaultPathScriptGenerateForder : IOExtension.CreateDirIfNotExists("Assets/" + config.ScriptGeneratePath);
                    var classDefine = new PTClassDefine();
                    classDefine.Comment = config.Description;
                    classDefine.Name    = config.name;
                    nameSpace.Classes.Add(classDefine);
                    Debug.Log(nameSpace.GenerateDir);
                    foreach (var pathItem in config.List)
                    {
                        if (!string.IsNullOrEmpty(pathItem.Name))
                        {
                            var variable = new PTVariable(PTAccessLimit.Private, PTCompileType.Const, PTTypeDefine.String, "m_" + pathItem.Name, pathItem.Path);
                            classDefine.Variables.Add(variable);

                            var property = new PTProperty(PTAccessLimit.Public, PTCompileType.Static, PTTypeDefine.String, pathItem.Name, pathItem.PropertyGetCode, pathItem.Description);
                            classDefine.Properties.Add(property);
                        }
                    }
                    PTCodeGenerator.Generate(nameSpace);

                    EditorUtility.SetDirty(config);
                    Resources.UnloadAsset(config);
                }
            }

            AssetDatabase.SaveAssets();
        }
        public static void ExtractTemplate(string packedTemplatePath)
        {
            if (!File.Exists(packedTemplatePath))
            {
                throw new Exception("<ERROR> Could not find packed template: " + packedTemplatePath + Environment.NewLine + "Try re-installing the toolkit ..." + Environment.NewLine);
            }

            var templateDir = Path.Combine(ExternalApps.TOOLKIT_ROOT, "Template");

            IOExtension.DeleteDirectory(templateDir);

            using (var packedTemplate = File.OpenRead(packedTemplatePath))
                using (var bz2 = new BZip2InputStream(packedTemplate))
                    using (var tar = TarArchive.CreateInputTarArchive(bz2))
                    {
                        tar.ExtractContents(ExternalApps.TOOLKIT_ROOT);
                    }
        }