private IValidationResult ValidateInternal(INamedObjectInfo node, bool isDirectory) { string name = node.Name; List <int> positions = new List <int>(); for (int i = 0, codepointIndex = 0; i < name.Length; ++i, ++codepointIndex) { int codePoint; if (char.IsSurrogatePair(name, i)) { codePoint = char.ConvertToUtf32(name, i); i += 1; } else { codePoint = name[i]; } if (codePoint < 0 || codePoint >= this.NumberOfCodePoints || this._codePointBlackList[codePoint]) { // adding +1 so that positions are 1-based // to make them more human friendly positions.Add(codepointIndex + 1); } } if (positions.Count > 0) { string itemLabel = isDirectory ? "Directory" : "File"; string description = $"{itemLabel} {node.Name} has an unsupported character in position"; if (positions.Count > 1) { description += "s"; } description += " "; description += String.Join(", ", positions); description += "."; return(new ValidationResult { Result = Result.Fail, Level = ResultLevel.Error, Path = node.FullName, Type = this.ValidationType, Kind = this.ValidationKind, Description = description, Positions = positions }); } return(this.SuccessfulResult); }
private IValidationResult ValidateInternal(INamedObjectInfo node) { bool filenameIsTooLong = node.Name.Length > this._maxFilenameLength; if (filenameIsTooLong) { return(new ValidationResult { Result = Result.Fail, Description = $"Filename {node.Name} is too long. Max length is {this._maxFilenameLength}", Level = ResultLevel.Error, Path = node.FullName, Type = this.ValidationType }); } return(this.SuccessfulResult); }
private IValidationResult ValidateInternal(INamedObjectInfo node) { AfsPath path = new AfsPath(node.FullName); int depth = path.Depth; bool isTooDeep = depth > this._maxTreeDepth; if (isTooDeep) { return(new ValidationResult { Result = Result.Fail, Description = $"Directory tree depth limit exceeded. Maximum tree depth is {this._maxTreeDepth}.", Level = ResultLevel.Error, Path = node.FullName, Type = this.ValidationType }); } return(this.SuccessfulResult); }
private IValidationResult ValidateInternal(INamedObjectInfo node) { AfsPath path = new AfsPath(node.FullName); int pathLength = path.Length; bool pathIsTooLong = pathLength > this._maxPathLength; if (pathIsTooLong) { return(new ValidationResult { Result = Result.Fail, Description = $"Path length limit exceeded. Maximum length is {this._maxPathLength}.", Level = ResultLevel.Error, Path = node.FullName, Type = this.ValidationType }); } return(this.SuccessfulResult); }