From 8f488a68ad0b7e61e6cdf591f6b17aac8d56361a Mon Sep 17 00:00:00 2001 From: ubbelol Date: Wed, 24 Aug 2016 15:48:13 +0200 Subject: [PATCH 1/3] Add support for forward slashes in file manager --- Server/Forms/FrmFileManager.cs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/Server/Forms/FrmFileManager.cs b/Server/Forms/FrmFileManager.cs index 35742060..e1d9498a 100644 --- a/Server/Forms/FrmFileManager.cs +++ b/Server/Forms/FrmFileManager.cs @@ -35,8 +35,25 @@ public FrmFileManager(Client c) private string GetAbsolutePath(string item) { + if (!string.IsNullOrEmpty(_currentDir) && _currentDir[0] == '/') + return Path.Combine(_currentDir, item + '/'); + return Path.GetFullPath(Path.Combine(_currentDir, item)); } + + private void NavigateUp() + { + if (!string.IsNullOrEmpty(_currentDir) && _currentDir[0] == '/') + { + if (_currentDir.LastIndexOf('/') > 0) + { + _currentDir = _currentDir.TrimEnd('/'); + SetCurrentDir(_currentDir.Remove(_currentDir.LastIndexOf('/') + 1)); + } + } + else + SetCurrentDir(GetAbsolutePath(@"..\")); + } private void FrmFileManager_Load(object sender, EventArgs e) { @@ -71,7 +88,7 @@ private void lstDirectory_DoubleClick(object sender, EventArgs e) switch (type) { case PathType.Back: - SetCurrentDir(Path.GetFullPath(Path.Combine(_currentDir, @"..\"))); + NavigateUp(); RefreshDirectory(); break; case PathType.Directory: From 81f45fdf8a42ed79e783a3ac76cd2a0a9ab47626 Mon Sep 17 00:00:00 2001 From: ubbelol Date: Wed, 24 Aug 2016 15:51:13 +0200 Subject: [PATCH 2/3] Fix indentation --- Server/Forms/FrmFileManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Server/Forms/FrmFileManager.cs b/Server/Forms/FrmFileManager.cs index e1d9498a..cdd0bd2a 100644 --- a/Server/Forms/FrmFileManager.cs +++ b/Server/Forms/FrmFileManager.cs @@ -40,8 +40,8 @@ private string GetAbsolutePath(string item) return Path.GetFullPath(Path.Combine(_currentDir, item)); } - - private void NavigateUp() + + private void NavigateUp() { if (!string.IsNullOrEmpty(_currentDir) && _currentDir[0] == '/') { From 93b87a7f62af84cdddf0c38de5fe7b6792e50ad3 Mon Sep 17 00:00:00 2001 From: ubbelol Date: Thu, 25 Aug 2016 18:03:49 +0200 Subject: [PATCH 3/3] fix trailing forward-slash --- Server/Forms/FrmFileManager.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Server/Forms/FrmFileManager.cs b/Server/Forms/FrmFileManager.cs index cdd0bd2a..59534a68 100644 --- a/Server/Forms/FrmFileManager.cs +++ b/Server/Forms/FrmFileManager.cs @@ -36,7 +36,10 @@ public FrmFileManager(Client c) private string GetAbsolutePath(string item) { if (!string.IsNullOrEmpty(_currentDir) && _currentDir[0] == '/') - return Path.Combine(_currentDir, item + '/'); + if (_currentDir.Length == 1) + return Path.Combine(_currentDir, item); + else + return Path.Combine(_currentDir + '/', item); return Path.GetFullPath(Path.Combine(_currentDir, item)); } @@ -47,9 +50,13 @@ private void NavigateUp() { if (_currentDir.LastIndexOf('/') > 0) { + _currentDir = _currentDir.Remove(_currentDir.LastIndexOf('/') + 1); _currentDir = _currentDir.TrimEnd('/'); - SetCurrentDir(_currentDir.Remove(_currentDir.LastIndexOf('/') + 1)); } + else + _currentDir = "/"; + + SetCurrentDir(_currentDir); } else SetCurrentDir(GetAbsolutePath(@"..\"));