private LfsOperationData(LfsOperations operation, LfsEntityType type) { Operation = operation; Type = type; FileSystemNumber = InvalidFileSystemNumber; Uid = InvalidUid; }
/// <summary> /// Initializes a new instance of the <see cref="INTV.LtoFlash.Model.LfsUpdateOperation"/> class. /// </summary> /// <param name="fileSystem">The file system.</param> /// <param name="operation">The nature of the operation.</param> /// <param name="entityType">The kind of file system entity involved on the operation.</param> /// <param name="entityId">The identifier (GDN, GFN, GKN) of the entity involved inthe operation.</param> public LfsUpdateOperation(FileSystem fileSystem, LfsOperations operation, LfsEntityType entityType, ushort entityId) { FileSystem = fileSystem; Operation = operation; Directories = new HashSet <byte>(); Files = new HashSet <ushort>(); Forks = new HashSet <ushort>(); Failures = new HashSet <LfsOperationFailure>(); }
/// <summary> /// Determines whether the given directory entry is contained in the directory add, update or delete differences. /// </summary> /// <param name="directory">The directory to search for.</param> /// <param name="operation">Which kind of operations to search for.</param> /// <returns><c>true</c> if the given directory participates in any of the given operations.</returns> public bool Contains(IDirectory directory, LfsOperations operation) { var isInDiff = false; if (operation.HasFlag(LfsOperations.Add)) { isInDiff |= DirectoryDifferences.ToAdd.Any(d => d.GlobalDirectoryNumber == directory.GlobalDirectoryNumber); } if (operation.HasFlag(LfsOperations.Update)) { isInDiff |= DirectoryDifferences.ToUpdate.Any(d => d.GlobalDirectoryNumber == directory.GlobalDirectoryNumber); } if (operation.HasFlag(LfsOperations.Remove)) { isInDiff |= DirectoryDifferences.ToDelete.Contains(directory.GlobalDirectoryNumber); } return(isInDiff); }
/// <summary> /// Determines whether the given fork entry is contained in the fork add, update or delete differences. /// </summary> /// <param name="fork">The fork to search for.</param> /// <param name="operation">Which kind of operations to search for.</param> /// <returns><c>true</c> if the given fork participates in any of the given operations.</returns> public bool Contains(Fork fork, LfsOperations operation) { var isInDiff = false; if (operation.HasFlag(LfsOperations.Add)) { isInDiff |= ForkDifferences.ToAdd.Any(f => f.GlobalForkNumber == fork.GlobalForkNumber); } if (operation.HasFlag(LfsOperations.Update)) { isInDiff |= ForkDifferences.ToUpdate.Any(f => f.GlobalForkNumber == fork.GlobalForkNumber); } if (operation.HasFlag(LfsOperations.Remove)) { isInDiff |= ForkDifferences.ToDelete.Contains(fork.GlobalForkNumber) || ForkDifferences.ToUpdate.Any(f => f.GlobalForkNumber == fork.GlobalForkNumber); } return(isInDiff); }
/// <summary> /// Determines whether the given file entry is contained in the file add, update or delete differences. /// </summary> /// <param name="file">The file to search for.</param> /// <param name="operation">Which kind of operations to search for.</param> /// <returns><c>true</c> if the given file participates in any of the given operations.</returns> public bool Contains(ILfsFileInfo file, LfsOperations operation) { var isInDiff = false; if (operation.HasFlag(LfsOperations.Add)) { isInDiff |= FileDifferences.ToAdd.Any(f => f.GlobalFileNumber == file.GlobalFileNumber); } if (operation.HasFlag(LfsOperations.Update)) { isInDiff |= FileDifferences.ToUpdate.Any(f => f.GlobalFileNumber == file.GlobalFileNumber); } if (operation.HasFlag(LfsOperations.Remove)) { isInDiff |= FileDifferences.ToDelete.Contains(file.GlobalFileNumber); } return(isInDiff); }
/// <summary> /// Creates a new LfsOperationData to describe a file system operation. /// </summary> /// <param name="operation">The kind of operation to create.</param> /// <param name="entry">The global file system entry involved in the operation.</param> /// <param name="targetType">The type of entity to which the operation applies.</param> /// <returns>A new instance of LfsOperationData.</returns> public static LfsOperationData Create(LfsOperations operation, IGlobalFileSystemEntry entry, System.Type targetType) { LfsOperationData operationData = null; switch (operation) { case LfsOperations.Add: case LfsOperations.Remove: case LfsOperations.Update: if ((entry is IDirectory) && (targetType == typeof(IDirectory))) { operationData = new LfsOperationData(operation, (IDirectory)entry); } else if ((entry is ILfsFileInfo) && (targetType == typeof(ILfsFileInfo))) { operationData = new LfsOperationData(operation, (ILfsFileInfo)entry); } else if (entry is Fork) { operationData = new LfsOperationData(operation, (Fork)entry); } else { throw new System.InvalidOperationException(); } break; case LfsOperations.UpdateFlags: operationData = new LfsOperationData(operation); break; case LfsOperations.Reformat: throw new System.InvalidOperationException(Resources.Strings.Reformat_ArgError); } return(operationData); }
/// <summary> /// Initializes a new instance of FileSystemOperationData. /// </summary> /// <param name="operation">The kind of operation being performed.</param> /// <param name="taskData">Task data used for error reporting, et. al.</param> protected FileSystemOperationData(LfsOperations operation, ExecuteDeviceCommandAsyncTaskData taskData) { Operation = operation; TaskData = taskData; }
/// <summary> /// If the operation should update the file system's dirty flags, and hasn't done so already, do so. /// </summary> /// <param name="currentDirtyFlags">The current dirty flags on the file system.</param> /// <param name="fileSystem">The file system being updated.</param> /// <param name="taskData">Task data for displaying updates, tracking success, etc.</param> /// <param name="globalFileSystemNumber">If an error occurs, the entity type and its global file system number value are used to report the error.</param> /// <param name="operation">The kind of file system operation being done.</param> /// <param name="targetType">The kind of file system entity involved in the operation.</param> /// <returns>The new dirty flags.</returns> private static LfsDirtyFlags UpdateFileSystemDirtyState(this LfsDirtyFlags currentDirtyFlags, FileSystem fileSystem, ExecuteDeviceCommandAsyncTaskData taskData, uint globalFileSystemNumber, LfsOperations operation, LfsEntityType targetType) { if (taskData.Succeeded && !currentDirtyFlags.HasFlag(LfsDirtyFlags.FileSystemUpdateInProgress)) { currentDirtyFlags |= LfsDirtyFlags.FileSystemUpdateInProgress; taskData.Succeeded = SetDirtyFlags.Create(currentDirtyFlags).Execute <bool>(taskData.Device.Port, taskData); } if (!taskData.Succeeded && currentDirtyFlags.HasFlag(LfsDirtyFlags.FileSystemUpdateInProgress)) { var errorFormatString = Resources.Strings.FileSystem_InconsistencyError_Format; if (operation == LfsOperations.Remove) { errorFormatString = Resources.Strings.FileSystem_InconsistencyError_Deleting_Format; } else if (operation == LfsOperations.Add) { errorFormatString = Resources.Strings.FileSystem_InconsistencyError_Creating_Format; } else if (operation == LfsOperations.Update) { errorFormatString = Resources.Strings.FileSystem_InconsistencyError_Updating_Format; } throw new InconsistentFileSystemException(targetType, globalFileSystemNumber, errorFormatString); } fileSystem.Status = currentDirtyFlags; return(currentDirtyFlags); }
private LfsOperationData(LfsOperations operation, IDirectory folder) : this(operation, LfsEntityType.Directory, folder) { FileSystemNumber = folder.GlobalDirectoryNumber; }
private LfsOperationData(LfsOperations operation, ILfsFileInfo file) : this(operation, LfsEntityType.File, file) { FileSystemNumber = file.GlobalFileNumber; }
private LfsOperationData(LfsOperations operation, Fork fork) : this(operation, LfsEntityType.Fork, fork) { FileSystemNumber = fork.GlobalForkNumber; }
private LfsOperationData(LfsOperations operation, LfsEntityType type, IGlobalFileSystemEntry fileSystemEntry) : this(operation, type) { Uid = fileSystemEntry.Uid; FileSystemNumber = InvalidFileSystemNumber; }
private LfsOperationData(LfsOperations operation) : this(operation, LfsEntityType.Unknown) { }