示例#1
0
        public static AssetIndexMap CreateInMemory()
        {
            var result = new AssetIndexMap {
                stream = new MemoryStream()
            };

            result.LoadNewValues();
            return(result);
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }
示例#4
0
        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);
        }