/// <summary> /// Adds the entry to directory (given by <see cref="DataDescriptor" />). /// </summary> /// <param name="dataDescriptor">The data descriptor.</param> /// <param name="metaEntry">The meta entry.</param> /// <returns>A <see cref="DataDescriptor"/> describing directory after append</returns> public void UpdateEntry(DataDescriptor dataDescriptor, ExFatMetaDirectoryEntry metaEntry) { lock (_directoryLock) { using (var directoryStream = OpenDataStream(dataDescriptor, FileAccess.ReadWrite)) { directoryStream.Seek(metaEntry.Primary.DirectoryPosition, SeekOrigin.Begin); metaEntry.Write(directoryStream); } } }
/// <summary> /// Adds the entry to directory (given by <see cref="DataDescriptor" />. /// </summary> /// <param name="targetDirectoryDataDescriptor">The data descriptor.</param> /// <param name="metaEntry">The meta entry.</param> /// <returns>A <see cref="DataDescriptor"/> describing directory after append</returns> public DataDescriptor AddEntry(DataDescriptor targetDirectoryDataDescriptor, ExFatMetaDirectoryEntry metaEntry) { var r = targetDirectoryDataDescriptor; lock (_directoryLock) { using (var directoryStream = OpenDataStream(targetDirectoryDataDescriptor, FileAccess.ReadWrite, d => r = d)) { var availableSlot = FindAvailableSlot(directoryStream, metaEntry.Entries.Count); directoryStream.Seek(availableSlot, SeekOrigin.Begin); foreach (var entry in metaEntry.Entries) { entry.EntryType.Value |= ExFatDirectoryEntryType.InUse; } metaEntry.Write(directoryStream); } } return(r); }