/// <inheritdoc/> public async Task <NefsItemSize> TransformFileAsync( INefsDataSource input, string outputFile, NefsDataTransform transform, NefsProgress p) { return(await this.TransformFileAsync(input.FilePath, outputFile, transform, p)); }
/// <inheritdoc/> public async Task <NefsItemSize> CompressFileAsync( INefsDataSource input, string outputFile, UInt32 chunkSize, NefsProgress p) { return(await this.CompressFileAsync(input.FilePath, outputFile, chunkSize, p)); }
/// <summary> /// Initializes a new instance of the <see cref="ReplaceFileCommand"/> class. /// </summary> /// <param name="item">The item to replace.</param> /// <param name="newDataSource">The new data source.</param> public ReplaceFileCommand(NefsItem item, INefsDataSource newDataSource) { this.Item = item; this.OldDataSource = item.DataSource; this.OldState = item.State; this.NewDataSource = newDataSource; this.NewState = NefsItemState.Replaced; }
/// <summary> /// Updates the data source for the item and the item's state. If the data source has /// changed, the new item data will be written to the archive when it is saved. If /// compression is required, the file data will be compressed when the archive is written. /// </summary> /// <param name="dataSource">The new data source to use.</param> /// <param name="state">The new item state.</param> public void UpdateDataSource(INefsDataSource dataSource, NefsItemState state) { if (this.Type == NefsItemType.Directory) { throw new InvalidOperationException($"Cannot perform {nameof(this.UpdateDataSource)} on a directory."); } this.DataSource = dataSource ?? throw new ArgumentNullException(nameof(dataSource)); this.State = state; }
/// <summary> /// Initializes a new instance of the <see cref="ReplaceFileCommand"/> class. /// </summary> /// <param name="item">The item to perform the command on.</param> /// <param name="oldDataSource">The old data source.</param> /// <param name="oldState">The old state.</param> /// <param name="newDataSource">The new data source.</param> public ReplaceFileCommand( NefsItem item, INefsDataSource oldDataSource, NefsItemState oldState, INefsDataSource newDataSource) { this.Item = item ?? throw new ArgumentNullException(nameof(item)); this.OldDataSource = oldDataSource ?? throw new ArgumentNullException(nameof(oldDataSource)); this.OldState = oldState; this.NewDataSource = newDataSource ?? throw new ArgumentNullException(nameof(newDataSource)); this.NewState = NefsItemState.Replaced; }
/// <summary> /// Creates an item for testing. /// </summary> /// <param name="id">The item id.</param> /// <param name="dirId">The directory id.</param> /// <param name="fileName">The item name.</param> /// <param name="dataSource">The data source.</param> /// <returns>The new item.</returns> internal static NefsItem CreateFile( uint id, uint dirId, string fileName, INefsDataSource dataSource) { var attributes = new NefsItemAttributes(v20IsZlib: true); var transform = TestTransform; return(new NefsItem( Guid.NewGuid(), new NefsItemId(id), fileName, new NefsItemId(dirId), dataSource, transform, attributes)); }
/// <summary> /// Initializes a new instance of the <see cref="NefsItem"/> class. /// </summary> /// <param name="guid">The unique identifier for this item.</param> /// <param name="id">The item id.</param> /// <param name="fileName">The file name within the archive.</param> /// <param name="directoryId">The directory id the item is in.</param> /// <param name="dataSource">The data source for the item's data.</param> /// <param name="transform"> /// The transform that is applied to this item's data. Can be null if no transform. /// </param> /// <param name="attributes">Additional attributes.</param> /// <param name="state">The item state.</param> public NefsItem( Guid guid, NefsItemId id, string fileName, NefsItemId directoryId, INefsDataSource dataSource, NefsDataTransform transform, NefsItemAttributes attributes, NefsItemState state = NefsItemState.None) { this.Guid = guid; this.Id = id; this.DirectoryId = directoryId; this.DataSource = dataSource ?? throw new ArgumentNullException(nameof(dataSource)); this.State = state; this.Transform = transform; this.Attributes = attributes; // Save file name this.FileName = fileName ?? throw new ArgumentNullException(nameof(fileName)); }
/// <summary> /// Initializes a new instance of the <see cref="NefsItem"/> class. /// </summary> /// <param name="id">The item id (index).</param> /// <param name="fileName">The file name within the archive.</param> /// <param name="directoryId">The directory id the item is in.</param> /// <param name="type">The type of item.</param> /// <param name="dataSource">The data source for the item's data.</param> /// <param name="unknownData">Unknown metadata.</param> /// <param name="state">The item state.</param> public NefsItem( NefsItemId id, string fileName, NefsItemId directoryId, NefsItemType type, INefsDataSource dataSource, NefsItemUnknownData unknownData, NefsItemState state = NefsItemState.None) { this.Id = id; this.DirectoryId = directoryId; this.Type = type; this.DataSource = dataSource ?? throw new ArgumentNullException(nameof(dataSource)); this.State = state; // Unknown data this.Part6Unknown0x00 = unknownData.Part6Unknown0x00; this.Part6Unknown0x01 = unknownData.Part6Unknown0x01; this.Part6Unknown0x02 = unknownData.Part6Unknown0x02; this.Part6Unknown0x03 = unknownData.Part6Unknown0x03; // Save file name this.FileName = fileName ?? throw new ArgumentNullException(nameof(fileName)); }