update page now

Voting

: max(three, six)?
(Example: nine)

The Note You're Voting On

com dot gmail at algofoogle
20 years ago
Re note posted by "salisbm at hotmail dot com":
S_IFDIR is not a single-bit flag. It is a constant that relies on the "S_IFMT" bitmask. This bitmask should be applied to the "mode" parameter before comparing with any of the other "S_IF..." constants, as indicated by stat.h:
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
That is, this approach is incorrect:
<?php
define('S_IFDIR',040000);
if ($mode & S_IFDIR)
{
 /*
 incorrect!
 format could be S_IFDIR, but also
 S_IFBLK, S_IFSOCK, or S_IFWHT.
 */
}
?>

...and should instead be:
<?php
define('S_IFMT',0170000);
define('S_IFDIR',040000);
if (S_IFDIR == ($mode & S_IFMT)) { /* ... */ }
?>

As pointed out by "svend at svendtofte dot com", however, there is also the "is_dir" function for this purpose, along with "is_file" and "is_link" to cover the most common format types...

<< Back to user notes page

AltStyle によって変換されたページ (->オリジナル) /