com php-src: Fix ftok() multibyte path support: win32/ftok.c

From: Date: Mon, 09 Oct 2017 11:12:40 +0000
Subject: com php-src: Fix ftok() multibyte path support: win32/ftok.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-99663@lists.php.net to get a copy of this message
Commit: dc3b9fe619ca36ddb1f1948c66fc09a500dedc2f Author: Anatol Belski <ab@php.net> Mon, 9 Oct 2017 13:07:40 +0200 Parents: ac1fd769ad2c69f40007e5d679c6c61631eaec44 Branches: PHP-7.1 PHP-7.2 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=dc3b9fe619ca36ddb1f1948c66fc09a500dedc2f Log: Fix ftok() multibyte path support Changed paths: M win32/ftok.c Diff: diff --git a/win32/ftok.c b/win32/ftok.c index eb926b1..64c430b 100644 --- a/win32/ftok.c +++ b/win32/ftok.c @@ -21,24 +21,33 @@ #include <windows.h> #include <sys/stat.h> +#include "ioutil.h" PHPAPI key_t ftok(const char *pathname, int proj_id) { HANDLE fh; - struct stat st; + struct _stat st; BY_HANDLE_FILE_INFORMATION bhfi; key_t ret; + PHP_WIN32_IOUTIL_INIT_W(pathname) - if (stat(pathname, &st) < 0) { + if (!pathw) { return (key_t)-1; } - if ((fh = CreateFile(pathname, GENERIC_READ, 0, 0, OPEN_EXISTING, 0, 0)) == INVALID_HANDLE_VALUE) { + if (_wstat(pathw, &st) < 0) { + PHP_WIN32_IOUTIL_CLEANUP_W() + return (key_t)-1; + } + + if ((fh = CreateFileW(pathw, GENERIC_READ, 0, 0, OPEN_EXISTING, 0, 0)) == INVALID_HANDLE_VALUE) { + PHP_WIN32_IOUTIL_CLEANUP_W() return (key_t)-1; } if (!GetFileInformationByHandle(fh, &bhfi)) { + PHP_WIN32_IOUTIL_CLEANUP_W() CloseHandle(fh); return (key_t)-1; } @@ -46,6 +55,7 @@ ftok(const char *pathname, int proj_id) ret = (key_t) ((proj_id & 0xff) << 24 | (st.st_dev & 0xff) << 16 | ((bhfi.nFileIndexLow | (__int64)bhfi.nFileIndexHigh << 32) & 0xffff)); CloseHandle(fh); + PHP_WIN32_IOUTIL_CLEANUP_W() return ret; }

« previous php.cvs (#99663) next »