{"id":26800610,"url":"https://github.com/ktsu-dev/strongpaths","last_synced_at":"2025-03-29T20:18:07.399Z","repository":{"id":166467747,"uuid":"641964088","full_name":"ktsu-dev/StrongPaths","owner":"ktsu-dev","description":null,"archived":false,"fork":false,"pushed_at":"2024-10-17T14:49:19.000Z","size":246,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-29T10:08:29.780Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ktsu-dev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-17T14:25:54.000Z","updated_at":"2024-10-17T14:49:22.000Z","dependencies_parsed_at":"2023-12-19T06:45:47.535Z","dependency_job_id":"eb314380-0156-4283-a808-00e726394078","html_url":"https://github.com/ktsu-dev/StrongPaths","commit_stats":null,"previous_names":["ktsu-io/StrongPaths","ktsu-dev/strongpaths","ktsu-io/strongpaths"],"tags_count":84,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ktsu-dev%2FStrongPaths","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ktsu-dev%2FStrongPaths/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ktsu-dev%2FStrongPaths/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ktsu-dev%2FStrongPaths/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ktsu-dev","download_url":"https://codeload.github.com/ktsu-dev/StrongPaths/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246237434,"owners_count":20745348,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-29T20:18:06.760Z","updated_at":"2025-03-29T20:18:07.390Z","avatar_url":"https://github.com/ktsu-dev.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# StrongPaths\n\nA library that provides strong typing for common filesystem paths providing compile time feedback and runtime validation.\n\nStrongPaths is a collection of classes derived from `ktsu.StrongStrings` with added functionality and helper methods for filesystem paths.\n\nGet familiar with the [StrongStrings](https://github.com/ktsu-dev/StrongStrings) library to get the most out of StrongPaths.\n\n## Usage\n```csharp\nusing ktsu.StrongPaths;\n\npublic class MyDemoClass\n{\n\tpublic AbsoluteDirectoryPath OutputDir { get; set; } = (AbsoluteDirectoryPath)@\"c:\\output\";\n\n\tpublic void SaveData(RelativeDirectoryPath subDir, FileName fileName)\n\t{\n\t\t// You can use the / operator to combine paths\n\t\tAbsoluteFilePath filePath = OutputDir / subDir / fileName;\n\t\tFile.WriteAllText(filePath, \"Hello, world!\");\n\n\t\t// An AbsoluteDirectoryPath combined with a RelativeDirectoryPath returns an AbsoluteDirectoryPath\n\t\tAbsoluteDirectoryPath newOutputDir = OutputDir / subDir;\n\n\t\t// An AbsoluteDirectoryPath combined with a FileName returns an AbsoluteFilePath\n\t\tAbsoluteFilePath newFilePath = newOutputDir / fileName;\n\n\t\t// You can get a relative path from Absolute/Relative Directory/File paths using the RelativeTo method\n\t\tRelativeDirectoryPath relativePath = newOutputDir.RelativeTo(OutputDir);\n\t\tRelativeFilePath relativeFilePath = newFilePath.RelativeTo(OutputDir);\n\t\tRelativeDirectoryPath relativePath2 = newOutputDir.RelativeTo(filePath);\n\t\tRelativeFilePath relativeFilePath2 = newFilePath.RelativeTo(filePath);\n\t}\n\n\tpublic void Demo()\n\t{\n\t\tstring storeLocation = \"melbourne\";\n\t\tRelativeDirectoryPath storeDir = (RelativeDirectoryPath)$\"store_{storeLocation}\";\n\t\tFileName fileName = (FileName)$\"{DateTime.UtcNow}.json\";\n\t\tSaveData(storeDir, fileName);\n\t}\n}\n\n```\n## Concrete Types\n- `AbsolutePath`\n- `RelativePath`\n- `DirectoryPath`\n- `FilePath`\n- `FileName`\n- `FileExtension`\n- `AbsoluteDirectoryPath`\n- `RelativeDirectoryPath`\n- `AbsoluteFilePath`\n- `RelativeFilePath`\n\n## Abstract Base Classes\nYou can use these abstract base classes to accept a subset of path types in your method parameters:\n- `AnyStrongPath` Accepts any of the concrete types and types derived from them\n- `AnyRelativePath` Accepts `RelativePath`, `RelativeDirectroryPath`, `RelativeFilePath`, and types derived from them\n- `AnyAbsolutePath` Accepts `AbsolutePath`, `AbsoluteDirectroryPath`, `AbsoluteFilePath`, and types derived from them\n- `AnyDirectoryPath` Accepts `DirectoryPath`, `AbsoluteDirectroryPath`, `RelativeDirectroryPath`, and types derived from them\n- `AnyFilePath` Accepts `FilePath`, `AbsoluteFilePath`, `RelativeFilePath`, and types derived from them\n\n```csharp\nusing ktsu.StrongPaths;\n\npublic static class MyDemoClass\n{\n\tpublic static void SaveData(AnyDirectoryPath outputDir, FileName fileName)\n\t{\n\t\t// You can't use the / operator with the abstract base classes because it has no way of knowing which type to return\n\t\t// You have to use the Path.Combine method when using the abstract base classes\n\t\tFilePath filePath = (FilePath)Path.Combine(outputDir, fileName);\n\t\tFile.WriteAllText(filePath, \"Hello, World!\");\n\t}\n\n    public static void Demo()\n\t{\n\t\tstring storeLocation = \"melbourne\";\n\t\tRelativeDirectoryPath storeDir = (RelativeDirectoryPath)$\"store_{storeLocation}\";\n\t\tFileName fileName = (FileName)$\"{DateTime.UtcNow}.json\";\n\t\tSaveData(storeDir, fileName);\n\t}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fktsu-dev%2Fstrongpaths","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fktsu-dev%2Fstrongpaths","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fktsu-dev%2Fstrongpaths/lists"}