/// <summary> /// Formats the specified volume. /// </summary> /// <param name="volume">The volume.</param> /// <param name="options">The options.</param> /// <param name="label">The label.</param> /// <returns></returns> public static ExFatFileSystem Format(PhysicalVolumeInfo volume, ExFatFormatOptions options = null, string label = null) { var partitionStream = volume.Open(); using (ExFatPathFilesystem.Format(partitionStream, options, label)) { } return(new ExFatFileSystem(partitionStream)); }
public void ReadDatesTest() { using (var testEnvironment = StreamTestEnvironment.FromExistingVhdx()) using (var filesystem = new ExFatPathFilesystem(testEnvironment.PartitionStream)) { var c = filesystem.GetCreationTime(DiskContent.LongContiguousFileName); } }
public void ReadSubFolderFilesTest() { using (var testEnvironment = StreamTestEnvironment.FromExistingVhdx()) using (var filesystem = new ExFatPathFilesystem(testEnvironment.PartitionStream)) { var entries = filesystem.EnumerateEntries(DiskContent.LongFolderFileName).ToArray(); Assert.AreEqual(DiskContent.LongFolderEntriesCount, entries.Length); } }
public void DeleteTree() { using (var testEnvironment = StreamTestEnvironment.FromExistingVhdx(true)) { using (var filesystem = new ExFatPathFilesystem(testEnvironment.PartitionStream)) { filesystem.DeleteTree(DiskContent.LongFolderFileName); Assert.IsFalse(filesystem.EnumerateEntries("") .Any(e => e.Path == $@"\{DiskContent.LongFolderFileName}")); } } }
/// <summary> /// Initializes a new instance of the <see cref="T:ExFat.DiscUtils.ExFatFileSystem" /> class. /// </summary> /// <param name="partitionStream">The partition stream.</param> /// <param name="pathSeparators">The path separators.</param> /// <exception cref="InvalidOperationException">Given stream is not exFAT volume</exception> /// <exception cref="T:System.InvalidOperationException">Given stream is not exFAT volume</exception> /// <inheritdoc /> public ExFatFileSystem(Stream partitionStream, char[] pathSeparators = null) { _filesystem = new ExFatPathFilesystem(partitionStream); PathSeparators = pathSeparators ?? DefaultSeparators; var bootSector = ExFatPartition.ReadBootSector(partitionStream); if (!bootSector.IsValid) { throw new InvalidOperationException("Given stream is not exFAT volume"); } _partitionStream = partitionStream; }
public void ReadRootFolderEntriesTest() { using (var testEnvironment = StreamTestEnvironment.FromExistingVhdx()) using (var filesystem = new ExFatPathFilesystem(testEnvironment.PartitionStream)) { var entries = filesystem.EnumerateEntries(@"\").ToArray(); Assert.IsTrue(entries.Any(e => e.Path == DiskContent.LongContiguousFileName)); Assert.IsTrue(entries.Any(e => e.Path == DiskContent.LongSparseFile1Name)); Assert.IsTrue(entries.Any(e => e.Path == DiskContent.EmptyRootFolderFileName)); Assert.IsTrue(entries.Any(e => e.Path == DiskContent.LongFolderFileName)); } }
public void MoveTree() { using (var testEnvironment = StreamTestEnvironment.FromExistingVhdx(true)) { using (var filesystem = new ExFatPathFilesystem(testEnvironment.PartitionStream)) { filesystem.Move(DiskContent.LongSparseFile1Name, DiskContent.EmptyRootFolderFileName); Assert.IsNull(filesystem.GetInformation(DiskContent.LongSparseFile1Name)); Assert.IsNotNull( filesystem.GetInformation(DiskContent.EmptyRootFolderFileName + "\\" + DiskContent.LongSparseFile1Name)); } } }
public void CreateDirectoryTree() { using (var testEnvironment = StreamTestEnvironment.FromExistingVhdx(true)) { using (var filesystem = new ExFatPathFilesystem(testEnvironment.PartitionStream)) { var now = DateTime.UtcNow; var path = @"a\b\c"; filesystem.CreateDirectory(path); var d = filesystem.GetCreationTimeUtc(path); Assert.IsTrue(IsAlmostMoreRecentThan(d, now)); } } }
public void CreateFileTree() { using (var testEnvironment = StreamTestEnvironment.FromExistingVhdx(true)) { using (var filesystem = new ExFatPathFilesystem(testEnvironment.PartitionStream)) { filesystem.CreateDirectory("a"); using (var s = filesystem.Open(@"a\b.txt", FileMode.Create, FileAccess.ReadWrite)) s.WriteByte(66); using (var r = filesystem.Open(@"a\b.txt", FileMode.Open, FileAccess.Read)) { Assert.AreEqual(66, r.ReadByte()); Assert.AreEqual(-1, r.ReadByte()); } } } }