An IArchiveStorage implementation suitable for hard disks.
Inheritance: BaseArchiveStorage
Example #1
0
        public override Stream ConvertTemporaryToFinal()
        {
            if (this.temporaryStream_ == null)
            {
                throw new ZipException("No temporary stream has been created");
            }
            Stream result       = null;
            string tempFileName = DiskArchiveStorage.GetTempFileName(this.fileName_, false);
            bool   flag         = false;

            try
            {
                this.temporaryStream_.Close();
                File.Move(this.fileName_, tempFileName);
                File.Move(this.temporaryName_, this.fileName_);
                flag = true;
                File.Delete(tempFileName);
                result = File.OpenRead(this.fileName_);
            }
            catch (Exception)
            {
                result = null;
                if (!flag)
                {
                    File.Move(tempFileName, this.fileName_);
                    File.Delete(this.temporaryName_);
                }
                throw;
            }
            return(result);
        }
Example #2
0
 public override Stream MakeTemporaryCopy(Stream stream)
 {
     stream.Close();
     this.temporaryName_ = DiskArchiveStorage.GetTempFileName(this.fileName_, true);
     File.Copy(this.fileName_, this.temporaryName_, true);
     this.temporaryStream_ = new FileStream(this.temporaryName_, FileMode.Open, FileAccess.ReadWrite);
     return(this.temporaryStream_);
 }
Example #3
0
 public override Stream GetTemporaryOutput()
 {
     if (this.temporaryName_ != null)
     {
         this.temporaryName_   = DiskArchiveStorage.GetTempFileName(this.temporaryName_, true);
         this.temporaryStream_ = File.OpenWrite(this.temporaryName_);
     }
     else
     {
         this.temporaryName_   = Path.GetTempFileName();
         this.temporaryStream_ = File.OpenWrite(this.temporaryName_);
     }
     return(this.temporaryStream_);
 }
 public override Stream GetTemporaryOutput()
 {
     if (this.temporaryName_ != null)
     {
         this.temporaryName_   = DiskArchiveStorage.GetTempFileName(this.temporaryName_, true);
         this.temporaryStream_ = File.Open(this.temporaryName_, FileMode.OpenOrCreate, FileAccess.Write, FileShare.None);
     }
     else
     {
         this.temporaryName_   = Path.GetTempFileName();
         this.temporaryStream_ = File.Open(this.temporaryName_, FileMode.OpenOrCreate, FileAccess.Write, FileShare.None);
     }
     return(this.temporaryStream_);
 }