Skip to content

Commit

Permalink
Directory/FilePath.MakeAbsolute()
Browse files Browse the repository at this point in the history
  • Loading branch information
Noggog committed Jan 14, 2024
1 parent cf74eba commit 6db9968
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Noggog.CSharpExt/Structs/FileSystems/DirectoryPath.cs
Expand Up @@ -47,6 +47,12 @@ public DirectoryPath(string relativePath)
_fullPath = relativePath == string.Empty ? string.Empty : System.IO.Path.GetFullPath(relativePath);
}

private DirectoryPath(string? originalPath, string? fullPath)
{
_originalPath = originalPath;
_fullPath = fullPath;
}

public bool CheckExists(IFileSystem? fs = null) => fs.GetOrDefault().Directory.Exists(Path);

public static bool operator ==(DirectoryPath lhs, DirectoryPath rhs)
Expand Down Expand Up @@ -195,6 +201,11 @@ public string GetRelativePathTo(FilePath relativeTo)
recursive: recursive);
}

public DirectoryPath MakeAbsolute()
{
return new DirectoryPath(_fullPath, _fullPath);
}

public static implicit operator DirectoryPath(DirectoryInfo info)
{
return new DirectoryPath(info.FullName);
Expand Down
11 changes: 11 additions & 0 deletions Noggog.CSharpExt/Structs/FileSystems/FilePath.cs
Expand Up @@ -38,6 +38,12 @@ public struct FilePath : IEquatable<FilePath>, IPath
[IgnoreDataMember]
public bool Exists => CheckExists();

private FilePath(string? fullPath, string? originalPath)
{
_fullPath = fullPath;
_originalPath = originalPath;
}

public FilePath(string relativePath)
{
relativePath = IFileSystemExt.CleanDirectorySeparators(relativePath);
Expand Down Expand Up @@ -112,6 +118,11 @@ public Stream OpenRead(IFileSystem? fileSystem = null)
return fileSystem.GetOrDefault().FileStream.Create(Path, FileMode.Open, FileAccess.Read, FileShare.Read);

Check warning on line 118 in Noggog.CSharpExt/Structs/FileSystems/FilePath.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, Noggog.Autofac)

'IFileStreamFactory.Create(string, FileMode, FileAccess, FileShare)' is obsolete: 'Use `IFileStreamFactory.New(string, FileMode, FileAccess, FileShare)` instead.'

Check warning on line 118 in Noggog.CSharpExt/Structs/FileSystems/FilePath.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, Noggog.CSharpExt)

'IFileStreamFactory.Create(string, FileMode, FileAccess, FileShare)' is obsolete: 'Use `IFileStreamFactory.New(string, FileMode, FileAccess, FileShare)` instead.'

Check warning on line 118 in Noggog.CSharpExt/Structs/FileSystems/FilePath.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, Noggog.CSharpExt.Json)

'IFileStreamFactory.Create(string, FileMode, FileAccess, FileShare)' is obsolete: 'Use `IFileStreamFactory.New(string, FileMode, FileAccess, FileShare)` instead.'

Check warning on line 118 in Noggog.CSharpExt/Structs/FileSystems/FilePath.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, Noggog.Testing)

'IFileStreamFactory.Create(string, FileMode, FileAccess, FileShare)' is obsolete: 'Use `IFileStreamFactory.New(string, FileMode, FileAccess, FileShare)` instead.'

Check warning on line 118 in Noggog.CSharpExt/Structs/FileSystems/FilePath.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, CSharpExt.UnitTests)

'IFileStreamFactory.Create(string, FileMode, FileAccess, FileShare)' is obsolete: 'Use `IFileStreamFactory.New(string, FileMode, FileAccess, FileShare)` instead.'

Check warning on line 118 in Noggog.CSharpExt/Structs/FileSystems/FilePath.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest, Noggog.Autofac)

'IFileStreamFactory.Create(string, FileMode, FileAccess, FileShare)' is obsolete: 'Use `IFileStreamFactory.New(string, FileMode, FileAccess, FileShare)` instead.'

