예제 #1
0
        /// <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));
        }
예제 #2
0
 public void ReadDatesTest()
 {
     using (var testEnvironment = StreamTestEnvironment.FromExistingVhdx())
         using (var filesystem = new ExFatPathFilesystem(testEnvironment.PartitionStream))
         {
             var c = filesystem.GetCreationTime(DiskContent.LongContiguousFileName);
         }
 }
예제 #3
0
 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);
         }
 }
예제 #4
0
 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}"));
         }
     }
 }
예제 #5
0
        /// <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;
        }
예제 #6
0
 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));
         }
 }
예제 #7
0
 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));
         }
     }
 }
예제 #8
0
 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));
         }
     }
 }
예제 #9
0
 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());
             }
         }
     }
 }