コード例 #1
0
        private static bool GetDataiOSDirectory(DirectoryInfo rootDirectory, out string dataPath, out string appName)
        {
            dataPath = null;
            appName  = null;

            string        payloadPath      = Path.Combine(rootDirectory.FullName, PayloadName);
            DirectoryInfo payloadDirectory = new DirectoryInfo(payloadPath);

            if (!payloadDirectory.Exists)
            {
                return(false);
            }

            foreach (DirectoryInfo dinfo in payloadDirectory.EnumerateDirectories())
            {
                if (dinfo.Name.EndsWith(AppExtension, StringComparison.Ordinal))
                {
                    appName  = dinfo.Name.Substring(0, dinfo.Name.Length - AppExtension.Length);
                    dataPath = Path.Combine(dinfo.FullName, DataName);
                    if (DirectoryUtils.Exists(dataPath))
                    {
                        return(true);
                    }
                }
            }

            dataPath = null;
            appName  = null;
            return(false);
        }
コード例 #2
0
        public MixedGameStructure(FileCollection collection, IEnumerable <string> pathes) :
            base(collection)
        {
            Dictionary <string, string> files      = new Dictionary <string, string>();
            Dictionary <string, string> assemblies = new Dictionary <string, string>();
            HashSet <string>            dataPathes = new HashSet <string>();

            foreach (string path in pathes)
            {
                if (FileMultiStream.Exists(path))
                {
                    string name = FileMultiStream.GetFileName(path);
                    files.Add(name, path);
                    string directory = Path.GetDirectoryName(path);
                    dataPathes.Add(directory);
                }
                else if (DirectoryUtils.Exists(path))
                {
                    DirectoryInfo directory = new DirectoryInfo(DirectoryUtils.ToLongPath(path));
                    CollectFromDirectory(directory, files, assemblies, dataPathes);
                }
                else
                {
                    throw new Exception($"Neither file nor directory at '{path}' exists");
                }
            }

            DataPathes = dataPathes.ToArray();
            Files      = files;
            Assemblies = assemblies;
            SetScriptingBackend();
            Name = Files.First().Key;
        }
コード例 #3
0
        private static bool GetDataPCDirectory(DirectoryInfo rootDiectory, out string dataPath, out string name)
        {
            name = null;
            int exeCount = 0;

            foreach (FileInfo finfo in rootDiectory.EnumerateFiles())
            {
                if (finfo.Extension == ExeExtension)
                {
                    exeCount++;
                    name = Path.GetFileNameWithoutExtension(finfo.Name);
                    string dataFolder = $"{name}_{DataPostfix}";
                    dataPath = Path.Combine(rootDiectory.FullName, dataFolder);
                    if (DirectoryUtils.Exists(dataPath))
                    {
                        return(true);
                    }
                }
            }

            if (exeCount > 0)
            {
                name     = exeCount == 1 ? name : rootDiectory.Name;
                dataPath = Path.Combine(rootDiectory.FullName, DataPostfix);
                if (DirectoryUtils.Exists(dataPath))
                {
                    return(true);
                }
            }

            name     = null;
            dataPath = null;
            return(false);
        }
