Exemplo n.º 1
0
        public override bool SaveContainer(AContainer <BinaryStream> container, string name)
        {
            string filePath   = GetFilePath(name);
            bool   fileExists = File.Exists(filePath);

            if (!fileExists)
            {
                fileExists = CreateFile(filePath);
            }
            if (!fileExists)
            {
                return(false);
            }
            container.CleanUp();

            using (var file = File.Open(filePath, FileMode.Create))
            {
                var memStream = container.GetUnderlyingStream();
                memStream.Seek(0, SeekOrigin.Begin);
                memStream.CopyTo(file);
                file.Close();
            }

            return(true);
        }
Exemplo n.º 2
0
        public override bool SaveContainer(AContainer <BinaryStream> container, string name)
        {
            _storage.Seek(0, SeekOrigin.End);
            PosLen containerPosLen = new PosLen()
            {
                Position = _storage.Position
            };

            container.CleanUp();
            var memStream = container.GetUnderlyingStream();

            memStream.Seek(0, SeekOrigin.Begin);
            memStream.CopyTo(_storage);
            containerPosLen.Length    = _storage.Position - containerPosLen.Position;
            _containerPositions[name] = containerPosLen;
            return(true);
        }