mirror of
https://github.com/danog/ext-uv.git
synced 2024-11-30 04:29:01 +01:00
Add UV::S_IFDIR + UV::S_IFREG constants
These constants allow differentiation between regular files (S_IFREG) and directories (S_IFDIR) when used for bitwise AND operations against the "mode" value returned from uv_fs_stat/fstat/lstat(). Example: uv_fs_open(uv_default_loop(), __FILE__, UV::O_RDONLY, 0, function($r){ uv_fs_fstat(uv_default_loop(), $r, function($result, $da){ echo "is directory: ", ($da['mode'] & UV::S_IFDIR ? 'yes' : 'no'), "\n"; echo "if file: ", ($da['mode'] & UV::S_IFREG ? 'yes' : 'no'), "\n"; }); }); uv_run();
This commit is contained in:
parent
75fd2ff591
commit
148a84f62b
14
php_uv.h
Normal file → Executable file
14
php_uv.h
Normal file → Executable file
@ -220,6 +220,20 @@ typedef struct {
|
||||
#define PHP_UV_LIST_INSERT(type, handle) zend_list_insert(type, handle)
|
||||
#endif
|
||||
|
||||
|
||||
/* File/directory stat mode constants*/
|
||||
#ifdef PHP_WIN32
|
||||
#define S_IFDIR _S_IFDIR
|
||||
#define S_IFREG _S_IFREG
|
||||
#else
|
||||
#ifndef S_IFDIR
|
||||
#define S_IFDIR 0040000
|
||||
#endif
|
||||
#ifndef S_IFREG
|
||||
#define S_IFREG 0100000
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* TODO: remove these macro when libuv provides uv_inet_ntop & uv_inet_pton */
|
||||
#ifdef PHP_WIN32
|
||||
# include "libuv/src/ares/inet_net_pton.h"
|
||||
|
3
uv.c
Normal file → Executable file
3
uv.c
Normal file → Executable file
@ -51,6 +51,9 @@ static int php_uv_class_init(TSRMLS_D)
|
||||
zend_declare_class_constant_long(uv_class_entry, "O_TRUNC", sizeof("O_TRUNC")-1, O_TRUNC TSRMLS_CC);
|
||||
zend_declare_class_constant_long(uv_class_entry, "O_APPEND", sizeof("O_APPEND")-1, O_APPEND TSRMLS_CC);
|
||||
|
||||
zend_declare_class_constant_long(uv_class_entry, "S_IFDIR", sizeof("S_IFDIR")-1, S_IFDIR TSRMLS_CC);
|
||||
zend_declare_class_constant_long(uv_class_entry, "S_IFREG", sizeof("S_IFREG")-1, S_IFREG TSRMLS_CC);
|
||||
|
||||
#ifndef PHP_WIN32
|
||||
zend_declare_class_constant_long(uv_class_entry, "O_NOCTTY", sizeof("O_NOCTTY")-1, O_NOCTTY TSRMLS_CC);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user