Ejemplo n.º 1
0
        /// <summary>
        /// Writes the storage to disk
        /// </summary>
        /// <param name="filePath">Path to write the file</param>
        /// <param name="oldStorage">TODO</param>
        public void Write(String filePath, JStorageSource oldStorage)
        {
            IJStorageLoader loader;

            // Get a loader for this storage version
            loader = JStorageManager.GetLoader(this._version);

            // Write the storage
            loader.Write(this, oldStorage, filePath);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Reads a storage file from disk
        /// </summary>
        /// <param name="storagePath">Path to the storage file</param>
        public void Read(String storagePath)
        {
            IJStorageLoader loader;

            // Open the storage file
            _storageFileStream = File.Open(storagePath, FileMode.Open, FileAccess.Read);
            _path = storagePath;

            // Read it
            using (BinaryReader br = new BinaryReader(_storageFileStream))
            {
                // Get the storage version
                _version = br.ReadInt32();

                // Get a loader to load this file version
                loader = JStorageManager.GetLoader(_version);

                // Load the storage
                loader.Read(this, br);
            }

            // Reopen the file (as closing the BinaryReader closed it)
            this._storageFileStream = File.Open(storagePath, FileMode.Open, FileAccess.Read);
        }