No description
This repository has been archived on 2023-02-02. You can view files and clone it, but cannot push or open issues or pull requests.
Find a file
2021-12-06 23:47:21 -06:00
.gitlab fix: fixed the Git root searching plus added tests 2021-12-06 23:37:10 -06:00
.husky feat: initial commit 2021-09-11 00:54:27 -05:00
src fix: fixed the Git root searching plus added tests 2021-12-06 23:37:10 -06:00
tests/MfGames.IO.Tests tests: fixing missing JUnit logger 2021-12-06 23:47:21 -06:00
.editorconfig feat: initial commit 2021-09-11 00:54:27 -05:00
.envrc build: switching to a Nix-based setup 2021-12-06 17:52:35 -06:00
.gitignore tests: fixing missing JUnit logger 2021-12-06 23:47:21 -06:00
CHANGELOG.md chore(release): v1.2.2 [skip ci] 2021-12-07 05:20:33 +00:00
commitlint.config.js build: switching to a Nix-based setup 2021-12-06 17:52:35 -06:00
flake.lock build: switching to a Nix-based setup 2021-12-06 17:52:35 -06:00
flake.nix build: switching to a Nix-based setup 2021-12-06 17:52:35 -06:00
LICENSE.txt feat: initial commit 2021-09-11 00:54:27 -05:00
MfGames.IO.sln fix: fixed the Git root searching plus added tests 2021-12-06 23:37:10 -06:00
MfGames.IO.sln.DotSettings feat: initial commit 2021-09-11 00:54:27 -05:00
package-lock.json chore(release): v1.2.2 [skip ci] 2021-12-07 05:20:33 +00:00
package.json chore(release): v1.2.2 [skip ci] 2021-12-07 05:20:33 +00:00
README.md fix: fixed the Git root searching plus added tests 2021-12-06 23:37:10 -06:00
release.config.js build: switching to a Nix-based setup 2021-12-06 17:52:35 -06:00

MfGames.IO CIL

This a small collection of classes and extensions to make working with System.IO a little bit easier.

Installation

At the moment, this library is not on NuGet.org. Instead, it is hosted at MyGet.

dotnet add package MfGames.IO --source https://www.myget.org/F/mfgames/api/v3/index.json 

The repository can also be added to a project by setting the NuGet.Config file.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
    <add key="mfgames" value="https://www.myget.org/F/mfgames/api/v3/index.json" protocolVersion="3" />
  </packageSources>
</configuration>

Extensions

Assembly Extensions

DirectoryInfo? GetDirectory(this Assembly? assembly)

Gets a directory containing the assembly directory.

FileInfo? GetFile(this Assembly? assembly)

Gets a file representing the assembly's Location property or null.

DirectoryInfo Extensions

DirectoryInfo? CreateIfMissing(this DirectoryInfo? directory)

Creates directory if it doesn't exist and directory is not null. This will also create any parent directories to duplicate the mkdir -p directory functionality that inspired it.

DirectoryInfo? FindGitRoot(this DirectoryInfo?)

Finds the Git root from the given directory, using FindSelfOrParent.

DirectoryInfo? FindParent(this DirectoryInfo?, Func<DirectoryInfo, bool> match)

Finds a parent directory that returns true from the given match. This does not check the given directory, but only parents. If none are found, this returns null.

DirectoryInfo? FindSelfOrParent(this DirectoryInfo?, Func<DirectoryInfo, bool> match)

Finds a parent directory that returns true from the given match. This checks the given directory before going to parents. If none are found, this returns null.

DirectoryInfo GetDirectory(this DirectoryInfo directory, string[] paths)

The equivalent of new DirectoryInfo(Path.Combine(directory.FullName, ...paths)).

FileInfo GetFile(this DirectoryInfo directory, string[] paths)

The equivalent of new FileInfo(Path.Combine(directory.FullName, ...paths)).

bool IsGitRoot(this DirectoryInfo? directory)

Returns true if the given directory is non-null and contains the .git folder. Otherwise, returns false.

FileInfo Extensions

string ReadAllText(this FileInfo file)

The same as File.ReadAllText(file.GetFullPath).

string ReadAllText(this FileInfo file, Encoding encoding)

The same as File.ReadAllText(file.GetFullPath, encoding).

void WriteAllText(this FileInfo file, string text)

The same as File.WriteAllText(file.GetFullPath, text).

void WriteAllText(this FileInfo file, string text, Encoding encoding)

The same as File.WriteAllText(file.GetFullPath, text, encoding).

Type Extensions

DirectoryInfo? GetDirectory(this Type? type)

Gets a directory containing the type's assembly directory.

FileInfo? GetFile(this Type? type)

Gets a file representing the type's assembly's Location property or null.