Пример #1
0
        public void Load(IEnumerable <string> pathes)
        {
            List <string> toProcess = new List <string>();

            toProcess.AddRange(pathes);
            if (CheckPC(toProcess))
            {
            }
            else if (CheckAndroid(toProcess))
            {
            }
            CheckMixed(toProcess);

            if (PlatformStructure != null)
            {
                foreach (string filePath in PlatformStructure.FetchFiles())
                {
                    string fileName = FileMultiStream.GetFileName(filePath);
                    if (m_knownFiles.Add(fileName))
                    {
                        FileCollection.Load(filePath);
                    }
                }
            }
            foreach (string filePath in MixedStructure.FetchFiles())
            {
                string fileName = FileMultiStream.GetFileName(filePath);
                if (m_knownFiles.Add(fileName))
                {
                    FileCollection.Load(filePath);
                }
            }
        }
Пример #2
0
        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");
                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);
                    return;
                }
            }

            Program program = new Program();

            program.Load(args);
            Console.ReadKey();
        }
Пример #3
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;
        }
Пример #4
0
        private static bool TryLoadDependency(AssetCollection collection, IEnumerable <string> directories, string originalName, string loadName)
        {
            foreach (string dirPath in directories)
            {
                string path = Path.Combine(dirPath, loadName);
#if !DEBUG_PROGRAM
                try
#endif
                {
                    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);
                    }
                }
#if !DEBUG_PROGRAM
                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());
                }
#endif
            }
            return(false);
        }
        protected void CollectGameFiles(DirectoryInfo root, IDictionary <string, string> files)
        {
            string filePath = Path.Combine(root.FullName, GlobalGameManagerName);

            if (FileMultiStream.Exists(filePath))
            {
                AddFile(files, GlobalGameManagerName, filePath);
            }
            else
            {
                filePath = Path.Combine(root.FullName, MainDataName);
                if (FileMultiStream.Exists(filePath))
                {
                    AddFile(files, MainDataName, filePath);
                }
            }

            foreach (FileInfo levelFile in root.EnumerateFiles())
            {
                string levelName = FileMultiStream.GetFileName(levelFile.Name);
                if (s_levelName.IsMatch(levelName))
                {
                    AddFile(files, levelName, levelFile.FullName);
                }
            }
        }
Пример #6
0
 private void LoadFiles(IEnumerable <string> filePathes)
 {
     foreach (string filePath in filePathes)
     {
         string fileName = FileMultiStream.GetFileName(filePath);
         LoadFile(filePath, fileName);
     }
 }
Пример #7
0
        private void AddFile(string path)
        {
            string name = FileMultiStream.GetFileName(path);

            m_files.Add(name, path);
            string directory = Path.GetDirectoryName(path);

            m_knownDirectories.Add(directory);
        }
Пример #8
0
 private void LoadFile(string fullFilePath, string originalFileName)
 {
     if (m_knownFiles.Add(originalFileName))
     {
         string filePath = FileMultiStream.GetFilePath(fullFilePath);
         using (Stream stream = FileMultiStream.OpenRead(filePath))
         {
             m_collection.Read(stream, filePath, originalFileName);
         }
     }
 }
Пример #9
0
        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;
                }
            }

#if !DEBUG_PROGRAM
            try
#endif
            {
                AssetCollection collection = new AssetCollection();
                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");
            }
#if !DEBUG_PROGRAM
            catch (Exception ex)
            {
                Logger.Instance.Log(LogType.Error, LogCategory.General, ex.ToString());
            }
#endif
            Console.ReadKey();
        }
Пример #10
0
 public bool RequestResource(string resource, out string path)
 {
     foreach (string dataPath in DataPathes)
     {
         path = Path.Combine(dataPath, resource);
         if (FileMultiStream.Exists(path))
         {
             return(true);
         }
     }
     path = null;
     return(false);
 }
Пример #11
0
 private bool TryLoadDependency(string loadName, string originalName)
 {
     foreach (string dirPath in m_knownDirectories)
     {
         string path = Path.Combine(dirPath, loadName);
         if (FileMultiStream.Exists(path))
         {
             LoadFile(path, originalName);
             Logger.Instance.Log(LogType.Info, LogCategory.Import, $"Dependency '{path}' was loaded");
             return(true);
         }
     }
     return(false);
 }
        private void AddDirectory(DirectoryInfo directory)
        {
            foreach (FileInfo file in directory.EnumerateFiles())
            {
                if (FileMultiStream.IsNameEquals(file.Name, MainDataName))
                {
                    AddFile(file.FullName);
                    Logger.Log(LogType.Info, LogCategory.Import, $"'{MainDataName}' has been found at '{directory.FullName}'");
                }
                else if (FileMultiStream.IsNameEquals(file.Name, GlobalGameManagerName))
                {
                    AddFile(file.FullName);
                    Logger.Log(LogType.Info, LogCategory.Import, $"'{GlobalGameManagerName}' has been found at '{directory.FullName}'");
                }
                else if (m_levelName.IsMatch(file.Name))
                {
                    AddFile(file.FullName);
                    Logger.Log(LogType.Info, LogCategory.Import, $"'{file.Name}' has been found at '{directory.FullName}'");
                }
                else if (file.Extension == AssetBundleExtension)
                {
                    string onlyName = Path.GetFileNameWithoutExtension(file.Name);
                    m_files.Add(onlyName, file.FullName);
                    Logger.Log(LogType.Info, LogCategory.Import, $"Asset bundle '{onlyName}' has been found at '{directory.FullName}'");
                }
                else if (AssemblyManager.IsAssembly(file.Name))
                {
                    if (MonoManager.IsMonoAssembly(file.Name))
                    {
                        m_fileCollection.AssemblyManager.ScriptingBackEnd = ScriptingBackEnd.Mono;
                    }
                    else
                    {
                        throw new NotImplementedException();
                    }

                    m_assemblies.Add(file.FullName);
                    Logger.Log(LogType.Info, LogCategory.Import, $"Assembly '{file.Name}' has been found at '{directory.FullName}'");
                }
            }

            foreach (DirectoryInfo subDirectory in directory.EnumerateDirectories())
            {
                AddDirectory(subDirectory);
            }
        }
