public static IOLink From(string value, bool strict = true) { var link = FileLink.From(value, strict: false) ?? FolderLink.From(value, strict: false) as IOLink; ExpectNot(strict && link == null, "Value is not an I/O link"); return(link); }
public static FileLink From(string value, bool strict = true, bool extensionOptional = false) { var parsedFolder = FolderLink.From(value, strict); if (parsedFolder != null) { var fileSegment = parsedFolder.Resource.Path.Segments.LastOrDefault(); if (fileSegment != null) { var parsedName = FileName.From(fileSegment.ToString(), strict, extensionOptional); if (parsedName != null) { return(new FileLink(parsedFolder.Up(strict: false), parsedName)); } } } ExpectNot(strict, "Cannot parse file link"); return(null); }
private IEnumerable <FolderLink> ReadFolderLinksCore(FolderResource subfolder, bool recursive = false) { var folderPath = Link.Then(subfolder).ToString(); var pattern = "*.*"; var option = recursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly; return(Directory.GetDirectories(folderPath, pattern, option).Select(subdirectory => FolderLink.From(subdirectory))); }
public static FileLink From(string folder, string file, bool strict = true) { var parsedFolder = FolderLink.From(folder, strict); return(parsedFolder == null ? null : From(parsedFolder, file, strict)); }