public override CommandResult Validate(CommandArg arg) { CommandResult result = base.Validate(arg); if (result.Succeeded) { string path = arg.Value; if (!Path.IsPathFullyQualified(path)) { try { path = Path.Combine(GeneralParameters.Instance.WorkingFolder, path); } catch (Exception ex) { result.Append(new CommandResult(false, "Invalid path:", ex)); } } if (result.Succeeded) { if (!FileSupport.IsFolderReadable(path)) { return(new CommandResult(false, $"Folder '{path}' does not exist or is not readable")); } arg.ResolvedValue = path; } } return(result); }
public static FolderStatus Validate(string path) { FolderStatus status = FolderStatus.Valid; if (String.IsNullOrEmpty(path)) { status |= FolderStatus.NullPath; } else if (!FileSupport.IsValidPath(path)) { status |= FolderStatus.InvalidPath; } else if (!System.IO.Path.IsPathFullyQualified(path)) { status |= FolderStatus.NotFullyQualified; } else if (!Directory.Exists(path)) { status |= FolderStatus.Nonextant; } else if (!FileSupport.IsFolderReadable(path)) { status |= FolderStatus.Unreadable; } return(status); }
public void IsFolderReadableTest() { Assert.False(FileSupport.IsFolderReadable(_fixture.UnreadableFolderPath)); Assert.True(FileSupport.IsFolderReadable(_fixture.ReadableFolderPath)); Assert.False(FileSupport.IsFolderReadable(_fixture.InvalidFilePath)); }