{"id":37470346,"url":"https://github.com/spectresystems/spectre.io","last_synced_at":"2026-01-16T07:15:17.002Z","repository":{"id":45878624,"uuid":"279096503","full_name":"spectresystems/spectre.io","owner":"spectresystems","description":"Spectre.IO is a .NET library containing cross-platform abstractions and implementations for file system I/O.","archived":false,"fork":false,"pushed_at":"2025-10-21T12:06:54.000Z","size":298,"stargazers_count":56,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-12-23T13:26:42.862Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/spectresystems.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-07-12T15:47:46.000Z","updated_at":"2025-10-23T23:14:37.000Z","dependencies_parsed_at":"2024-05-29T10:42:39.935Z","dependency_job_id":"d9f09e00-f306-4446-af1a-4e19c761d0d0","html_url":"https://github.com/spectresystems/spectre.io","commit_stats":{"total_commits":30,"total_committers":2,"mean_commits":15.0,"dds":0.09999999999999998,"last_synced_commit":"f6f5bef5147159a514f7fcd006ecad101566ec83"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/spectresystems/spectre.io","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spectresystems%2Fspectre.io","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spectresystems%2Fspectre.io/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spectresystems%2Fspectre.io/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spectresystems%2Fspectre.io/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/spectresystems","download_url":"https://codeload.github.com/spectresystems/spectre.io/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spectresystems%2Fspectre.io/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28478047,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T06:30:42.265Z","status":"ssl_error","status_checked_at":"2026-01-16T06:30:16.248Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":"2026-01-16T07:15:16.225Z","updated_at":"2026-01-16T07:15:16.990Z","avatar_url":"https://github.com/spectresystems.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Spectre.IO\n\n_[![Spectre.IO NuGet Version](https://img.shields.io/nuget/v/spectre.io.svg?style=flat\u0026label=NuGet%3A%20Spectre.IO)](https://www.nuget.org/packages/spectre.io)_\n\nSpectre.IO is a .NET library containing cross-platform abstractions and \nimplementations for IO. It also comes with a library that includes an\nin-memory implementation of a file system to use when writing tests.\n\n## Table of Contents\n\n1. [Usage](#usage)\n2. [Testing](#testing)\n3. [Contributing](#building-from-source)\n5. [License](#license)\n\n## Usage\n\n```csharp\nusing Spectre.IO;\n\npublic bool CheckSomething()\n{\n    // Get the full path to \"foo/hello.txt\" in the current working directory.\n    // Note: A path has no knowledge of the actual file. It's just a convenient\n    // way to work with file system paths since it does things as normalization\n    // automatically.\n    var root = new DirectoryPath(\"foo\").MakeAbsolute(_environment);\n    var path = root.CombineWithFilePath(new FilePath(\"hello.txt\"));\n\n    // Of course, we could also have done this in one step.\n    path = new FilePath(\"foo/hello.txt\").MakeAbsolute(_environment);\n\n    // Now get a file system reference to the file and check if it exist.\n    var file = _fileSystem.GetFile(path);\n    if (file.Exists)\n    {\n        // The file exists.\n        // Does the file not contain the word \"goodbye\"?\n        var contents = GetFileContents(file);\n        if (!contents?.Contains(\"goodbye\") ?? false)\n        {\n            return true;\n        }\n    }\n\n    // The file \"foo/hello.txt\" was not found. Is there a file in any \n    // directory that contains the word \"ten\" or \"tea\"?\n    // That should return true as well.\n    if (_globber.GetFiles(\"**/*te{n|a}*\").Any())\n    {\n        return true;\n    }\n\n    return false;\n}\n\nprivate string GetFileContents(IFile file)\n{\n    using (var stream = file.OpenRead())\n    using (var reader = new StreamReader(stream))\n    {\n        return reader.ReadToEnd();\n    }\n}\n```\n\n## Testing\n\nOne purpose of Spectre.IO is enabling writing tests against code that uses the filesystem in some way. To write tests for the code above, we'll use the FakeFileSystem in Spectre.IO.Testing, an in-memory implementation of a file system.\n\n```csharp\nusing Spectre.IO.Testing;\n\n[Fact]\npublic void Should_Return_False_If_Hello_File_Exists_But_Contains_The_Word_Goodbye()\n{\n    // Given\n    var environment = FakeEnvironment.CreateLinuxEnvironment();\n    var filesystem = new FakeFileSystem(environment);\n    var globber = new Globber(filesystem, environment);\n    var checker = new Checker(filesystem, environment, globber);\n\n    filesystem.CreateFile(\"foo/bar.txt\");\n    filesystem.CreateFile(\"bar/qux.txt\");\n    filesystem.CreateFile(\"foo/hello.txt\").SetTextContent(\"Is this goodbye?\");\n\n    // When\n    var result = checker.CheckSomething();\n\n    // Then\n    result.ShouldBeFalse();\n}\n```\n\n## Building from source\n\nWe're using [Cake](https://github.com/cake-build/cake) as a local dotnet tool for building. \nSo make sure that you've restored Cake by running the following in the repository root:\n\n```\n\u003e dotnet tool restore\n```\n\nAfter that, running the build is as easy as writing:\n\n```\n\u003e dotnet cake\n```\n\n## License\n\nSpectre.IO is provided as-is under the MIT license and is based upon the IO abstractions in \n[Cake](https://github.com/cake-build/cake) that [Patrik Svensson](https://github.com/patriksvensson) \n(the author of this library) previously implemented as part of that project.\n\nFor more information see LICENSE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspectresystems%2Fspectre.io","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspectresystems%2Fspectre.io","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspectresystems%2Fspectre.io/lists"}