From 1dd395b27fed08172838dff50bf3ebb7bfc52cd8 Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Fri, 19 May 2006 02:51:18 +0000 Subject: [PATCH] MFB: Fixed bug #37505 (touch() truncates large files). --- ext/standard/filestat.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ext/standard/filestat.c b/ext/standard/filestat.c index 9a9365f372e..812a6ecd4d4 100644 --- a/ext/standard/filestat.c +++ b/ext/standard/filestat.c @@ -504,7 +504,6 @@ PHP_FUNCTION(touch) { zval **filename, **filetime, **fileatime; int ret; - struct stat sb; FILE *file; struct utimbuf newtimebuf; struct utimbuf *newtime = NULL; @@ -537,8 +536,7 @@ PHP_FUNCTION(touch) } /* create the file if it doesn't exist already */ - ret = VCWD_STAT(Z_STRVAL_PP(filename), &sb); - if (ret == -1) { + if (VCWD_ACCESS(Z_STRVAL_PP(filename), F_OK) != 0) { file = VCWD_FOPEN(Z_STRVAL_PP(filename), "w"); if (file == NULL) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to create file %s because %s", Z_STRVAL_PP(filename), strerror(errno));