示例#1
0
 public PackageFileStreamLZ4(BundleOdbBackend bundleOdbBackend, string packageLocation, Stream innerStream, CompressionMode compressionMode, long uncompressedStreamSize, long compressedSize)
     : base(innerStream, compressionMode, uncompressedSize: uncompressedStreamSize, compressedSize: compressedSize, disposeInnerStream: false)
 {
     this.bundleOdbBackend = bundleOdbBackend;
     this.packageLocation  = packageLocation;
     this.innerStream      = innerStream;
 }
示例#2
0
        public void CreateBundle(ObjectId[] objectIds, string bundleName, BundleOdbBackend bundleBackend, ISet <ObjectId> disableCompressionIds, Dictionary <string, ObjectId> indexMap, IList <string> dependencies)
        {
            if (bundleBackend == null)
            {
                throw new InvalidOperationException("Can't pack files.");
            }

            if (objectIds.Length == 0)
            {
                return;
            }

            var packUrl = bundleBackend.BundleDirectory + bundleName + BundleOdbBackend.BundleExtension; // we don't want the pack to be compressed in the APK on android

            // Create pack
            BundleOdbBackend.CreateBundle(packUrl, backendRead1, objectIds, disableCompressionIds, indexMap, dependencies);
        }
示例#3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ObjectDatabase" /> class.
        /// </summary>
        /// <param name="vfsMainUrl">The VFS main URL.</param>
        /// <param name="indexName">Name of the index file.</param>
        /// <param name="vfsAdditionalUrl">The VFS additional URL. It will be used only if vfsMainUrl is read-only.</param>
        public ObjectDatabase(string vfsMainUrl, string indexName = "index", string vfsAdditionalUrl = null, bool loadDefaultBundle = true)
        {
            if (vfsMainUrl == null)
            {
                throw new ArgumentNullException("vfsMainUrl");
            }

            // Create the merged asset index map
            AssetIndexMap = new ObjectDatabaseAssetIndexMap();

            // Try to open file backends
            bool isReadOnly = Platform.Type != PlatformType.Windows;
            var  backend    = new FileOdbBackend(vfsMainUrl, isReadOnly, indexName);

            AssetIndexMap.Merge(backend.AssetIndexMap);
            if (backend.IsReadOnly)
            {
                backendRead1 = backend;
                if (vfsAdditionalUrl != null)
                {
                    backendWrite = backendRead2 = new FileOdbBackend(vfsAdditionalUrl, false);
                    AssetIndexMap.Merge(backendWrite.AssetIndexMap);
                }
            }
            else
            {
                backendWrite = backendRead1 = backend;
            }

            AssetIndexMap.WriteableAssetIndexMap = backendWrite.AssetIndexMap;

            bundleBackend = new BundleOdbBackend(vfsMainUrl);

            // Try to open "default" pack file synchronously
            if (loadDefaultBundle)
            {
                try
                {
                    bundleBackend.LoadBundle("default", AssetIndexMap).GetAwaiter().GetResult();
                }
                catch (FileNotFoundException)
                {
                }
            }
        }
示例#4
0
 public PackageFileStream(BundleOdbBackend bundleOdbBackend, string packageLocation, Stream internalStream, long startPosition = 0, long endPosition = -1, bool disposeInternalStream = true, bool seekToBeginning = true)
     : base(internalStream, startPosition, endPosition, disposeInternalStream, seekToBeginning)
 {
     this.bundleOdbBackend = bundleOdbBackend;
     this.packageLocation  = packageLocation;
 }