aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.FileSystem/FileSystemManager.cs
diff options
context:
space:
mode:
authorVictoria Plitt <Victoria.Plitt@twine-s.com>2020-03-23 10:36:13 +0200
committerVictoria Plitt <Victoria.Plitt@twine-s.com>2020-03-23 10:36:13 +0200
commit35842a2b231af79f34c7e8685bd1ca8313b1a122 (patch)
tree45680658dd7a03333a762c8a0b7b459e77a94b64 /Software/Visual_Studio/Tango.FileSystem/FileSystemManager.cs
parentc025ab482326b6809e40e4e35026b58488795df3 (diff)
parent3c4ff5beaa41a376ce42fa400d36d7a5a74330ec (diff)
downloadTango-35842a2b231af79f34c7e8685bd1ca8313b1a122.tar.gz
Tango-35842a2b231af79f34c7e8685bd1ca8313b1a122.zip
Merge branch 'master' of https://twinetfs.visualstudio.com/Tango/_git/Tango
Diffstat (limited to 'Software/Visual_Studio/Tango.FileSystem/FileSystemManager.cs')
-rw-r--r--Software/Visual_Studio/Tango.FileSystem/FileSystemManager.cs68
1 files changed, 68 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Tango.FileSystem/FileSystemManager.cs b/Software/Visual_Studio/Tango.FileSystem/FileSystemManager.cs
index 44c8f1901..c18df97c9 100644
--- a/Software/Visual_Studio/Tango.FileSystem/FileSystemManager.cs
+++ b/Software/Visual_Studio/Tango.FileSystem/FileSystemManager.cs
@@ -5,6 +5,7 @@ using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
+using Tango.Core.Helpers;
using Tango.FileSystem.Network;
namespace Tango.FileSystem
@@ -91,6 +92,28 @@ namespace Tango.FileSystem
};
}
+ public Task<FileSystemItem> GetFolder(String path)
+ {
+ return Task.Factory.StartNew<FileSystemItem>(() =>
+ {
+ return FileSystemItem.FromDTO(GetFolder(new GetFileSystemItemRequest()
+ {
+ Path = path,
+ }));
+ });
+ }
+
+ public Task<FileSystemItem> GetFolder(Environment.SpecialFolder specialFolder)
+ {
+ return Task.Factory.StartNew<FileSystemItem>(() =>
+ {
+ return FileSystemItem.FromDTO(GetFolder(new GetFileSystemItemRequest()
+ {
+ SpecialFolder = specialFolder
+ }));
+ });
+ }
+
public void Delete(String path)
{
if (Directory.Exists(path))
@@ -106,5 +129,50 @@ namespace Tango.FileSystem
throw new FileNotFoundException("Could not locate the specified file or directory.");
}
}
+
+ public void Move(MoveRequest request)
+ {
+ if (Directory.Exists(request.Destination))
+ {
+ throw new IOException($"'{Path.GetFileName(request.Destination)}' already exists on the target folder.");
+ }
+
+ if (File.Exists(request.Source))
+ {
+ File.Move(request.Source, request.Destination);
+ }
+ else if (Directory.Exists(request.Source))
+ {
+ Directory.Move(request.Source, request.Destination);
+ }
+ else
+ {
+ throw new FileNotFoundException("Could not locate the source file or folder.");
+ }
+ }
+
+ public void Copy(CopyRequest request)
+ {
+ if (File.Exists(request.Source))
+ {
+ if (request.Source == request.Destination)
+ {
+ while (File.Exists(request.Destination))
+ {
+ request.Destination = Path.Combine(Path.GetDirectoryName(request.Destination), Path.GetFileNameWithoutExtension(request.Destination)) + " copy" + Path.GetExtension(request.Destination);
+ }
+ }
+ File.Copy(request.Source, request.Destination, true);
+ }
+ else if (Directory.Exists(request.Source))
+ {
+ Directory.CreateDirectory(Path.GetDirectoryName(request.Destination));
+ PathHelper.CopyDirectory(request.Source, request.Destination, true);
+ }
+ else
+ {
+ throw new FileNotFoundException("Could not locate the source file or folder.");
+ }
+ }
}
}