summaryrefslogtreecommitdiff
path: root/ext/standard/filestat.c
diff options
context:
space:
mode:
authorStanislav Malyshev <stas@php.net>2011-09-06 05:28:25 +0000
committerStanislav Malyshev <stas@php.net>2011-09-06 05:28:25 +0000
commit7f56f7eb696259245411a5410f8495e75f3b5aea (patch)
treed23094d118a3d2dc6c2f5ae84824dffdc87fc783 /ext/standard/filestat.c
parent6280a6bdf934acd5e1bffa27947c99aa2b80109b (diff)
downloadphp-git-7f56f7eb696259245411a5410f8495e75f3b5aea.tar.gz
allow user streams to override ch* on windows too
Diffstat (limited to 'ext/standard/filestat.c')
-rw-r--r--ext/standard/filestat.c32
1 files changed, 21 insertions, 11 deletions
diff --git a/ext/standard/filestat.c b/ext/standard/filestat.c
index 5c4c5d465e..9b26c81946 100644
--- a/ext/standard/filestat.c
+++ b/ext/standard/filestat.c
@@ -415,6 +415,7 @@ PHPAPI int php_get_gid_by_name(const char *name, gid_t *gid TSRMLS_DC)
#endif
return SUCCESS;
}
+#endif
static void php_do_chgrp(INTERNAL_FUNCTION_PARAMETERS, int do_lchgrp) /* {{{ */
{
@@ -450,11 +451,18 @@ static void php_do_chgrp(INTERNAL_FUNCTION_PARAMETERS, int do_lchgrp) /* {{{ */
RETURN_FALSE;
}
} else {
+#if !defined(WINDOWS)
+/* On Windows, we expect regular chgrp to fail silently by default */
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can not call chgrp() for a non-standard stream");
+#endif
RETURN_FALSE;
}
}
+#if defined(WINDOWS)
+ /* We have no native chgrp on Windows, nothing left to do if stream doesn't have own implementation */
+ RETURN_FALSE;
+#else
if (Z_TYPE_P(group) == IS_LONG) {
gid = (gid_t)Z_LVAL_P(group);
} else if (Z_TYPE_P(group) == IS_STRING) {
@@ -484,20 +492,16 @@ static void php_do_chgrp(INTERNAL_FUNCTION_PARAMETERS, int do_lchgrp) /* {{{ */
RETURN_FALSE;
}
RETURN_TRUE;
+#endif
}
/* }}} */
-#endif
#ifndef NETWARE
/* {{{ proto bool chgrp(string filename, mixed group)
Change file group */
PHP_FUNCTION(chgrp)
{
-#if !defined(WINDOWS)
php_do_chgrp(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
-#else
- RETURN_FALSE;
-#endif
}
/* }}} */
@@ -546,6 +550,7 @@ PHPAPI uid_t php_get_uid_by_name(const char *name, uid_t *uid TSRMLS_DC)
#endif
return SUCCESS;
}
+#endif
static void php_do_chown(INTERNAL_FUNCTION_PARAMETERS, int do_lchown) /* {{{ */
{
@@ -581,11 +586,19 @@ static void php_do_chown(INTERNAL_FUNCTION_PARAMETERS, int do_lchown) /* {{{ */
RETURN_FALSE;
}
} else {
+#if !defined(WINDOWS)
+/* On Windows, we expect regular chown to fail silently by default */
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can not call chown() for a non-standard stream");
+#endif
RETURN_FALSE;
}
}
+#if defined(WINDOWS)
+ /* We have no native chown on Windows, nothing left to do if stream doesn't have own implementation */
+ RETURN_FALSE;
+#else
+
if (Z_TYPE_P(user) == IS_LONG) {
uid = (uid_t)Z_LVAL_P(user);
} else if (Z_TYPE_P(user) == IS_STRING) {
@@ -614,21 +627,18 @@ static void php_do_chown(INTERNAL_FUNCTION_PARAMETERS, int do_lchown) /* {{{ */
php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", strerror(errno));
RETURN_FALSE;
}
+ RETURN_TRUE;
+#endif
}
/* }}} */
-#endif
+
#ifndef NETWARE
/* {{{ proto bool chown (string filename, mixed user)
Change file owner */
PHP_FUNCTION(chown)
{
-#if !defined(WINDOWS)
- RETVAL_TRUE;
php_do_chown(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
-#else
- RETURN_FALSE;
-#endif
}
/* }}} */