tony2001 Fri Jun 30 10:53:11 2006 UTC
Modified files: (Branch: PHP_5_2)
/php-src/ext/standard filestat.c
Log:
MFH: add error messages to disk_free_space() & disk_total_space() (feature
request #37971)
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/filestat.c?r1=1.136.2.8.2.1&r2=1.136.2.8.2.2&diff_format=u
Index: php-src/ext/standard/filestat.c
diff -u php-src/ext/standard/filestat.c:1.136.2.8.2.1
php-src/ext/standard/filestat.c:1.136.2.8.2.2
--- php-src/ext/standard/filestat.c:1.136.2.8.2.1 Fri May 19 02:51:00 2006
+++ php-src/ext/standard/filestat.c Fri Jun 30 10:53:11 2006
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: filestat.c,v 1.136.2.8.2.1 2006/05/19 02:51:00 iliaa Exp $ */
+/* $Id: filestat.c,v 1.136.2.8.2.2 2006/06/30 10:53:11 tony2001 Exp $ */
#include "php.h"
#include "safe_mode.h"
@@ -79,6 +79,10 @@
# endif
#endif
+#ifdef PHP_WIN32
+#include "win32/winutil.h"
+#endif
+
#include "basic_functions.h"
#include "php_filestat.h"
@@ -170,7 +174,10 @@
if (func(Z_STRVAL_PP(path),
&FreeBytesAvailableToCaller,
&TotalNumberOfBytes,
- &TotalNumberOfFreeBytes) == 0) RETURN_FALSE;
+ &TotalNumberOfFreeBytes) == 0) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING,
"%s", php_win_err());
+ RETURN_FALSE;
+ }
/* i know - this is ugly, but i works <[EMAIL
PROTECTED]> */
bytestotal = TotalNumberOfBytes.HighPart *
@@ -181,7 +188,10 @@
else {
if (GetDiskFreeSpace(Z_STRVAL_PP(path),
&SectorsPerCluster, &BytesPerSector,
- &NumberOfFreeClusters, &TotalNumberOfClusters)
== 0) RETURN_FALSE;
+ &NumberOfFreeClusters, &TotalNumberOfClusters)
== 0) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING,
"%s", php_win_err());
+ RETURN_FALSE;
+ }
bytestotal = (double)TotalNumberOfClusters *
(double)SectorsPerCluster * (double)BytesPerSector;
}
}
@@ -200,7 +210,10 @@
}
#else /* WINDOWS, OS/2 */
#if defined(HAVE_SYS_STATVFS_H) && defined(HAVE_STATVFS)
- if (statvfs(Z_STRVAL_PP(path), &buf)) RETURN_FALSE;
+ if (statvfs(Z_STRVAL_PP(path), &buf)) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s",
strerror(errno));
+ RETURN_FALSE;
+ }
if (buf.f_frsize) {
bytestotal = (((double)buf.f_blocks) * ((double)buf.f_frsize));
} else {
@@ -208,7 +221,10 @@
}
#elif (defined(HAVE_SYS_STATFS_H) || defined(HAVE_SYS_MOUNT_H)) &&
defined(HAVE_STATFS)
- if (statfs(Z_STRVAL_PP(path), &buf)) RETURN_FALSE;
+ if (statfs(Z_STRVAL_PP(path), &buf)) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s",
strerror(errno));
+ RETURN_FALSE;
+ }
bytestotal = (((double)buf.f_bsize) * ((double)buf.f_blocks));
#endif
#endif /* WINDOWS */
@@ -273,7 +289,10 @@
if (func(Z_STRVAL_PP(path),
&FreeBytesAvailableToCaller,
&TotalNumberOfBytes,
- &TotalNumberOfFreeBytes) == 0) RETURN_FALSE;
+ &TotalNumberOfFreeBytes) == 0) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING,
"%s", php_win_err());
+ RETURN_FALSE;
+ }
/* i know - this is ugly, but i works <[EMAIL
PROTECTED]> */
bytesfree = FreeBytesAvailableToCaller.HighPart *
@@ -284,7 +303,10 @@
else {
if (GetDiskFreeSpace(Z_STRVAL_PP(path),
&SectorsPerCluster, &BytesPerSector,
- &NumberOfFreeClusters, &TotalNumberOfClusters)
== 0) RETURN_FALSE;
+ &NumberOfFreeClusters, &TotalNumberOfClusters)
== 0) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING,
"%s", php_win_err());
+ RETURN_FALSE;
+ }
bytesfree = (double)NumberOfFreeClusters *
(double)SectorsPerCluster * (double)BytesPerSector;
}
}
@@ -303,14 +325,20 @@
}
#else /* WINDOWS, OS/2 */
#if defined(HAVE_SYS_STATVFS_H) && defined(HAVE_STATVFS)
- if (statvfs(Z_STRVAL_PP(path), &buf)) RETURN_FALSE;
+ if (statvfs(Z_STRVAL_PP(path), &buf)) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s",
strerror(errno));
+ RETURN_FALSE;
+ }
if (buf.f_frsize) {
bytesfree = (((double)buf.f_bavail) * ((double)buf.f_frsize));
} else {
bytesfree = (((double)buf.f_bavail) * ((double)buf.f_bsize));
}
#elif (defined(HAVE_SYS_STATFS_H) || defined(HAVE_SYS_MOUNT_H)) &&
defined(HAVE_STATFS)
- if (statfs(Z_STRVAL_PP(path), &buf)) RETURN_FALSE;
+ if (statfs(Z_STRVAL_PP(path), &buf)) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s",
strerror(errno));
+ RETURN_FALSE;
+ }
#ifdef NETWARE
bytesfree = (((double)buf.f_bsize) * ((double)buf.f_bfree));
#else
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php