コード例 #4
0
        public AndroidGameStructure(FileCollection collection, string rootPath, string obbPath) :
            base(collection)
        {
            if (string.IsNullOrEmpty(rootPath))
            {
                throw new ArgumentNullException(rootPath);
            }
            m_root = new DirectoryInfo(DirectoryUtils.ToLongPath(rootPath));
            if (!m_root.Exists)
            {
                throw new Exception($"Root directory '{rootPath}' doesn't exist");
            }

            string        apkDataPath      = Path.Combine(rootPath, AssetName, BinName, DataName);
            DirectoryInfo apkDataDirectory = new DirectoryInfo(DirectoryUtils.ToLongPath(apkDataPath));

            if (!apkDataDirectory.Exists)
            {
                throw new Exception($"Data directory hasn't been found");
            }
            List <string> dataPathes = new List <string>()
            {
                apkDataPath
            };

            DirectoryInfo obbDataDirectory = null;

            if (obbPath != null)
            {
                m_obbRoot = new DirectoryInfo(DirectoryUtils.ToLongPath(obbPath));
                if (!m_obbRoot.Exists)
                {
                    throw new Exception($"Obb directory '{obbPath}' doesn't exist");
                }

                string obbDataPath = Path.Combine(obbPath, AssetName, BinName, DataName);
                if (!DirectoryUtils.Exists(obbDataPath))
                {
                    throw new Exception($"Obb data directory '{obbDataPath}' hasn't beed found");
                }
                dataPathes.Add(obbDataPath);
            }
            DataPathes = dataPathes.ToArray();

            Dictionary <string, string> files = new Dictionary <string, string>();

            CollectGameFiles(apkDataDirectory, files);
            if (obbDataDirectory != null)
            {
                CollectGameFiles(obbDataDirectory, files);
            }
            CollectApkAssetBundles(files);
            Files = files;

            Dictionary <string, string> assemblies = new Dictionary <string, string>();

            CollectMainAssemblies(apkDataDirectory, assemblies);
            Assemblies = assemblies;
            SetScriptingBackend();
        }
コード例 #5
0
        public static bool IsAndroidStructure(string path)
        {
            DirectoryInfo directory = new DirectoryInfo(DirectoryUtils.ToLongPath(path));

            if (!directory.Exists)
            {
                return(false);
            }

            int match = GetRootAndroidDirectoryMatch(directory);

            if (match <= 8)
            {
                return(false);
            }

            string dataPath = Path.Combine(path, AssetName, BinName, DataName);

            if (!DirectoryUtils.Exists(dataPath))
            {
                return(false);
            }

            return(true);
        }
コード例 #6
0
        public AndroidGameStructure(FileCollection collection, string rootPath, string obbPath) :
            base(collection)
        {
            if (string.IsNullOrEmpty(rootPath))
            {
                throw new ArgumentNullException(rootPath);
            }
            m_root = new DirectoryInfo(DirectoryUtils.ToLongPath(rootPath));
            if (!m_root.Exists)
            {
                throw new Exception($"Root directory '{rootPath}' doesn't exist");
            }

            m_dataPath = Path.Combine(rootPath, AssetName, BinName, DataName);
            if (!DirectoryUtils.Exists(m_dataPath))
            {
                throw new Exception($"Data directory hasn't beed found");
            }

            if (obbPath != null)
            {
                m_obbRoot = new DirectoryInfo(DirectoryUtils.ToLongPath(obbPath));
                if (!m_obbRoot.Exists)
                {
                    throw new Exception($"Obb directory '{obbPath}' doesn't exist");
                }

                m_obbDataPath = Path.Combine(obbPath, AssetName, BinName, DataName);
                if (!DirectoryUtils.Exists(m_obbDataPath))
                {
                    throw new Exception($"Obb data directory hasn't beed found");
                }
            }

            DirectoryInfo managedDirectory = new DirectoryInfo(DirectoryUtils.ToLongPath(ManagedPath));

            if (!managedDirectory.Exists)
            {
                throw new Exception($"Managed directory hasn't been found");
            }

            foreach (FileInfo assemblyFile in managedDirectory.EnumerateFiles())
            {
                if (AssemblyManager.IsAssembly(assemblyFile.Name))
                {
                    if (MonoManager.IsMonoAssembly(assemblyFile.Name))
                    {
                        m_fileCollection.AssemblyManager.ScriptingBackEnd = ScriptingBackEnd.Mono;
                    }
                    else
                    {
                        m_fileCollection.AssemblyManager.ScriptingBackEnd = ScriptingBackEnd.Il2Cpp;
                    }
                    break;
                }
            }
        }
