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); } } }
public static bool IsSerializedFile(string filePath) { using (Stream stream = MultiFileStream.OpenRead(filePath)) { return(IsSerializedFile(stream)); } }
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)); } }
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; }
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); } }
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)); } }
public string RequestResource(string resource) { foreach (string dataPath in DataPathes) { string path = Path.Combine(dataPath, resource); if (MultiFileStream.Exists(path)) { return(path); } } return(null); }
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)); } }
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)); } }
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()); }