Check warning on line 118 in Noggog.CSharpExt/Structs/FileSystems/FilePath.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest, Noggog.CSharpExt)

'IFileStreamFactory.Create(string, FileMode, FileAccess, FileShare)' is obsolete: 'Use `IFileStreamFactory.New(string, FileMode, FileAccess, FileShare)` instead.'

Check warning on line 118 in Noggog.CSharpExt/Structs/FileSystems/FilePath.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest, Noggog.CSharpExt.Json)

'IFileStreamFactory.Create(string, FileMode, FileAccess, FileShare)' is obsolete: 'Use `IFileStreamFactory.New(string, FileMode, FileAccess, FileShare)` instead.'

Check warning on line 118 in Noggog.CSharpExt/Structs/FileSystems/FilePath.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest, CSharpExt.UnitTests)

'IFileStreamFactory.Create(string, FileMode, FileAccess, FileShare)' is obsolete: 'Use `IFileStreamFactory.New(string, FileMode, FileAccess, FileShare)` instead.'

Check warning on line 118 in Noggog.CSharpExt/Structs/FileSystems/FilePath.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest, Noggog.CSharpExt.Json)

'IFileStreamFactory.Create(string, FileMode, FileAccess, FileShare)' is obsolete: 'Use `IFileStreamFactory.New(string, FileMode, FileAccess, FileShare)` instead.'

Check warning on line 118 in Noggog.CSharpExt/Structs/FileSystems/FilePath.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest, Noggog.CSharpExt)

'IFileStreamFactory.Create(string, FileMode, FileAccess, FileShare)' is obsolete: 'Use `IFileStreamFactory.New(string, FileMode, FileAccess, FileShare)` instead.'

Check warning on line 118 in Noggog.CSharpExt/Structs/FileSystems/FilePath.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest, Noggog.CSharpExt.Windows)

'IFileStreamFactory.Create(string, FileMode, FileAccess, FileShare)' is obsolete: 'Use `IFileStreamFactory.New(string, FileMode, FileAccess, FileShare)` instead.'

Check warning on line 118 in Noggog.CSharpExt/Structs/FileSystems/FilePath.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest, Noggog.Autofac)

'IFileStreamFactory.Create(string, FileMode, FileAccess, FileShare)' is obsolete: 'Use `IFileStreamFactory.New(string, FileMode, FileAccess, FileShare)` instead.'

Check warning on line 118 in Noggog.CSharpExt/Structs/FileSystems/FilePath.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest, Noggog.WPF)

'IFileStreamFactory.Create(string, FileMode, FileAccess, FileShare)' is obsolete: 'Use `IFileStreamFactory.New(string, FileMode, FileAccess, FileShare)` instead.'

Check warning on line 118 in Noggog.CSharpExt/Structs/FileSystems/FilePath.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest, Noggog.Testing)

'IFileStreamFactory.Create(string, FileMode, FileAccess, FileShare)' is obsolete: 'Use `IFileStreamFactory.New(string, FileMode, FileAccess, FileShare)` instead.'

Check warning on line 118 in Noggog.CSharpExt/Structs/FileSystems/FilePath.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest, Noggog.Testing)

'IFileStreamFactory.Create(string, FileMode, FileAccess, FileShare)' is obsolete: 'Use `IFileStreamFactory.New(string, FileMode, FileAccess, FileShare)` instead.'

Check warning on line 118 in Noggog.CSharpExt/Structs/FileSystems/FilePath.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest, CSharpExt.UnitTests)

'IFileStreamFactory.Create(string, FileMode, FileAccess, FileShare)' is obsolete: 'Use `IFileStreamFactory.New(string, FileMode, FileAccess, FileShare)` instead.'
}

public FilePath MakeAbsolute()
{
return new FilePath(_fullPath, _fullPath);
}

public static implicit operator FilePath(FileInfo info)
{
return new FilePath(info.FullName);
Expand Down

0 comments on commit 6db9968

Please sign in to comment.