コード例 #1
0
ファイル: ExFatFileSystem.cs プロジェクト: jason6568/ExFat-2
        /// <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
ファイル: ExFatFileSystem.cs プロジェクト: jason6568/ExFat-2
        /// <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());
             }
         }
     }
 }