cvs: pecl /xattr php_xattr.h xattr.c
| From: | Marcin Gibula | Date: | Thu, 19 Aug 2004 11:03:40 +0000 |
| Subject: | cvs: pecl /xattr php_xattr.h xattr.c | ||
| Groups: | php.pecl.cvs | ||
| Request: | Send a blank email to pecl-cvs+get-1687@lists.php.net to get a copy of this message | ||
mg Thu Aug 19 07:03:40 2004 EDT
Modified files:
/pecl/xattr php_xattr.h xattr.c
Log:
Add xattr_supported function.
http://cvs.php.net/diff.php/pecl/xattr/php_xattr.h?r1=1.2&r2=1.3&ty=u
Index: pecl/xattr/php_xattr.h
diff -u pecl/xattr/php_xattr.h:1.2 pecl/xattr/php_xattr.h:1.3
--- pecl/xattr/php_xattr.h:1.2 Fri Aug 13 18:10:29 2004
+++ pecl/xattr/php_xattr.h Thu Aug 19 07:03:40 2004
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_xattr.h,v 1.2 2004/08/13 22:10:29 mg Exp $ */
+/* $Id: php_xattr.h,v 1.3 2004/08/19 11:03:40 mg Exp $ */
#ifndef PHP_XATTR_H
#define PHP_XATTR_H
@@ -41,6 +41,7 @@
PHP_FUNCTION(xattr_get);
PHP_FUNCTION(xattr_remove);
PHP_FUNCTION(xattr_list);
+PHP_FUNCTION(xattr_supported);
#endif /* PHP_XATTR_H */
http://cvs.php.net/diff.php/pecl/xattr/xattr.c?r1=1.8&r2=1.9&ty=u
Index: pecl/xattr/xattr.c
diff -u pecl/xattr/xattr.c:1.8 pecl/xattr/xattr.c:1.9
--- pecl/xattr/xattr.c:1.8 Sat Aug 14 16:33:10 2004
+++ pecl/xattr/xattr.c Thu Aug 19 07:03:40 2004
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: xattr.c,v 1.8 2004/08/14 20:33:10 mg Exp $ */
+/* $Id: xattr.c,v 1.9 2004/08/19 11:03:40 mg Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -52,6 +52,7 @@
PHP_FE(xattr_get, NULL)
PHP_FE(xattr_remove, NULL)
PHP_FE(xattr_list, NULL)
+ PHP_FE(xattr_supported, NULL)
{NULL, NULL, NULL} /* Must be the last line in xattr_functions[] */
};
/* }}} */
@@ -70,7 +71,7 @@
NULL,
PHP_MINFO(xattr),
#if ZEND_MODULE_API_NO >= 20010901
- "0.9",
+ "1.0",
#endif
STANDARD_MODULE_PROPERTIES
};
@@ -214,6 +215,40 @@
}
RETURN_FALSE;
+}
+/* }}} */
+
+/* {{{ proto bool xattr_supported(string path)
+ Checks if filesystem supports extended attributes */
+PHP_FUNCTION(xattr_supported)
+{
+ char *buffer, *path = NULL;
+ int error, tmp;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &path, &tmp) ==
FAILURE) {
+ return;
+ }
+
+ /* Is "test" a good name? */
+ error = getxattr(path, "user.test", buffer, 0);
+ if (error >= 0)
+ RETURN_TRUE;
+
+ switch (errno) {
+ case ENOATTR:
+ RETURN_TRUE;
+ case ENOTSUP:
+ RETURN_FALSE;
+ case ENOENT:
+ case ENOTDIR:
+ php_error(E_WARNING, "%s File %s doesn't exists",
get_active_function_name(TSRMLS_C), path);
+ break;
+ case EACCES:
+ php_error(E_WARNING, "%s Permission denied", get_active_function_name(TSRMLS_C));
+ break;
+ }
+
+ RETURN_NULL();
}
/* }}} */