public async Task <ReturnResult> CreateAsync(IStorageItemWithPath source, bool registerHistory) { FilesystemErrorCode returnCode = FilesystemErrorCode.ERROR_INPROGRESS; Progress <FilesystemErrorCode> errorCode = new Progress <FilesystemErrorCode>(); errorCode.ProgressChanged += (s, e) => returnCode = e; IStorageHistory history = await filesystemOperations.CreateAsync(source, errorCode, cancellationToken); if (registerHistory && !string.IsNullOrWhiteSpace(source.Path)) { App.HistoryWrapper.AddHistory(history); } return(returnCode.ToStatus()); }
public async Task <ReturnResult> RenameAsync(PathWithType source, string newName, NameCollisionOption collision, bool registerHistory) { FilesystemErrorCode returnCode = FilesystemErrorCode.ERROR_INPROGRESS; Progress <FilesystemErrorCode> errorCode = new Progress <FilesystemErrorCode>(); errorCode.ProgressChanged += (s, e) => returnCode = e; IStorageHistory history = await filesystemOperations.RenameAsync(source, newName, collision, errorCode, cancellationToken); if (registerHistory && !string.IsNullOrWhiteSpace(source.Path)) { App.HistoryWrapper.AddHistory(history); } return(returnCode.ToStatus()); }
public static ReturnResult ToStatus(this FilesystemErrorCode errorCode) { switch (errorCode) { case FilesystemErrorCode.ERROR_SUCCESS: return(ReturnResult.Success); case FilesystemErrorCode.ERROR_GENERIC: return(ReturnResult.InProgress | ReturnResult.Cancelled); case FilesystemErrorCode.ERROR_UNAUTHORIZED: return(ReturnResult.AccessUnauthorized); case FilesystemErrorCode.ERROR_NOTFOUND: return(ReturnResult.IntegrityCheckFailed); case FilesystemErrorCode.ERROR_INUSE: return(ReturnResult.AccessUnauthorized); case FilesystemErrorCode.ERROR_NAMETOOLONG: return(ReturnResult.UnknownException); case FilesystemErrorCode.ERROR_ALREADYEXIST: return(ReturnResult.Failed | ReturnResult.UnknownException); case FilesystemErrorCode.ERROR_NOTAFOLDER: return(ReturnResult.BadArgumentException | ReturnResult.IntegrityCheckFailed); case FilesystemErrorCode.ERROR_NOTAFILE: return(ReturnResult.BadArgumentException | ReturnResult.IntegrityCheckFailed); case FilesystemErrorCode.ERROR_INPROGRESS: return(ReturnResult.InProgress); default: return(default); } }
public FilesystemResult(T result, FilesystemErrorCode errorCode) : base(errorCode) { this.Result = result; }
public static bool HasFlag(this FilesystemErrorCode errorCode, FilesystemErrorCode flag) { return((errorCode & flag) != FilesystemErrorCode.ERROR_SUCCESS); }