public static AssetIndexMap CreateInMemory() { var result = new AssetIndexMap { stream = new MemoryStream() }; result.LoadNewValues(); return(result); }
public static AssetIndexMap NewTool(string indexName = null) { if (string.IsNullOrWhiteSpace(indexName)) { indexName = "index"; } var result = new AssetIndexMap(); // Try to open with read-write result.stream = VirtualFileSystem.OpenStream( "/data/db/" + indexName, VirtualFileMode.OpenOrCreate, VirtualFileAccess.ReadWrite, VirtualFileShare.ReadWrite); return(result); }
public static AssetIndexMap NewTool(string indexName) { if (indexName == null) { throw new ArgumentNullException(nameof(indexName)); } var result = new AssetIndexMap { // Try to open with read-write stream = VirtualFileSystem.OpenStream( VirtualFileSystem.ApplicationDatabasePath + '/' + indexName, VirtualFileMode.OpenOrCreate, VirtualFileAccess.ReadWrite, VirtualFileShare.ReadWrite) }; return(result); }
public static AssetIndexMap Load(string indexFile, bool isReadOnly = false) { if (indexFile == null) { throw new ArgumentNullException(nameof(indexFile)); } var result = new AssetIndexMap(); var isAppDataWriteable = !isReadOnly; if (isAppDataWriteable) { try { // Try to open with read-write result.stream = VirtualFileSystem.OpenStream( indexFile, VirtualFileMode.OpenOrCreate, VirtualFileAccess.ReadWrite, VirtualFileShare.ReadWrite); } catch (UnauthorizedAccessException) { isAppDataWriteable = false; } } if (!isAppDataWriteable) { // Try to open read-only result.stream = VirtualFileSystem.OpenStream( indexFile, VirtualFileMode.Open, VirtualFileAccess.Read); } result.LoadNewValues(); return(result); }