/// <summary> /// Initializes a new instance of the <see cref="RemoveFileCommand"/> class. /// </summary> /// <param name="item">The item to remove.</param> /// <param name="oldState">The old item state.</param> public RemoveFileCommand( NefsItem item, NefsItemState oldState) { this.Item = item ?? throw new ArgumentNullException(nameof(item)); this.OldState = oldState; this.NewState = NefsItemState.Removed; }
/// <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> /// 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)); }
/// <summary> /// Updates the item state. /// </summary> /// <param name="state">The new state.</param> public void UpdateState(NefsItemState state) { this.State = state; }