mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 19:48:20 +02:00
Copy fixup
This commit is contained in:
parent
8313fdf2d8
commit
cb1e3ec49f
1 changed files with 6 additions and 12 deletions
|
@ -90,20 +90,14 @@ namespace System.IO
|
|||
return .Ok;
|
||||
}
|
||||
|
||||
///Copies and overwrites the contents of fromPath into toPath.
|
||||
/// 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);
|
||||
|
||||
Try!(Directory.CreateDirectory(toPath));
|
||||
for (var file in Directory.EnumerateFiles(fromPath))
|
||||
Try!(File.Copy(file.GetFilePath(.. scope .()), file.GetFileName(.. scope $"{toPath}/")));
|
||||
for (var dir in Directory.EnumerateDirectories(fromPath))
|
||||
Try!(Directory.Copy(dir.GetFilePath(.. scope .()), dir.GetFileName(.. scope $"{toPath}/")));
|
||||
return .Ok;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue