[Pkg-owncloud-commits] [ocsync] 07/29: Symlink detection for Win32.
Sandro Knauß
hefee-guest at moszumanska.debian.org
Fri Dec 13 14:26:33 UTC 2013
This is an automated email from the git hooks/post-receive script.
hefee-guest pushed a commit to branch master
in repository ocsync.
commit 22608f13ca16c3d2ba26c9b9e4be42605f1dd4dc
Author: Klaas Freitag <freitag at owncloud.com>
Date: Mon Dec 9 15:19:50 2013 +0100
Symlink detection for Win32.
This fixes https://github.com/owncloud/mirall/issues/1259
---
src/std/c_file.c | 31 +++++++++++++++++++++++++++++++
src/std/c_file.h | 14 +++++++++++++-
src/vio/csync_vio_local.c | 5 +++++
3 files changed, 49 insertions(+), 1 deletion(-)
diff --git a/src/std/c_file.c b/src/std/c_file.c
index b04c05b..61984b3 100644
--- a/src/std/c_file.c
+++ b/src/std/c_file.c
@@ -37,6 +37,37 @@
#include "c_private.h"
+#ifdef _WIN32
+/* check if path is a symlink */
+int c_islink(const char *path) {
+ int re = 0;
+
+ mbchar_t *wpath = 0;
+ DWORD dwAttrs;
+ WIN32_FIND_DATAW FindFileData;
+ HANDLE hFind;
+
+ wpath = c_utf8_to_locale(path);
+
+ dwAttrs = GetFileAttributesW(wpath);
+ if (dwAttrs != INVALID_FILE_ATTRIBUTES) {
+
+ if ((dwAttrs & FILE_ATTRIBUTE_REPARSE_POINT)) {
+ hFind = FindFirstFileW(wpath, &FindFileData );
+ if (hFind != INVALID_HANDLE_VALUE) {
+ if( (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) &&
+ (FindFileData.dwReserved0 & IO_REPARSE_TAG_SYMLINK) ) {
+ re = 1;
+ }
+ }
+ FindClose(hFind);
+ }
+ }
+ c_free_locale_string(wpath);
+ return re;
+}
+#endif
+
/* check if path is a file */
int c_isfile(const char *path) {
csync_stat_t sb;
diff --git a/src/std/c_file.h b/src/std/c_file.h
index 31e5ff9..d952b39 100644
--- a/src/std/c_file.h
+++ b/src/std/c_file.h
@@ -40,12 +40,24 @@
#define BUFFER_SIZE (16 * 1024)
#endif
+#ifdef _WIN32
+/**
+ * @brief Check if a path is a link.
+ *
+ * @param path The path to check.
+ *
+ * @return 1 if the path is a symbolic link, 0 if the path doesn't
+ * exist or is something else.
+ */
+int c_islink(const char *path);
+#endif
+
/**
* @brief Check if a path is a regular file or a link.
*
* @param path The path to check.
*
- * @return 1 if the path is a file, 0 if the path doesn't exist, is a
+ * @return 1 if the path is a file, 0 if the path doesn't exist, is
* something else or can't be accessed.
*/
int c_isfile(const char *path);
diff --git a/src/vio/csync_vio_local.c b/src/vio/csync_vio_local.c
index 4e4e687..facadde 100644
--- a/src/vio/csync_vio_local.c
+++ b/src/vio/csync_vio_local.c
@@ -416,6 +416,11 @@ int csync_vio_local_stat(const char *uri, csync_vio_file_stat_t *buf) {
}
CloseHandle(h);
}
+
+ /* check if it is a symlink on win32 */
+ if (c_islink(uri)) {
+ buf->type = CSYNC_VIO_FILE_TYPE_SYMBOLIC_LINK;
+ }
#else /* non windows platforms: */
/* Both values are only initialized to zero as they are not used in csync */
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/ocsync.git
More information about the Pkg-owncloud-commits
mailing list