{"id":13465734,"url":"https://github.com/dduan/Pathos","last_synced_at":"2025-03-25T16:32:46.898Z","repository":{"id":33084858,"uuid":"134193326","full_name":"dduan/Pathos","owner":"dduan","description":"File management and path analysis for Swift","archived":false,"fork":false,"pushed_at":"2022-05-03T04:05:36.000Z","size":8752,"stargazers_count":118,"open_issues_count":0,"forks_count":6,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-05T16:51:33.364Z","etag":null,"topics":["filesystem","swift","vfs"],"latest_commit_sha":null,"homepage":"","language":"Swift","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/dduan.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["dduan"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2018-05-20T22:54:25.000Z","updated_at":"2025-01-30T13:45:54.000Z","dependencies_parsed_at":"2022-08-07T20:00:19.771Z","dependency_job_id":null,"html_url":"https://github.com/dduan/Pathos","commit_stats":null,"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dduan%2FPathos","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dduan%2FPathos/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dduan%2FPathos/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dduan%2FPathos/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dduan","download_url":"https://codeload.github.com/dduan/Pathos/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245500460,"owners_count":20625586,"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":["filesystem","swift","vfs"],"created_at":"2024-07-31T15:00:34.527Z","updated_at":"2025-03-25T16:32:46.562Z","avatar_url":"https://github.com/dduan.png","language":"Swift","funding_links":["https://github.com/sponsors/dduan"],"categories":["Libs","Files [🔝](#readme)"],"sub_categories":["Files"],"readme":"![Banner](Resources/Assets/Banner.png)\n\nPathos offers cross-platform virtual file system APIs for Swift.\n\nPathos is implement from ground-up with on each OS's native API. It has zero dependencies.\n\nWindows support is currently considered *experimental*.\n\n| Continuous Integration |\n|-|\n|[![Amazon Linux 2](https://github.com/dduan/Pathos/workflows/Amazon%20Linux%202/badge.svg)](https://github.com/dduan/Pathos/actions?query=workflow%3A%22Amazon+Linux+2%22)|\n|[![macOS 11.15](https://github.com/dduan/Pathos/workflows/macOS%2011.15/badge.svg)](https://github.com/dduan/Pathos/actions?query=workflow%3A%22macOS+11.15%22)|\n|[![Ubuntu Bionic](https://github.com/dduan/Pathos/workflows/Ubuntu%20Bionic/badge.svg)](https://github.com/dduan/Pathos/actions?query=workflow%3A%22Ubuntu+Bionic%22)|\n|[![Ubuntu Focal](https://github.com/dduan/Pathos/workflows/Ubuntu%20Focal/badge.svg)](https://github.com/dduan/Pathos/actions?query=workflow%3A%22Ubuntu+Focal%22)|\n|[![Windows 2019](https://github.com/dduan/Pathos/workflows/Windows%202019/badge.svg) (Experimental)](https://github.com/dduan/Pathos/actions?query=workflow%3A%22Windows+2019%22)\n\nFor a taste of Pathos, let's generate a static site from Markdown!\n\n```swift\nimport Pathos\n\n// Set the CWD and execute a closure\ntry Path(\"markdown-source-dir\").asWorkingDirectory {\n    // Build the site in a unique, temporary directory\n    let temporaryRoot = try Path.makeTemporaryDirectory()\n    \n    // Joining path components that works across OSes.\n    // E.g. `articles/**/*.md` on POSIX systems.\n    let pattern = Path(\"articles\") + \"**\" + \"*.md\"\n    \n    // Use glob to find files that matches the pattern\n    for markdown in try pattern.glob() {\n        // path/to/file.md =\u003e path/to/file\n        let url = markdown.base\n        \n        // path that contains index.html\n        let htmlDirectory = temporaryRoot + url\n        \n        // make a directory, including multiple levels\n        try htmlDirectory.makeDirectory(withParents: true)\n        \n        // read content of a file\n        let source = try markdown.readUTF8String()\n        \n        // write out the html, imagine `markdown2html` exists\n        try (htmlDirectory + \"index.html\").write(utf8: markdown2html(source))\n    }\n\n    // all done! move the built site to output directory\n    try temporaryRoot.move(to: \"output\")\n}\n// CWD is restored after the closure is done\n```\n\nAs you can see, Pathos offers a whole suite of APIs for inspecting and manipulating the file system. Programs built with Pathos compile and work on all supported OS without the need to use `#if OS()` in the source.\n\nThere are more [Examples](./Examples) for the curious.\n\n## Installation\n\n#### With [SwiftPM](https://swift.org/package-manager)\n\n```swift\n.package(url: \"http://github.com/dduan/Pathos\", from: \"0.4.2\")\n```\n\n## Documentation\n\n1. [User Guide][] - A tour of Pathos for introduction purposes.\n2. [API Refererence][] - Complete reference to Pathos public APIs.\n3. [Design][] - Answers for why an API is designed as such.\n4. [Change Log][] - Change logs for all Pathos versions.\n\nYou may also checkout the [Example apps][].\n\n## License\n\nPathos is released under the MIT license. See [LICENSE.md](./LICENSE.md)\n\n\n[Design]: Documentation/design.md\n[Change Log]: CHANGELOG.md\n[User Guide]: Documentation/UserGuide.md\n[API Refererence]: Documentation/APIs/README.md\n[Example apps]: ./Examples\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdduan%2FPathos","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdduan%2FPathos","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdduan%2FPathos/lists"}