| 1 | /* |
|---|
| 2 | * $Id: Plugin.cs 1100 2009-06-03 02:49:33Z lowjoel $ |
|---|
| 3 | * Copyright 2008 The Eraser Project |
|---|
| 4 | * Original Author: Joel Low <lowjoel@users.sourceforge.net> |
|---|
| 5 | * Modified By: |
|---|
| 6 | * |
|---|
| 7 | * This file is part of Eraser. |
|---|
| 8 | * |
|---|
| 9 | * Eraser is free software: you can redistribute it and/or modify it under the |
|---|
| 10 | * terms of the GNU General Public License as published by the Free Software |
|---|
| 11 | * Foundation, either version 3 of the License, or (at your option) any later |
|---|
| 12 | * version. |
|---|
| 13 | * |
|---|
| 14 | * Eraser is distributed in the hope that it will be useful, but WITHOUT ANY |
|---|
| 15 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
|---|
| 16 | * A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
|---|
| 17 | * |
|---|
| 18 | * A copy of the GNU General Public License can be found at |
|---|
| 19 | * <http://www.gnu.org/licenses/>. |
|---|
| 20 | */ |
|---|
| 21 | |
|---|
| 22 | using System; |
|---|
| 23 | using System.Collections.Generic; |
|---|
| 24 | using System.Text; |
|---|
| 25 | |
|---|
| 26 | using System.IO; |
|---|
| 27 | using Eraser.Manager; |
|---|
| 28 | using Eraser.Util; |
|---|
| 29 | |
|---|
| 30 | namespace Eraser.DefaultPlugins |
|---|
| 31 | { |
|---|
| 32 | /// <summary> |
|---|
| 33 | /// Provides functions to handle erasures specific to FAT volumes. |
|---|
| 34 | /// </summary> |
|---|
| 35 | public abstract class FatFileSystem : WindowsFileSystem |
|---|
| 36 | { |
|---|
| 37 | public override void EraseOldFileSystemResidentFiles(VolumeInfo volume, |
|---|
| 38 | DirectoryInfo tempDirectory, ErasureMethod method, |
|---|
| 39 | FileSystemEntriesEraseProgress callback) |
|---|
| 40 | { |
|---|
| 41 | //Nothing to be done here. FAT doesn't store files in its FAT. |
|---|
| 42 | } |
|---|
| 43 | |
|---|
| 44 | public override void EraseFileSystemObject(StreamInfo info, ErasureMethod method, |
|---|
| 45 | ErasureMethodProgressFunction callback) |
|---|
| 46 | { |
|---|
| 47 | //Create the file stream, and call the erasure method to write to |
|---|
| 48 | //the stream. |
|---|
| 49 | long fileArea = GetFileArea(info.FullName); |
|---|
| 50 | using (FileStream strm = info.Open(FileMode.Open, FileAccess.Write, |
|---|
| 51 | FileShare.None, FileOptions.WriteThrough)) |
|---|
| 52 | { |
|---|
| 53 | //Set the end of the stream after the wrap-round the cluster size |
|---|
| 54 | strm.SetLength(fileArea); |
|---|
| 55 | |
|---|
| 56 | //If the stream is empty, there's nothing to overwrite. Continue |
|---|
| 57 | //to the next entry |
|---|
| 58 | if (strm.Length != 0) |
|---|
| 59 | { |
|---|
| 60 | //Then erase the file. |
|---|
| 61 | method.Erase(strm, long.MaxValue, |
|---|
| 62 | PrngManager.GetInstance(ManagerLibrary.Settings.ActivePrng), |
|---|
| 63 | callback |
|---|
| 64 | ); |
|---|
| 65 | } |
|---|
| 66 | |
|---|
| 67 | //Set the length of the file to 0. |
|---|
| 68 | strm.Seek(0, SeekOrigin.Begin); |
|---|
| 69 | strm.SetLength(0); |
|---|
| 70 | } |
|---|
| 71 | } |
|---|
| 72 | |
|---|
| 73 | protected override DateTime MinTimestamp |
|---|
| 74 | { |
|---|
| 75 | get |
|---|
| 76 | { |
|---|
| 77 | return new DateTime(1980, 1, 1, 0, 0, 0); |
|---|
| 78 | } |
|---|
| 79 | } |
|---|
| 80 | } |
|---|
| 81 | |
|---|
| 82 | public class Fat32FileSystem : FatFileSystem |
|---|
| 83 | { |
|---|
| 84 | public override bool Supports(string fileSystemName) |
|---|
| 85 | { |
|---|
| 86 | if (fileSystemName == "FAT32") |
|---|
| 87 | return true; |
|---|
| 88 | return false; |
|---|
| 89 | } |
|---|
| 90 | |
|---|
| 91 | public override void EraseDirectoryStructures(VolumeInfo info, |
|---|
| 92 | FileSystemEntriesEraseProgress callback) |
|---|
| 93 | { |
|---|
| 94 | Fat32Api api = new Fat32Api(info); |
|---|
| 95 | } |
|---|
| 96 | } |
|---|
| 97 | } |
|---|