summaryrefslogtreecommitdiffstats
path: root/core/windows.c
diff options
context:
space:
mode:
authorGravatar Jeremie Guichard <djebrest@gmail.com>2017-02-24 14:06:48 +0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-02-24 01:10:22 -0800
commit5ed93a9d9e7d35ab680ba763aa0c2e8302ef6b08 (patch)
treebcee6fd3501bc44a06a5856c864f4bfbbc8be7f0 /core/windows.c
parent5640a6a83951faefda0f22594044a34cb385e9fd (diff)
downloadsubsurface-5ed93a9d9e7d35ab680ba763aa0c2e8302ef6b08.tar.gz
Fix "Load/Save to cloudstorage" for non-ASCII user names
On Windows that would fail because stat() doesn't deal well with our utf8 strings. Added new subsurface_stat() portability function to replace stat(). Added Windows implementation of subsurface_stat() using wstat(), with conversion to ut16 of the inputed path. Other platform implementations (linux, android) make use of the normal stat(). Added non ASCII test case in TestGitStorage::testGitStorageLocal() Signed-off-by: Jeremie Guichard <djebrest@gmail.com>
Diffstat (limited to 'core/windows.c')
-rw-r--r--core/windows.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/core/windows.c b/core/windows.c
index a94d7dda5..c767cbeda 100644
--- a/core/windows.c
+++ b/core/windows.c
@@ -346,6 +346,18 @@ int subsurface_access(const char *path, int mode)
return ret;
}
+int subsurface_stat(const char* path, struct stat* buf)
+{
+ int ret = -1;
+ if (!path)
+ return ret;
+ wchar_t *wpath = utf8_to_utf16(path);
+ if (wpath)
+ ret = wstat(wpath, buf);
+ free((void *)wpath);
+ return ret;
+}
+
#ifndef O_BINARY
#define O_BINARY 0
#endif