Пример #13
0
        public ResourcesFile FindResourcesFile(ISerializedFile ifile, string fileName)
        {
            SerializedFile file = (SerializedFile)ifile;

            const string archivePrefix = "archive:/";

            if (fileName.StartsWith(archivePrefix))
            {
                fileName = Path.GetFileName(fileName);
            }

            // check assets bundles / web files
            string filePath = file.FilePath;

            foreach (ResourcesFile res in m_resources)
            {
                if (res.FilePath == filePath && res.Name == fileName)
                {
                    return(res);
                }
            }

            // check manualy loaded resource files
            string dirPath = Path.GetDirectoryName(filePath) ?? string.Empty;
            string resPath = Path.Combine(dirPath, fileName);

            foreach (ResourcesFile res in m_resources)
            {
                if (res.FilePath == resPath && res.Name == fileName)
                {
                    return(res);
                }
            }

            // lazy loading
            if (FileMultiStream.Exists(resPath))
            {
                Stream        stream    = FileMultiStream.OpenRead(resPath);
                ResourcesFile resesFile = new ResourcesFile(resPath, fileName, stream);
                m_resources.Add(resesFile);
                return(resesFile);
            }
            return(null);
        }
Пример #14
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");
         }
     }
 }
Пример #15
0
        public bool RequestDependency(string dependency)
        {
            if (Files.TryGetValue(dependency, out string dependencyPath))
            {
                LoadDependency(dependency, dependencyPath);
                return(true);
            }

            foreach (string dataPath in DataPathes)
            {
                string filePath = Path.Combine(dataPath, dependency);
                if (FileMultiStream.Exists(filePath))
                {
                    LoadDependency(dependency, filePath);
                    return(true);
                }

                if (FilenameUtils.IsDefaultResource(dependency))
                {
                    if (LoadEngineDependency(dataPath, FilenameUtils.DefaultResourceName1))
                    {
                        return(true);
                    }
                    if (LoadEngineDependency(dataPath, FilenameUtils.DefaultResourceName2))
                    {
                        return(true);
                    }
                }
                else if (FilenameUtils.IsBuiltinExtra(dependency))
                {
                    if (LoadEngineDependency(dataPath, FilenameUtils.BuiltinExtraName1))
                    {
                        return(true);
                    }
                    if (LoadEngineDependency(dataPath, FilenameUtils.BuiltinExtraName2))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Пример #16
0
        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 virtual bool RequestDependency(string dependency)
        {
            foreach (string dataPath in DataPathes)
            {
                string filePath = Path.Combine(dataPath, dependency);
                if (FileMultiStream.Exists(filePath))
                {
                    m_fileCollection.Load(filePath);
                    return(true);
                }

                if (dependency.StartsWith(LibraryFolder, StringComparison.Ordinal))
                {
                    dependency = dependency.Substring(LibraryFolder.Length + 1);
                }
                if (IsDefaultResource(dependency))
                {
                    if (LoadEngineDependency(dataPath, DefaultResourceName1, dependency))
                    {
                        return(true);
                    }
                    if (LoadEngineDependency(dataPath, DefaultResourceName2, dependency))
                    {
                        return(true);
                    }
                }
                else if (IsBuiltinExtra(dependency))
                {
                    if (LoadEngineDependency(dataPath, BuiltinExtraName1, dependency))
                    {
                        return(true);
                    }
                    if (LoadEngineDependency(dataPath, BuiltinExtraName2, dependency))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
        public virtual IEnumerable <string> FetchFiles()
        {
            string filePath = Path.Combine(MainDataPath, MainDataName);

            if (FileMultiStream.Exists(filePath))
            {
                yield return(filePath);
            }

            filePath = Path.Combine(MainDataPath, GlobalGameManagerName);
            if (FileMultiStream.Exists(filePath))
            {
                yield return(filePath);
            }

            foreach (string dataPath in DataPathes)
            {
                DirectoryInfo dataDirectory = new DirectoryInfo(DirectoryUtils.ToLongPath(dataPath));
                foreach (FileInfo levelFile in dataDirectory.EnumerateFiles())
                {
                    if (m_levelName.IsMatch(levelFile.Name))
                    {
                        yield return(levelFile.FullName);
                    }
                }

                string        streamingPath      = Path.Combine(dataPath, StreamingName);
                DirectoryInfo streamingDirectory = new DirectoryInfo(DirectoryUtils.ToLongPath(streamingPath));
                if (streamingDirectory.Exists)
                {
                    foreach (string path in FetchAssetBundles(streamingDirectory))
                    {
                        yield return(path);
                    }
                }
            }
        }
Пример #19
0
        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();
        }