コード例 #7
0
        private static string[] GetFiles(string dirPath, string fileName)
        {
            if (!DirectoryUtils.Exists(dirPath))
            {
                return(new string[0]);
            }

            string filePatern = fileName + ".split*";

            return(DirectoryUtils.GetFiles(dirPath, filePatern));
        }
コード例 #8
0
ファイル: Program.cs プロジェクト: frankkyoshiliu/UtinyRipper
        private static void PrepareExportDirectory(string path)
        {
#if !NET_CORE
            if (!RunetimeUtils.IsRunningOnMono)
            {
                string directory = Directory.GetCurrentDirectory();
                CheckWritePermission(directory);
            }
#endif

            if (DirectoryUtils.Exists(path))
            {
                DirectoryUtils.Delete(path, true);
            }
        }
コード例 #9
0
 private static string GetDataPCDirectory(DirectoryInfo rootDiectory)
 {
     foreach (FileInfo finfo in rootDiectory.EnumerateFiles())
     {
         if (finfo.Extension == ExeExtension)
         {
             string exeName       = Path.GetFileNameWithoutExtension(finfo.Name);
             string dataFolder    = $"{exeName}_{DataPostfix}";
             string dataDirectory = Path.Combine(rootDiectory.FullName, dataFolder);
             if (DirectoryUtils.Exists(dataDirectory))
             {
                 return(dataDirectory);
             }
         }
     }
     return(null);
 }
コード例 #10
0
 public void AddFiles(IEnumerable <string> pathes)
 {
     foreach (string path in pathes)
     {
         if (FileMultiStream.Exists(path))
         {
             AddFile(path);
         }
         else if (DirectoryUtils.Exists(path))
         {
             DirectoryInfo directory = new DirectoryInfo(DirectoryUtils.ToLongPath(path));
             AddDirectory(directory);
         }
         else
         {
             throw new Exception($"Neither file nor directory with path '{path}' exists");
         }
     }
 }
コード例 #11
0
 protected static string GetPresentDirectoryName(string rootPath, string directoryName)
 {
     if (RunetimeUtils.IsRunningOnMono)
     {
         if (DirectoryUtils.Exists(rootPath))
         {
             directoryName = Path.GetFileName(directoryName).ToLowerInvariant();
             DirectoryInfo root = new DirectoryInfo(DirectoryUtils.ToLongPath(rootPath));
             foreach (DirectoryInfo directory in root.EnumerateDirectories())
             {
                 if (directory.Name.ToLowerInvariant() == directoryName)
                 {
                     return(directory.Name);
                 }
             }
         }
     }
     return(directoryName);
 }
コード例 #12
0
 protected static string GetPresentFileName(string rootPath, string fileName)
 {
     if (RunetimeUtils.IsRunningOnMono)
     {
         if (DirectoryUtils.Exists(rootPath))
         {
             fileName = Path.GetFileName(fileName).ToLowerInvariant();
             DirectoryInfo root = new DirectoryInfo(DirectoryUtils.ToLongPath(rootPath));
             foreach (FileInfo file in root.EnumerateFiles())
             {
                 if (file.Name.ToLowerInvariant() == fileName)
                 {
                     return(file.Name);
                 }
             }
         }
     }
     return(fileName);
 }
コード例 #13
0
        private static bool GetDataLinuxDirectory(DirectoryInfo rootDiectory, out string dataPath, out string name)
        {
            foreach (FileInfo finfo in rootDiectory.EnumerateFiles())
            {
                if (finfo.Extension == x86Extension || finfo.Extension == x64Extension)
                {
                    name = Path.GetFileNameWithoutExtension(finfo.Name);
                    string dataFolder = $"{name}_{DataPostfix}";
                    dataPath = Path.Combine(rootDiectory.FullName, dataFolder);
                    if (DirectoryUtils.Exists(dataPath))
                    {
                        return(true);
                    }
                }
            }

            name     = null;
            dataPath = null;
            return(false);
        }
コード例 #14
0
ファイル: Program.cs プロジェクト: frankkyoshiliu/UtinyRipper
        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();
        }