Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add file move to FileIO #1175

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions LanguageExt.Sys/Live/FileIO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ public Unit Copy(string fromPath, string toPath, bool overwrite = false)
return default;
}

/// <inheritdoc/>
public Unit Move(string fromPath, string toPath)
{
File.Move(fromPath, toPath);
return default;
}

#if NET5PLUS
/// <summary>
/// Append lines to the end of a file
Expand Down
11 changes: 11 additions & 0 deletions LanguageExt.Sys/Sys/IO/File.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,17 @@ public static class File<RT>
public static Eff<RT, Unit> copy(string fromPath, string toPath, bool overwrite = false) =>
default(RT).FileEff.Map(e => e.Copy(fromPath, toPath, overwrite));

/// <summary>
/// Move file
/// </summary>
/// <param name="fromPath">Source path</param>
/// <param name="toPath">Destination path</param>
/// <typeparam name="RT">Runtime</typeparam>
/// <returns>Unit</returns>
[Pure, MethodImpl(AffOpt.mops)]
public static Eff<RT, Unit> move(string fromPath, string toPath) =>
default(RT).FileEff.Map(e => e.Move(fromPath, toPath));

/// <summary>
/// Append lines to the end of the file provided
/// </summary>
Expand Down
4 changes: 4 additions & 0 deletions LanguageExt.Sys/Test/FileIO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ namespace LanguageExt.Sys.Test
public Unit Copy(string fromPath, string toPath, bool overwrite = false) =>
fs.CopyFile(fromPath, toPath, overwrite, now);

/// <inheritdoc/>
public Unit Move(string fromPath, string toPath) =>
fs.Move(fromPath, toPath, now);

/// <summary>
/// Append lines to the end of a file
/// </summary>
Expand Down
6 changes: 6 additions & 0 deletions LanguageExt.Sys/Traits/FileIO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ public interface FileIO
/// </summary>
Unit Copy(string fromPath, string toPath, bool overwrite = false);

/// <summary>
/// Move file from one place to another
/// </summary>
/// <exception cref="IOException">The <paramref name="toPath"/> exists or <paramref name="fromPath"/> was not found.</exception>
Unit Move(string fromPath, string toPath);

/// <summary>
/// Append lines to the end of a file
/// </summary>
Expand Down