private static bool TryLoadDependency(AssetCollection collection, IEnumerable <string> directories, string originalName, string loadName) { foreach (string dirPath in directories) { string path = Path.Combine(dirPath, loadName); try { if (FileMultiStream.Exists(path)) { using (Stream stream = FileMultiStream.OpenRead(path)) { collection.Read(stream, path, originalName); } Logger.Instance.Log(LogType.Info, LogCategory.Import, $"Dependency '{path}' was loaded"); return(true); } } catch (Exception ex) { Logger.Instance.Log(LogType.Error, LogCategory.Import, $"Can't parse dependency file {path}"); Logger.Instance.Log(LogType.Error, LogCategory.Debug, ex.ToString()); } } return(false); }
// ===================================================== // Methods // ===================================================== private bool ProcessInputFiles(string[] files) { if (files.Length == 0) { return(false); } foreach (string file in files) { if (FileMultiStream.Exists(file)) { continue; } if (DirectoryUtils.Exists(file)) { continue; } Logger.Log(LogType.Warning, LogCategory.General, FileMultiStream.IsMultiFile(file) ? $"File '{file}' doesn't has all parts for combining" : $"Neither file nor directory with path '{file}' exists"); return(false); } IntroText.Text = "Loading files..."; MainGrid.AllowDrop = false; m_processingFiles = files; ThreadPool.QueueUserWorkItem(new WaitCallback(LoadFiles), files); return(true); }
// ===================================================== // Callbacks // ===================================================== private void OnDataDroped(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(DataFormats.FileDrop)) { string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); foreach (string file in files) { if (FileMultiStream.Exists(file)) { continue; } if (DirectoryUtils.Exists(file)) { continue; } Logger.Instance.Log(LogType.Warning, LogCategory.General, FileMultiStream.IsMultiFile(file) ? $"File '{file}' doesn't has all parts for combining" : $"Neither file nor directory with path '{file}' exists"); return; } ThreadPool.QueueUserWorkItem(new WaitCallback(LoadFiles), files); IntroText.Text = "Loading files..."; MainGrid.AllowDrop = false; e.Handled = true; } }
public static SerializedFileScheme LoadScheme(string filePath, string fileName, TransferInstructionFlags flags) { if (!FileMultiStream.Exists(filePath)) { throw new Exception($"Serialized file at path '{filePath}' doesn't exist"); } using (SmartStream fileStream = SmartStream.OpenRead(filePath)) { return(ReadScheme(fileStream, 0, fileStream.Length, filePath, fileName, flags)); } }
public static bool IsBundleFile(string bundlePath) { if (!FileMultiStream.Exists(bundlePath)) { throw new Exception($"Bundle at path '{bundlePath}' doesn't exist"); } using (Stream stream = FileMultiStream.OpenRead(bundlePath)) { return(IsBundleFile(stream)); } }
public static bool IsWebFile(string webPath) { if (!FileMultiStream.Exists(webPath)) { throw new Exception($"Web at path '{webPath}' doesn't exist"); } using (Stream stream = FileMultiStream.OpenRead(webPath)) { return(IsWebFile(stream)); } }
public static bool IsSerializedFile(string filePath) { if (!FileMultiStream.Exists(filePath)) { throw new Exception($"Serialized file at '{filePath}' doesn't exist"); } using (Stream stream = FileMultiStream.OpenRead(filePath)) { return(IsSerializedFile(stream)); } }
public static void Main(string[] args) { Logger.Instance = ConsoleLogger.Instance; Config.IsAdvancedLog = true; Config.IsGenerateGUIDByContent = false; Config.IsExportDependencies = false; if (args.Length == 0) { Console.WriteLine("No arguments"); Console.ReadKey(); return; } foreach (string arg in args) { if (!FileMultiStream.Exists(arg)) { Console.WriteLine(FileMultiStream.IsMultiFile(arg) ? $"File {arg} doen't has all parts for combining" : $"File {arg} doesn't exist", arg); Console.ReadKey(); return; } } try { AssetCollection collection = new AssetCollection(); collection.Exporter.OverrideExporter(ClassIDType.AudioClip, new AudioAssetExporter()); LoadFiles(collection, args); LoadDependencies(collection, args); ValidateCollection(collection); string name = Path.GetFileNameWithoutExtension(args.First()); string exportPath = ".\\Ripped\\" + name; if (Directory.Exists(exportPath)) { Directory.Delete(exportPath, true); } collection.Exporter.Export(exportPath, FetchExportObjects(collection)); Logger.Instance.Log(LogType.Info, LogCategory.General, "Finished"); } catch (Exception ex) { Logger.Instance.Log(LogType.Error, LogCategory.General, ex.ToString()); } Console.ReadKey(); }
public void Load(string assetPath, Action <string> requestDependencyCallback) { if (!FileMultiStream.Exists(assetPath)) { throw new Exception($"Asset at path '{assetPath}' doesn't exist"); } using (Stream stream = FileMultiStream.OpenRead(assetPath)) { Read(stream, requestDependencyCallback); if (stream.Position != stream.Length) { //throw new Exception($"Read {read} but expected {m_length}"); } } }
private void Load(Action <string> dependencyCallback) { if (!FileMultiStream.Exists(FilePath)) { throw new Exception($"Serialized file at path '{FilePath}' doesn't exist"); } using (Stream stream = FileMultiStream.OpenRead(FilePath)) { Read(stream, dependencyCallback); if (stream.Position != stream.Length) { //throw new Exception($"Read {read} but expected {m_length}"); } } }
private static void LoadFiles(AssetCollection collection, IEnumerable <string> filePathes) { List <string> processed = new List <string>(); foreach (string path in filePathes) { string filePath = FileMultiStream.GetFilePath(path); if (processed.Contains(filePath)) { continue; } string fileName = FileMultiStream.GetFileName(path); using (Stream stream = FileMultiStream.OpenRead(path)) { collection.Read(stream, filePath, fileName); } processed.Add(filePath); } }
public static void Main(string[] args) { Logger.Instance = ConsoleLogger.Instance; Config.IsAdvancedLog = true; Config.IsGenerateGUIDByContent = false; Config.IsExportDependencies = false; if (args.Length == 0) { Console.WriteLine("No arguments"); Console.ReadKey(); return; } foreach (string arg in args) { if (FileMultiStream.Exists(arg)) { continue; } if (DirectoryUtils.Exists(arg)) { continue; } Console.WriteLine(FileMultiStream.IsMultiFile(arg) ? $"File '{arg}' doesn't has all parts for combining" : $"Neither file nor directory with path '{arg}' exists"); Console.ReadKey(); return; } Program program = new Program(); program.Load(args); Console.ReadKey(); }
public void rip(string[] args, string targetDir) { Logger.Instance = PythonLogger.Instance; Config.IsAdvancedLog = true; Config.IsGenerateGUIDByContent = false; Config.IsExportDependencies = true; if (args.Length == 0) { Console.WriteLine("No arguments"); return; } foreach (string arg in args) { if (FileMultiStream.Exists(arg)) { continue; } if (DirectoryUtils.Exists(arg)) { continue; } Console.WriteLine(FileMultiStream.IsMultiFile(arg) ? $"File '{arg}' doesn't has all parts for combining" : $"Neither file nor directory with path '{arg}' exists"); return; } try { GameStructure = GameStructure.Load(args); Validate(); // MRH - can make this an option to include/exclude. Including will transcode, e.g. fsb (FSB5) into wav GameStructure.FileCollection.Exporter.OverrideExporter(ClassIDType.AudioClip, new AudioAssetExporter()); /* MRH - borrowing from the GUI... there seems to be much more work there than in the CLI * uTinyRipperGUI.Exporters.TextureAssetExporter textureExporter = new uTinyRipperGUI.Exporters.TextureAssetExporter(); * GameStructure.FileCollection.Exporter.OverrideExporter(ClassIDType.Texture2D, textureExporter); * GameStructure.FileCollection.Exporter.OverrideExporter(ClassIDType.Cubemap, textureExporter); * GameStructure.FileCollection.Exporter.OverrideExporter(ClassIDType.Sprite, textureExporter); * GameStructure.FileCollection.Exporter.OverrideExporter(ClassIDType.Shader, new uTinyRipperGUI.Exporters.ShaderAssetExporter()); * GameStructure.FileCollection.Exporter.OverrideExporter(ClassIDType.TextAsset, new TextAssetExporter()); * GameStructure.FileCollection.Exporter.OverrideExporter(ClassIDType.Font, new FontAssetExporter()); * GameStructure.FileCollection.Exporter.OverrideExporter(ClassIDType.MovieTexture, new MovieTextureAssetExporter()); * * EngineAssetExporter engineExporter = new EngineAssetExporter(); * GameStructure.FileCollection.Exporter.OverrideExporter(ClassIDType.Material, engineExporter); * GameStructure.FileCollection.Exporter.OverrideExporter(ClassIDType.Texture2D, engineExporter); * GameStructure.FileCollection.Exporter.OverrideExporter(ClassIDType.Mesh, engineExporter); * GameStructure.FileCollection.Exporter.OverrideExporter(ClassIDType.Shader, engineExporter); * GameStructure.FileCollection.Exporter.OverrideExporter(ClassIDType.Font, engineExporter); * GameStructure.FileCollection.Exporter.OverrideExporter(ClassIDType.Sprite, engineExporter); * GameStructure.FileCollection.Exporter.OverrideExporter(ClassIDType.MonoBehaviour, engineExporter); * * PrepareExportDirectory(targetDir); */ GameStructure.Export(targetDir, AssetSelector); Logger.Log(LogType.Info, LogCategory.General, "Finished"); } catch (Exception ex) { Logger.Log(LogType.Error, LogCategory.General, ex.ToString()); } }