summaryrefslogtreecommitdiff
path: root/file_io
diff options
context:
space:
mode:
authorbojan <bojan@13f79535-47bb-0310-9956-ffa450edef68>2008-07-25 00:17:04 +0000
committerbojan <bojan@13f79535-47bb-0310-9956-ffa450edef68>2008-07-25 00:17:04 +0000
commit3f2c60077a406fdf0d9bd0a5b8756388da6f563a (patch)
tree31bec45d0db517020fac20f3aca541ab72c7954a /file_io
parent6f8c70435216888d2de2d66828d5c08c7b83fc39 (diff)
downloadlibapr-3f2c60077a406fdf0d9bd0a5b8756388da6f563a.tar.gz
Add apr_file_link() function.
PR 44841. Patch by Mark Heily <mark heily.com> git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@679630 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'file_io')
-rw-r--r--file_io/unix/copy.c10
-rw-r--r--file_io/win32/open.c30
2 files changed, 40 insertions, 0 deletions
diff --git a/file_io/unix/copy.c b/file_io/unix/copy.c
index 3a1c59a62..d8c1702d7 100644
--- a/file_io/unix/copy.c
+++ b/file_io/unix/copy.c
@@ -116,3 +116,13 @@ APR_DECLARE(apr_status_t) apr_file_append(const char *from_path,
perms,
pool);
}
+
+APR_DECLARE(apr_status_t) apr_file_link(const char *from_path,
+ const char *to_path)
+{
+ if (link(from_path, to_path) == -1) {
+ return errno;
+ }
+
+ return APR_SUCCESS;
+}
diff --git a/file_io/win32/open.c b/file_io/win32/open.c
index 5735a4471..0d7f0893c 100644
--- a/file_io/win32/open.c
+++ b/file_io/win32/open.c
@@ -581,6 +581,36 @@ APR_DECLARE(apr_status_t) apr_file_rename(const char *frompath,
return apr_get_os_error();
}
+APR_DECLARE(apr_status_t) apr_file_link(const char *from_path,
+ const char *to_path)
+{
+ apr_status_t rv;
+
+#if APR_HAS_UNICODE_FS
+ IF_WIN_OS_IS_UNICODE
+ {
+ apr_wchar_t wfrom_path[APR_PATH_MAX];
+ apr_wchar_t wto_path[APR_PATH_MAX];
+
+ if (rv = utf8_to_unicode_path(wfrom_path, sizeof(wfrom_path)
+ / sizeof(apr_wchar_t), from_path))
+ return rv;
+ if (rv = utf8_to_unicode_path(wto_path, sizeof(wto_path)
+ / sizeof(apr_wchar_t), to_path))
+ return rv;
+
+ if (!CreateHardLinkW(wto_path, wfrom_path))
+ return apr_get_os_error()
+ }
+#endif
+#if APR_HAS_ANSI_FS
+ ELSE_WIN_OS_IS_ANSI {
+ if (!CreateHardLinkA(wto_path, wfrom_path))
+ return apr_get_os_error()
+ }
+#endif
+}
+
APR_DECLARE(apr_status_t) apr_os_file_get(apr_os_file_t *thefile,
apr_file_t *file)
{