Beispiel #1
0
        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());
        }
Beispiel #2
0
        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());
        }
Beispiel #3
0
        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);
            }
        }
Beispiel #4
0
 public FilesystemResult(T result, FilesystemErrorCode errorCode) : base(errorCode)
 {
     this.Result = result;
 }
Beispiel #5
0
 public static bool HasFlag(this FilesystemErrorCode errorCode, FilesystemErrorCode flag)
 {
     return((errorCode & flag) != FilesystemErrorCode.ERROR_SUCCESS);
 }