mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-09 03:52:19 +02:00
Add Directory.Copy
This commit is contained in:
parent
d46cc8d015
commit
63d5bc07b5
1 changed files with 17 additions and 0 deletions
|
@ -90,6 +90,23 @@ namespace System.IO
|
||||||
return .Ok;
|
return .Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///Copies and overwrites the contents of fromPath into toPath.
|
||||||
|
public static Result<void, Platform.BfpFileResult> Copy(StringView fromPath, StringView toPath)
|
||||||
|
{
|
||||||
|
if(Directory.CreateDirectory(toPath) case .Err(let err))
|
||||||
|
return .Err(err);
|
||||||
|
|
||||||
|
for(var file in Directory.EnumerateFiles(fromPath))
|
||||||
|
if(File.Copy(file.GetFilePath(.. scope .()), scope $"{toPath}/{file.GetFileName(.. scope .())}") case .Err(let err))
|
||||||
|
return .Err(err);
|
||||||
|
|
||||||
|
for(var dir in Directory.EnumerateDirectories(fromPath))
|
||||||
|
if(Directory.Copy(dir.GetFilePath(.. scope .()), scope $"{toPath}/{dir.GetFileName(.. scope .())}") case .Err(let err))
|
||||||
|
return .Err(err);
|
||||||
|
|
||||||
|
return .Ok;
|
||||||
|
}
|
||||||
|
|
||||||
public static void GetCurrentDirectory(String outPath)
|
public static void GetCurrentDirectory(String outPath)
|
||||||
{
|
{
|
||||||
Platform.GetStrHelper(outPath, scope (outPtr, outSize, outResult) =>
|
Platform.GetStrHelper(outPath, scope (outPtr, outSize, outResult) =>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue