aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.FileSystem/FileSystemManager.cs
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2020-03-22 00:04:44 +0200
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2020-03-22 00:04:44 +0200
commitd48b2d23515d06a21ad241380986bf8f31773195 (patch)
treeebbb6b2bc874773ec58a4c999a1f6eb61a572592 /Software/Visual_Studio/Tango.FileSystem/FileSystemManager.cs
parent8c094ceeaa538fdb5dc1d69b6ac73f8574cecb66 (diff)
downloadTango-d48b2d23515d06a21ad241380986bf8f31773195.tar.gz
Tango-d48b2d23515d06a21ad241380986bf8f31773195.zip
Implemented WebRtcTransportAdapter.
Implemented FileSystem via WebRTC. Improved FileSystemControl keyboard control. Implemented FileSystemControl context menu. Improved Transported custom request handler registration. Implemented FS copy/move/delete. Implemented InputBox.
Diffstat (limited to 'Software/Visual_Studio/Tango.FileSystem/FileSystemManager.cs')
-rw-r--r--Software/Visual_Studio/Tango.FileSystem/FileSystemManager.cs46
1 files changed, 46 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Tango.FileSystem/FileSystemManager.cs b/Software/Visual_Studio/Tango.FileSystem/FileSystemManager.cs
index 44c8f1901..b8e59c322 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
@@ -106,5 +107,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.");
+ }
+ }
}
}