Esempio n. 1
0
      public override void EraseFileSystemObject(StreamInfo info, ErasureMethod method,
 ErasureMethodProgressFunction callback)
      {
          VolumeInfo volume = VolumeInfo.FromMountpoint(info.DirectoryName);
             if (info.Length < Math.Max(volume.ClusterSize, 1024))
             {
          using (FileStream strm = info.Open(FileMode.Open, FileAccess.Write,
           FileShare.None))
          {
           method.Erase(strm, long.MaxValue,
            PrngManager.GetInstance(ManagerLibrary.Settings.ActivePrng), null);
          }
             }
             long fileArea = GetFileArea(info.FullName);
             if (fileArea == 0)
          return;
             using (FileStream strm = info.Open(FileMode.Open, FileAccess.Write,
          FileShare.None, FileOptions.WriteThrough))
             {
          strm.SetLength(fileArea);
          method.Erase(strm, long.MaxValue,
           PrngManager.GetInstance(ManagerLibrary.Settings.ActivePrng),
           callback
          );
          strm.Seek(0, SeekOrigin.Begin);
          strm.SetLength(0);
             }
      }
Esempio n. 2
0
 private void EraseFileClusterTips(string file, ErasureMethod method)
 {
     StreamInfo streamInfo = new StreamInfo(file);
        DateTime lastAccess = streamInfo.LastAccessTime;
        DateTime lastWrite = streamInfo.LastWriteTime;
        DateTime created = streamInfo.CreationTime;
        long fileArea = GetFileArea(file);
        long fileLength = streamInfo.Length;
        if (fileArea == fileLength)
     return;
        using (FileStream stream = streamInfo.Open(FileMode.Open, FileAccess.Write,
     FileShare.None, FileOptions.WriteThrough))
        {
     try
     {
      stream.SetLength(fileArea);
      stream.Seek(fileLength, SeekOrigin.Begin);
      method.Erase(stream, long.MaxValue, PrngManager.GetInstance(
       ManagerLibrary.Settings.ActivePrng), null);
     }
     finally
     {
      stream.SetLength(fileLength);
      streamInfo.LastAccessTime = lastAccess;
      streamInfo.LastWriteTime = lastWrite;
      streamInfo.CreationTime = created;
     }
        }
 }
Esempio n. 3
0
      public override void EraseFileSystemObject(StreamInfo info, ErasureMethod method,
 ErasureMethodProgressFunction callback)
      {
          long fileArea = GetFileArea(info.FullName);
             using (FileStream strm = info.Open(FileMode.Open, FileAccess.Write,
          FileShare.None, FileOptions.WriteThrough))
             {
          strm.SetLength(fileArea);
          if (strm.Length != 0)
          {
           method.Erase(strm, long.MaxValue,
            PrngManager.GetInstance(ManagerLibrary.Settings.ActivePrng),
            callback
           );
          }
          strm.Seek(0, SeekOrigin.Begin);
          strm.SetLength(0);
             }
      }