aboutsummaryrefslogtreecommitdiff
path: root/sftp/request_windows.go
diff options
context:
space:
mode:
Diffstat (limited to 'sftp/request_windows.go')
-rw-r--r--sftp/request_windows.go44
1 files changed, 44 insertions, 0 deletions
diff --git a/sftp/request_windows.go b/sftp/request_windows.go
new file mode 100644
index 0000000..1f6d3df
--- /dev/null
+++ b/sftp/request_windows.go
@@ -0,0 +1,44 @@
+package sftp
+
+import (
+ "path"
+ "path/filepath"
+ "syscall"
+)
+
+func fakeFileInfoSys() interface{} {
+ return syscall.Win32FileAttributeData{}
+}
+
+func testOsSys(sys interface{}) error {
+ return nil
+}
+
+func toLocalPath(p string) string {
+ lp := filepath.FromSlash(p)
+
+ if path.IsAbs(p) {
+ tmp := lp
+ for len(tmp) > 0 && tmp[0] == '\\' {
+ tmp = tmp[1:]
+ }
+
+ if filepath.IsAbs(tmp) {
+ // If the FromSlash without any starting slashes is absolute,
+ // then we have a filepath encoded with a prefix '/'.
+ // e.g. "/C:/Windows" to "C:\\Windows"
+ return tmp
+ }
+
+ tmp += "\\"
+
+ if filepath.IsAbs(tmp) {
+ // If the FromSlash without any starting slashes but with extra end slash is absolute,
+ // then we have a filepath encoded with a prefix '/' and a dropped '/' at the end.
+ // e.g. "/C:" to "C:\\"
+ return tmp
+ }
+ }
+
+ return lp
+}