예제 #1
0
        Response ProcessTask(string fileName, string folderName, ProcessFileDelegate handler)
        {
            var processor = new CustomSingleOrZipFileProcessor()
            {
                CustomProcessMethod = handler
            };

            Aspose.App.Live.Demos.UI.Models.License.SetAsposeEmailLicense();
            Aspose.App.Live.Demos.UI.Models.License.SetAsposeWordsLicense();             // for email to image conversion

            return(processor.Process(folderName, fileName));
        }
예제 #2
0
        public static void ForEachFile(string gameDirectoryName, ProcessFileDelegate processDelegate)
        {
            var archiveFileNames = Directory.GetFiles(gameDirectoryName, "*.rpf", SearchOption.AllDirectories);

            for (int i = 0; i < archiveFileNames.Length; i++)
            {
                var fileName     = archiveFileNames[i];
                var fileInfo     = new FileInfo(fileName);
                var fileStream   = new FileStream(fileName, FileMode.Open);
                var inputArchive = RageArchiveWrapper7.Open(fileStream, fileInfo.Name);
                ForEachFile(fileName.Replace(gameDirectoryName, ""), inputArchive.Root, inputArchive.archive_.Encryption, processDelegate);
                inputArchive.Dispose();
            }
        }
예제 #3
0
        public static void ForEachFile(string gameDirectoryName, ProcessFileDelegate processDelegate, ErrorDelegate errorDelegate = null)
        {
            var archiveFileNames = Directory.GetFiles(gameDirectoryName, "*.rpf", SearchOption.AllDirectories);

            for (int i = 0; i < archiveFileNames.Length; i++)
            {
                try
                {
                    var fileName     = archiveFileNames[i];
                    var inputArchive = RageArchiveWrapper7.Open(fileName);
                    ForEachFile(fileName.Replace(gameDirectoryName, ""), inputArchive.Root, inputArchive.archive_.Encryption, processDelegate);
                    inputArchive.Dispose();
                }
                catch (Exception e)
                {
                    errorDelegate?.Invoke(e);
                }
            }
        }
 public static void ProcessAssetFile(string filename, string assetPath, string originalName, string replacementName,
                                     ProcessFileDelegate processFileHandler, ProcessSceneDelegate processSceneHandler, ProcessPrefabDelegate processPrefabHandler)
 {
     try
     {
         processFileHandler(filename, assetPath, originalName, replacementName, processSceneHandler, processPrefabHandler);
     }
     catch (System.Exception e)
     {
         if (assetPath.Contains("NavMesh"))
         {
             report += "Did not process " + filename + " but it appears to be a NavMesh so this should be fine. Result: " + e.Message + "\n";
         }
         else if (assetPath.Contains("Terrain"))
         {
             report += "Did not process " + filename + " but it appears to be a Terrain so this should be fine. Result: " + e.Message + "\n";
         }
         else
         {
             report += "Unable to process " + filename + ": " + e.Message + "\n";
         }
     }
 }
        public static void ProcessAssets(string title, string originalName, string replacementName,
                                         ProcessFileDelegate processFileHandler, ProcessSceneDelegate processSceneHandler, ProcessPrefabDelegate processPrefabHandler)
        {
            AssetDatabase.SaveAssets();
            var cancel = false;

            // Save open scenes:
            if (!UnityEditor.SceneManagement.EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
            {
                report += "Cancelled.\n";
                return;
            }

            if (!string.IsNullOrEmpty(replacementName))
            {
                // Close open assets:
                if (Selection.activeObject is DialogueDatabase || Selection.activeObject is LocalizedTextTable)
                {
                    Selection.activeObject = null;
                }
                if (DialogueEditor.DialogueEditorWindow.instance != null)
                {
                    DialogueEditor.DialogueEditorWindow.instance.Close();
                }
            }

            if (!string.IsNullOrEmpty(ignoreFilesRegex))
            {
                report += "Ignoring files matching: " + ignoreFilesRegex + "\n";
            }

            // Record serialization mode and force text:
            var originalSerializationMode = EditorSettings.serializationMode;

            if (EditorSettings.serializationMode != SerializationMode.ForceText)
            {
                cancel  = EditorUtility.DisplayCancelableProgressBar("Text Serialization Required", "Switching to Force Text serialization mode. This may take a while.", 0);
                report += "Set serialization mode to Force Text.\n";
                EditorSettings.serializationMode = SerializationMode.ForceText;
                if (cancel)
                {
                    report += "Update process cancelled. Serialization mode is set to Force Text. To set it back to " + originalSerializationMode + " use menu item Edit > Project Settings > Editor.\n";
                    return;
                }
            }

            // Force visible meta files:
            var originalExternalVersionControl = versionControlMode;

            if (!versionControlMode.Equals(ExternalVersionControlVisibleMetaFiles))
            {
                cancel             = EditorUtility.DisplayCancelableProgressBar("Visible Meta Files Required", "Switching Version Control Mode to Visible Meta Files. This may take a while.", 0);
                report            += "Set version control mode to Visible Meta Files.\n";
                versionControlMode = ExternalVersionControlVisibleMetaFiles;
                if (cancel)
                {
                    report += "Update process cancelled. Serialization mode is " + EditorSettings.serializationMode + " and Version Control Mode is " +
                              versionControlMode + ". To change these settings, use menu item Edit > Project Settings > Editor.\n";
                    return;
                }
            }

            // Record currently open scene:
            var originalScenePath = EditorSceneManager.GetActiveScene().path;

            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();

            var isWindows = Application.platform == RuntimePlatform.WindowsEditor;

            try
            {
                // Update all scene, scriptable object, and prefab files:
                var files = Directory.GetFiles(Application.dataPath, "*.*", SearchOption.AllDirectories)
                            .Where(s => s.EndsWith(".unity") || s.EndsWith(".asset") || s.EndsWith(".prefab")).ToArray();
                for (int i = 0; i < files.Length; i++)
                {
                    var filename  = files[i];
                    var assetPath = filename;
                    if (isWindows)
                    {
                        assetPath = assetPath.Replace("\\", "/");
                    }
                    assetPath = "Assets" + assetPath.Substring(Application.dataPath.Length);
                    if (Regex.IsMatch(assetPath, ignoreFilesRegex))
                    {
                        continue;                                             // Ignore this file.
                    }
                    cancel = EditorUtility.DisplayCancelableProgressBar(title, filename, (float)i / (float)files.Length);
                    ProcessAssetFile(filename, assetPath, originalName, replacementName, processFileHandler, processSceneHandler, processPrefabHandler);
                    if (cancel)
                    {
                        if (EditorSettings.serializationMode != originalSerializationMode)
                        {
                            report += "Update process cancelled. Serialization mode is set to Force Text. To set it back to " + originalSerializationMode + " use menu item Edit > Project Settings > Editor.\n";
                        }
                        return;
                    }
                }
            }
            catch (Exception e)
            {
                report += e.Message + "\n";
                Debug.LogException(e);
            }
            finally
            {
                EditorUtility.ClearProgressBar();
                AssetDatabase.Refresh();

                if (!cancel)
                {
                    // Restore original serialization mode:
                    if (originalSerializationMode != SerializationMode.ForceText)
                    {
                        EditorUtility.DisplayProgressBar(title, "Restoring original serialization mode. This may take a while.", 0.99f);
                        report += "Set serialization mode to " + originalSerializationMode + "\n.";
                        EditorSettings.serializationMode = originalSerializationMode;
                    }
                    // Restore original version control mode:
                    if (originalExternalVersionControl != ExternalVersionControlVisibleMetaFiles)
                    {
                        EditorUtility.DisplayProgressBar(title, "Restoring original version control mode. This may take a while.", 0.995f);
                        report            += "Set version control mode to " + originalExternalVersionControl + ".\n";
                        versionControlMode = originalExternalVersionControl;
                    }
                }

                // Return to original scene:
                if (!string.IsNullOrEmpty(originalScenePath) && EditorSceneManager.GetActiveScene().path != originalScenePath)
                {
                    EditorSceneManager.OpenScene(originalScenePath);
                }
            }
        }
예제 #6
0
        static void ProcessData(Stream romStream, ProcessFileDelegate processFileData)
        {
            if (romStream == null)
            {
                throw new ArgumentNullException(nameof(romStream));
            }

            using (BinaryReader br = new BinaryReader(romStream, Encoding.UTF8, true))
            {
                Info rom = GetInfo(romStream);

                // Start reading the ROM data

                romStream.Seek(rom.dataStartPosition, SeekOrigin.Begin);

                uint   fileCount    = Utils.SwapU32(br.ReadUInt32());
                uint[] filePointers = new uint[fileCount];

                for (int f = 0; f < fileCount; f++)
                {
                    filePointers[f] = Utils.SwapU32(br.ReadUInt32());
                }

                for (int f = 0; f < fileCount; f++)
                {
                    uint filePosition = rom.dataStartPosition + filePointers[f];
                    romStream.Seek(filePosition, SeekOrigin.Begin);

                    uint   subFileCount    = Utils.SwapU32(br.ReadUInt32());
                    uint[] subFilePointers = new uint[subFileCount];

                    for (int sf = 0; sf < subFileCount; sf++)
                    {
                        subFilePointers[sf] = Utils.SwapU32(br.ReadUInt32());
                    }

                    for (int sf = 0; sf < subFileCount; sf++)
                    {
                        uint subFilePosition = filePosition + subFilePointers[sf];

                        uint subFileLength;

                        if (sf < subFileCount - 1)
                        {
                            subFileLength = subFilePointers[sf + 1] - subFilePointers[sf];
                        }
                        else
                        {
                            if (f < fileCount - 1)
                            {
                                subFileLength = (rom.dataStartPosition + filePointers[f + 1]) - subFilePosition;
                            }
                            else
                            {
                                subFileLength = rom.dataEndPosition - subFilePosition;
                            }
                        }

                        romStream.Seek(subFilePosition, SeekOrigin.Begin);
                        byte[] data = new byte[subFileLength];
                        romStream.Read(data, 0, data.Length);

                        processFileData?.Invoke(rom.dataStartPosition, filePointers[f], subFilePointers[sf], data);
                    }
                }
            }
        }
 public FileMonitor(IProfile profile, string watchfolder, string filterpattern, ProcessFileDelegate processor) : base(profile, watchfolder, filterpattern) {
     this.processor = processor;
 }
 public FileMonitor(IProfile profile, string watchfolder, string filterpattern, ProcessFileDelegate processor) : base(profile, watchfolder, filterpattern)
 {
     this.processor = processor;
 }
예제 #9
0
 private static void ForEachFile(string fullPathName, IArchiveDirectory directory, RageArchiveEncryption7 encryption, ProcessFileDelegate processDelegate)
 {
     foreach (var file in directory.GetFiles())
     {
         processDelegate(fullPathName + "\\" + file.Name, file, encryption);
         if ((file is IArchiveBinaryFile) && file.Name.EndsWith(".rpf", StringComparison.OrdinalIgnoreCase))
         {
             var fileStream   = ((IArchiveBinaryFile)file).GetStream();
             var inputArchive = RageArchiveWrapper7.Open(fileStream, file.Name);
             ForEachFile(fullPathName + "\\" + file.Name, inputArchive.Root, inputArchive.archive_.Encryption, processDelegate);
         }
     }
     foreach (var subDirectory in directory.GetDirectories())
     {
         ForEachFile(fullPathName + "\\" + subDirectory.Name, subDirectory, encryption, processDelegate);
     }
 }
예제 #10
0
파일: FileManager.cs 프로젝트: Dahx/bns.spo
        static void GetFiles(string sourceDir, string parent, MigrationSettigs d, LogCsvFile log, ProcessFileDelegate FileHandler)
        {
            string[] fileEntries = TryGetDirFiles(sourceDir, log);
            foreach (string x in fileEntries)
            {
                FileHandler(parent, x, d, log);
            }

            string[] subdirEntries = TryGetSubDirs(sourceDir, log);
            foreach (string subdir in subdirEntries)
            {
                GetFiles(subdir, parent, d, log, FileHandler);
            }
        }
예제 #11
0
파일: FileManager.cs 프로젝트: Dahx/bns.spo
        public static void GetFiles(string masterfile_path, string doTransit, string from_date, ProcessFileDelegate FileHandler, string report_name)
        {
            MigrationSettigs d   = Init(doTransit, from_date);
            LogCsvFile       log = new LogCsvFile("", report_name);

            string[] lines = System.IO.File.ReadAllLines(masterfile_path);

            foreach (string idpair in lines)
            {
                string[] values = idpair.Split(new char[] { ',' });
                string   id     = values[0];

                string folderPath       = string.Format(d.SearchPattern, id);
                string parentFolderName = folderPath.Substring(folderPath.LastIndexOf("\\") + 1);

                log.WriteInfo("processing " + parentFolderName + "...");
                GetFiles(folderPath, parentFolderName, d, log, FileHandler);
                log.WriteInfo("done...");
            }
        }