コード例 #1
0
 /// <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);
 }
コード例 #2
0
 /// <summary>
 /// Initialize a new instance of type <see cref="FileSystemSyncErrors"/> type.
 /// </summary>
 /// <param name="initialDirtyFlags">The file system's 'dirty' flags at the beginning of the operation.</param>
 public FileSystemSyncErrors(LfsDirtyFlags initialDirtyFlags)
 {
     InitialDirtyFlags     = initialDirtyFlags;
     FailedToCreateEntries = new HashSet <IGlobalFileSystemEntry>();
     OrphanedForks         = new HashSet <Fork>();
     UnableToRetrieveForks = new HashSet <Fork>();
     UnsupportedForks      = new HashSet <Tuple <ILfsFileInfo, Fork> >();
 }
コード例 #3
0
 /// <summary>
 /// Sets the file system dirty flags on a Locutus device.
 /// </summary>
 /// <param name="device">The target Locutus device whose file system dirty flags are to be set.</param>
 /// <param name="flags">The flags to set.</param>
 /// <param name="errorHandler">Error handler, used to report errors to the user.</param>
 public static void SetFileSystemFlags(this Device device, LfsDirtyFlags flags, DeviceCommandErrorHandler errorHandler)
 {
     if (device.IsSafeToStartCommand())
     {
         var executeCommandTaskData = new ExecuteDeviceCommandAsyncTaskData(device, ProtocolCommandId.LfsSetFileSystemStatusFlags)
         {
             Data      = flags,
             OnSuccess = (c, p, r) => device.FileSystemFlags = flags,
             OnFailure = errorHandler
         };
         executeCommandTaskData.StartTask(SetFileSystemFlags);
     }
 }
コード例 #4
0
 /// <summary>
 /// Creates an instance of the SetDirtyFlags command.
 /// </summary>
 /// <param name="dirtyFlags">The flags to store on the device.</param>
 /// <returns>A new instance of the command.</returns>
 public static SetDirtyFlags Create(LfsDirtyFlags dirtyFlags)
 {
     return(new SetDirtyFlags(dirtyFlags));
 }
コード例 #5
0
 private SetDirtyFlags(LfsDirtyFlags dirtyFlags)
     : base(ProtocolCommandId.LfsSetFileSystemStatusFlags, DefaultResponseTimeout, (uint)dirtyFlags)
 {
 }
コード例 #6
0
        private static LfsDirtyFlags DeleteEntries <T>(IList <T> entries, DeleteOperationData deleteOpData, LfsDirtyFlags currentDirtyFlags, FileSystem deviceFileSystem)
        {
            var data        = deleteOpData.TaskData;
            var device      = data.Device;
            var numDeleted  = 0;
            var numToDelete = entries.Count;
            var succeeded   = false;

            foreach (var entry in entries)
            {
                if (data.AcceptCancelIfRequested())
                {
                    break;
                }
                deleteOpData.UpdateTitle();
                deleteOpData.UpdateStatus(numToDelete, ref numDeleted);
                currentDirtyFlags |= currentDirtyFlags.UpdateFileSystemDirtyState(deviceFileSystem, data, Convert.ToUInt32(entry), deleteOpData.Operation, deleteOpData.TargetType);
                deleteOpData.CreateCommand(entry).Execute(device.Port, data, out succeeded);
            }
            return(currentDirtyFlags);
        }