예제 #1
0
        protected void CollectGameFiles(DirectoryInfo root, IDictionary <string, string> files)
        {
            const string DataBundleName = DataName + AssetBundleExtension;
            string       dataBundlePath = Path.Combine(root.FullName, DataBundleName);

            if (MultiFileStream.Exists(dataBundlePath))
            {
                AddAssetBundle(files, DataBundleName, dataBundlePath);
            }

            string filePath = Path.Combine(root.FullName, GlobalGameManagerName);

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

            foreach (FileInfo levelFile in root.EnumerateFiles())
            {
                if (s_levelTemplate.IsMatch(levelFile.Name))
                {
                    string levelName = MultiFileStream.GetFileName(levelFile.Name);
                    AddFile(files, levelName, levelFile.FullName);
                }
            }
        }
예제 #2
0
 public static bool IsSerializedFile(string filePath)
 {
     using (Stream stream = MultiFileStream.OpenRead(filePath))
     {
         return(IsSerializedFile(stream));
     }
 }
예제 #3
0
        public string RequestDependency(string dependency)
        {
            if (Files.TryGetValue(dependency, out string dependencyPath))
            {
                return(dependencyPath);
            }

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

                if (FilenameUtils.IsDefaultResource(dependency))
                {
                    return(FindEngineDependency(dataPath, FilenameUtils.DefaultResourceName1) ??
                           FindEngineDependency(dataPath, FilenameUtils.DefaultResourceName2));
                }
                else if (FilenameUtils.IsBuiltinExtra(dependency))
                {
                    return(FindEngineDependency(dataPath, FilenameUtils.BuiltinExtraName1) ??
                           FindEngineDependency(dataPath, FilenameUtils.BuiltinExtraName2));
                }
            }
            return(null);
        }
 public static bool IsWebFile(string webPath)
 {
     using (Stream stream = MultiFileStream.OpenRead(webPath))
     {
         return(IsWebFile(stream));
     }
 }
예제 #5
0
        public MixedGameStructure(IEnumerable <string> pathes)
        {
            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 SelectUniquePathes(pathes))
            {
                if (MultiFileStream.Exists(path))
                {
                    string name = MultiFileStream.GetFileName(path);
                    AddFile(files, 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;
            Name       = Files.Count == 0 ? string.Empty : Files.First().Key;
        }
예제 #6
0
        public static BundleFileScheme LoadScheme(string filePath)
        {
            string fileName = Path.GetFileNameWithoutExtension(filePath);

            using (Stream stream = MultiFileStream.OpenRead(filePath))
            {
                return(ReadScheme(stream, filePath, fileName));
            }
        }
        protected void CollectBundleGameFiles(DirectoryInfo root, IDictionary <string, string> files)
        {
            const string DataBundleName = DataName + AssetBundleExtension;
            string       dataBundlePath = Path.Combine(root.FullName, DataBundleName);

            if (MultiFileStream.Exists(dataBundlePath))
            {
                AddAssetBundle(files, DataBundleName, dataBundlePath);
            }
        }
예제 #8
0
 public static SerializedFileScheme LoadScheme(string filePath, string fileName, TransferInstructionFlags flags)
 {
     if (!MultiFileStream.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));
     }
 }
예제 #9
0
 public string RequestResource(string resource)
 {
     foreach (string dataPath in DataPathes)
     {
         string path = Path.Combine(dataPath, resource);
         if (MultiFileStream.Exists(path))
         {
             return(path);
         }
     }
     return(null);
 }
예제 #10
0
        public static bool IsBundleFile(string filePath)
        {
            if (!MultiFileStream.Exists(filePath))
            {
                throw new Exception($"Bundle at path '{filePath}' doesn't exist");
            }

            using (Stream stream = MultiFileStream.OpenRead(filePath))
            {
                return(IsBundleFile(stream));
            }
        }
예제 #11
0
        public static bool IsWebFile(string webPath)
        {
            if (!MultiFileStream.Exists(webPath))
            {
                throw new Exception($"Web at path '{webPath}' doesn't exist");
            }

            using (Stream stream = MultiFileStream.OpenRead(webPath))
            {
                return(IsWebFile(stream));
            }
        }
예제 #12
0
        public static ResourceFileScheme LoadScheme(string filePath, string fileName)
        {
            if (!MultiFileStream.Exists(filePath))
            {
                throw new Exception($"Resource file at path '{filePath}' doesn't exist");
            }

            using (SmartStream stream = SmartStream.OpenRead(filePath))
            {
                return(ReadScheme(stream, 0, stream.Length, filePath, fileName));
            }
        }
 private IEnumerable <string> SelectUniquePathes(IEnumerable <string> pathes)
 {
     return(pathes.Select(t => MultiFileStream.GetFilePath(t)).Distinct());
 }