]> granicus.if.org Git - php/commitdiff
move these functions to the appropriate place
authorAnatol Belski <ab@php.net>
Mon, 10 Nov 2014 08:14:15 +0000 (09:14 +0100)
committerAnatol Belski <ab@php.net>
Mon, 10 Nov 2014 09:58:19 +0000 (10:58 +0100)
and include the necessary header

TSRM/tsrm_win32.c
TSRM/tsrm_win32.h
Zend/zend_virtual_cwd.c

index 9936320a951ca0ad652f906b05ab3e236de6deee..7194dffd610e5ad1341f5e0213c95f68af34dbe8 100644 (file)
@@ -722,4 +722,52 @@ TSRM_API char *realpath(char *orig_path, char *buffer)
        return buffer;
 }
 
+#if HAVE_UTIME
+static zend_always_inline void UnixTimeToFileTime(time_t t, LPFILETIME pft) /* {{{ */
+{
+       // Note that LONGLONG is a 64-bit value
+       LONGLONG ll;
+
+       ll = Int32x32To64(t, 10000000) + 116444736000000000;
+       pft->dwLowDateTime = (DWORD)ll;
+       pft->dwHighDateTime = ll >> 32;
+}
+/* }}} */
+
+TSRM_API int win32_utime(const char *filename, struct utimbuf *buf) /* {{{ */
+{
+       FILETIME mtime, atime;
+       HANDLE hFile;
+
+       hFile = CreateFile(filename, GENERIC_WRITE, FILE_SHARE_WRITE|FILE_SHARE_READ, NULL,
+                                OPEN_ALWAYS, FILE_FLAG_BACKUP_SEMANTICS, NULL);
+
+       /* OPEN_ALWAYS mode sets the last error to ERROR_ALREADY_EXISTS but
+          the CreateFile operation succeeds */
+       if (GetLastError() == ERROR_ALREADY_EXISTS) {
+               SetLastError(0);
+       }
+
+       if ( hFile == INVALID_HANDLE_VALUE ) {
+               return -1;
+       }
+
+       if (!buf) {
+               SYSTEMTIME st;
+               GetSystemTime(&st);
+               SystemTimeToFileTime(&st, &mtime);
+               atime = mtime;
+       } else {
+               UnixTimeToFileTime(buf->modtime, &mtime);
+               UnixTimeToFileTime(buf->actime, &atime);
+       }
+       if (!SetFileTime(hFile, NULL, &atime, &mtime)) {
+               CloseHandle(hFile);
+               return -1;
+       }
+       CloseHandle(hFile);
+       return 1;
+}
+/* }}} */
+#endif
 #endif
index 5933b54ddf3fa903575d8f190bf2ae369c9b936e..beff1e88cfd2b8581fe95f6f173e96035e2008f7 100644 (file)
@@ -23,6 +23,9 @@
 
 #include "TSRM.h"
 #include <windows.h>
+#if HAVE_UTIME
+# include <sys/utime.h>
+#endif
 
 struct ipc_perm {
        int                     key;
index 385df393bf5ff85f9e36f2f74fac4816973adc1b..f8b42b1596e387ae8732e778d633b21943f9438e 100644 (file)
@@ -1540,55 +1540,6 @@ CWD_API int virtual_access(const char *pathname, int mode TSRMLS_DC) /* {{{ */
 /* }}} */
 
 #if HAVE_UTIME
-#ifdef TSRM_WIN32
-static void UnixTimeToFileTime(time_t t, LPFILETIME pft) /* {{{ */
-{
-       // Note that LONGLONG is a 64-bit value
-       LONGLONG ll;
-
-       ll = Int32x32To64(t, 10000000) + 116444736000000000;
-       pft->dwLowDateTime = (DWORD)ll;
-       pft->dwHighDateTime = ll >> 32;
-}
-/* }}} */
-
-TSRM_API int win32_utime(const char *filename, struct utimbuf *buf) /* {{{ */
-{
-       FILETIME mtime, atime;
-       HANDLE hFile;
-
-       hFile = CreateFile(filename, GENERIC_WRITE, FILE_SHARE_WRITE|FILE_SHARE_READ, NULL,
-                                OPEN_ALWAYS, FILE_FLAG_BACKUP_SEMANTICS, NULL);
-
-       /* OPEN_ALWAYS mode sets the last error to ERROR_ALREADY_EXISTS but
-          the CreateFile operation succeeds */
-       if (GetLastError() == ERROR_ALREADY_EXISTS) {
-               SetLastError(0);
-       }
-
-       if ( hFile == INVALID_HANDLE_VALUE ) {
-               return -1;
-       }
-
-       if (!buf) {
-               SYSTEMTIME st;
-               GetSystemTime(&st);
-               SystemTimeToFileTime(&st, &mtime);
-               atime = mtime;
-       } else {
-               UnixTimeToFileTime(buf->modtime, &mtime);
-               UnixTimeToFileTime(buf->actime, &atime);
-       }
-       if (!SetFileTime(hFile, NULL, &atime, &mtime)) {
-               CloseHandle(hFile);
-               return -1;
-       }
-       CloseHandle(hFile);
-       return 1;
-}
-/* }}} */
-#endif
-
 CWD_API int virtual_utime(const char *filename, struct utimbuf *buf TSRMLS_DC) /* {{{ */
 {
        cwd_state new_state;