summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/android.cpp5
-rw-r--r--core/dive.h2
-rw-r--r--core/git-access.c4
-rw-r--r--core/linux.c5
-rw-r--r--core/windows.c12
-rw-r--r--tests/testgitstorage.cpp1
6 files changed, 27 insertions, 2 deletions
diff --git a/core/android.cpp b/core/android.cpp
index bb9dc5cd8..103f18866 100644
--- a/core/android.cpp
+++ b/core/android.cpp
@@ -176,6 +176,11 @@ int subsurface_access(const char *path, int mode)
return access(path, mode);
}
+int subsurface_stat(const char* path, struct stat* buf)
+{
+ return stat(path, buf);
+}
+
struct zip *subsurface_zip_open_readonly(const char *path, int flags, int *errorp)
{
return zip_open(path, flags, errorp);
diff --git a/core/dive.h b/core/dive.h
index ecb3240c1..ba92e1083 100644
--- a/core/dive.h
+++ b/core/dive.h
@@ -8,6 +8,7 @@
#include <zip.h>
#include <sqlite3.h>
#include <string.h>
+#include <sys/stat.h>
#include "divesite.h"
/* Windows has no MIN/MAX macros - so let's just roll our own */
@@ -728,6 +729,7 @@ extern int subsurface_open(const char *path, int oflags, mode_t mode);
extern FILE *subsurface_fopen(const char *path, const char *mode);
extern void *subsurface_opendir(const char *path);
extern int subsurface_access(const char *path, int mode);
+extern int subsurface_stat(const char* path, struct stat* buf);
extern struct zip *subsurface_zip_open_readonly(const char *path, int flags, int *errorp);
extern int subsurface_zip_close(struct zip *zip);
extern void subsurface_console_init(bool dedicated, bool logfile);
diff --git a/core/git-access.c b/core/git-access.c
index 458a7dd9a..b95606d86 100644
--- a/core/git-access.c
+++ b/core/git-access.c
@@ -768,7 +768,7 @@ static struct git_repository *get_remote_repo(const char *localdir, const char *
}
git_storage_update_progress(false, "start git interaction");
/* Do we already have a local cache? */
- if (!stat(localdir, &st)) {
+ if (!subsurface_stat(localdir, &st)) {
if (!S_ISDIR(st.st_mode)) {
if (is_subsurface_cloud)
(void)cleanup_local_cache(remote, branch);
@@ -934,7 +934,7 @@ struct git_repository *is_git_repository(const char *filename, const char **bran
return repo;
}
- if (stat(loc, &st) < 0 || !S_ISDIR(st.st_mode)) {
+ if (subsurface_stat(loc, &st) < 0 || !S_ISDIR(st.st_mode)) {
free(loc);
free(branch);
return dummy_git_repository;
diff --git a/core/linux.c b/core/linux.c
index bd6bbe2ab..5c9726750 100644
--- a/core/linux.c
+++ b/core/linux.c
@@ -204,6 +204,11 @@ int subsurface_access(const char *path, int mode)
return access(path, mode);
}
+int subsurface_stat(const char* path, struct stat* buf)
+{
+ return stat(path, buf);
+}
+
struct zip *subsurface_zip_open_readonly(const char *path, int flags, int *errorp)
{
return zip_open(path, flags, errorp);
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
diff --git a/tests/testgitstorage.cpp b/tests/testgitstorage.cpp
index 080ba49c3..aaa6bd8da 100644
--- a/tests/testgitstorage.cpp
+++ b/tests/testgitstorage.cpp
@@ -64,6 +64,7 @@ void TestGitStorage::testGitStorageLocal_data()
// test different path we may encounter (since storage depends on user name)
QTest::addColumn<QString>("testDirName");
QTest::newRow("ASCII path") << "./gittest";
+ QTest::newRow("Non ASCII path") << "./gittest_éèêôàüäößíñóúäåöø";
}
void TestGitStorage::testGitStorageLocal()