chobie / php-uv

libuv php extension
184 stars 21 forks source link

Add UV::S_IFDIR + UV::S_IFREG constants #54

Closed rdlowrey closed 10 years ago

rdlowrey commented 10 years ago

This PR adds two new 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:

<?php
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 "is file: ", ($da['mode'] & UV::S_IFREG ? 'yes' : 'no'), "\n";
    });
});
uv_run();
rdlowrey commented 10 years ago

Thanks for the quick merge :)

chobie commented 10 years ago

:)