mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
improved file size computation in stat()
On 32 bit it's still overwlowing, so nothing is changed there. But the usage of LARGE_INTEGER instead of bit shifting is a better way to go.
This commit is contained in:
parent
ccb24caa6d
commit
c41fbcfb4c
1 changed files with 6 additions and 5 deletions
|
@ -294,7 +294,7 @@ CWD_API int php_sys_readlink(const char *link, char *target, size_t target_len){
|
||||||
CWD_API int php_sys_stat_ex(const char *path, zend_stat_t *buf, int lstat) /* {{{ */
|
CWD_API int php_sys_stat_ex(const char *path, zend_stat_t *buf, int lstat) /* {{{ */
|
||||||
{
|
{
|
||||||
WIN32_FILE_ATTRIBUTE_DATA data;
|
WIN32_FILE_ATTRIBUTE_DATA data;
|
||||||
__int64 t;
|
LARGE_INTEGER t;
|
||||||
const size_t path_len = strlen(path);
|
const size_t path_len = strlen(path);
|
||||||
ALLOCA_FLAG(use_heap_large);
|
ALLOCA_FLAG(use_heap_large);
|
||||||
|
|
||||||
|
@ -393,10 +393,11 @@ CWD_API int php_sys_stat_ex(const char *path, zend_stat_t *buf, int lstat) /* {{
|
||||||
}
|
}
|
||||||
|
|
||||||
buf->st_nlink = 1;
|
buf->st_nlink = 1;
|
||||||
t = data.nFileSizeHigh;
|
t.HighPart = data.nFileSizeHigh;
|
||||||
t = t << 32;
|
t.LowPart = data.nFileSizeLow;
|
||||||
t |= data.nFileSizeLow;
|
/* It's an overflow on 32 bit, however it won't fix as long
|
||||||
buf->st_size = t;
|
as zend_long is 32 bit. */
|
||||||
|
buf->st_size = (zend_long)t.QuadPart;
|
||||||
buf->st_atime = FileTimeToUnixTime(&data.ftLastAccessTime);
|
buf->st_atime = FileTimeToUnixTime(&data.ftLastAccessTime);
|
||||||
buf->st_ctime = FileTimeToUnixTime(&data.ftCreationTime);
|
buf->st_ctime = FileTimeToUnixTime(&data.ftCreationTime);
|
||||||
buf->st_mtime = FileTimeToUnixTime(&data.ftLastWriteTime);
|
buf->st_mtime = FileTimeToUnixTime(&data.ftLastWriteTime);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue