Re: cvs: php4 /ext/standard filestat.c

From: Date: Tue, 02 Jul 2002 21:05:19 +0000
Subject: Re: cvs: php4 /ext/standard filestat.c
References: 1  Groups: php.cvs 
Request: Send a blank email to php-cvs+get-12669@lists.php.net to get a copy of this message
On Tue, 2 Jul 2002, Sterling Hughes wrote: > sterling Tue Jul 2 17:02:34 2002 EDT > > Modified files: > /php4/ext/standard filestat.c > Log: > use access instead of manually determining file permissions.. Does this also work on win****? Derick > > > Index: php4/ext/standard/filestat.c > diff -u php4/ext/standard/filestat.c:1.94 php4/ext/standard/filestat.c:1.95 > --- php4/ext/standard/filestat.c:1.94 Mon May 20 13:41:35 2002 > +++ php4/ext/standard/filestat.c Tue Jul 2 17:02:34 2002 > @@ -16,7 +16,7 @@ > +----------------------------------------------------------------------+ > */ > > -/* $Id: filestat.c,v 1.94 2002/05/20 17:41:35 mfischer Exp $ */ > +/* $Id: filestat.c,v 1.95 2002/07/02 21:02:34 sterling Exp $ */ > > #include "php.h" > #include "safe_mode.h" > @@ -662,21 +662,6 @@ > } > php_error(E_WARNING, "Unknown file type (%d)", BG(sb).st_mode&S_IFMT); > RETURN_STRING("unknown", 1); > - case FS_IS_W: > - if (getuid()==0) { > - RETURN_TRUE; /* root */ > - } > - RETURN_BOOL((BG(sb).st_mode & wmask) != 0); > - case FS_IS_R: > - if (getuid()==0) { > - RETURN_TRUE; /* root */ > - } > - RETURN_BOOL((BG(sb).st_mode&rmask)!=0); > - case FS_IS_X: > - if (getuid()==0) { > - xmask = S_IXROOT; /* root */ > - } > - RETURN_BOOL((BG(sb).st_mode&xmask)!=0 && !S_ISDIR(BG(sb).st_mode)); > case FS_IS_FILE: > RETURN_BOOL(S_ISREG(BG(sb).st_mode)); > case FS_IS_DIR: > @@ -687,8 +672,6 @@ > #else > RETURN_FALSE; > #endif > - case FS_EXISTS: > - RETURN_TRUE; /* the false case was done earlier */ > case FS_LSTAT: > #if HAVE_SYMLINK > stat_sb = &BG(lsb); > @@ -820,17 +803,44 @@ > > /* {{{ proto bool is_writable(string filename) > Returns true if file can be written */ > -FileFunction(PHP_FN(is_writable), FS_IS_W) > +PHP_FUNCTION(is_writable) > +{ > + char *filename; > + > + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &filename) == > FAILURE) { > + return; > + } > + > + RETURN_BOOL(!access (filename, W_OK)); > +} > /* }}} */ > > /* {{{ proto bool is_readable(string filename) > Returns true if file can be read */ > -FileFunction(PHP_FN(is_readable), FS_IS_R) > +PHP_FUNCTION(is_readable) > +{ > + char *filename; > + > + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &filename) == > FAILURE) { > + return; > + } > + > + RETURN_BOOL(!access (filename, R_OK)); > +} > /* }}} */ > > /* {{{ proto bool is_executable(string filename) > Returns true if file is executable */ > -FileFunction(PHP_FN(is_executable), FS_IS_X) > +PHP_FUNCTION(is_executable) > +{ > + char *filename; > + > + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &filename) == > FAILURE) { > + return; > + } > + > + RETURN_BOOL(!access (filename, X_OK)); > +} > /* }}} */ > > /* {{{ proto bool is_file(string filename) > @@ -850,7 +860,16 @@ > > /* {{{ proto bool file_exists(string filename) > Returns true if filename exists */ > -FileFunction(PHP_FN(file_exists), FS_EXISTS) > +PHP_FUNCTION(file_exists) > +{ > + char *filename; > + > + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &filename) == > FAILURE) { > + return; > + } > + > + RETURN_BOOL(!access (filename, F_OK)); > +} > /* }}} */ > > /* {{{ proto array lstat(string filename) > > > > -- > PHP CVS Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > --------------------------------------------------------------------------- Did I help you? http://www.derickrethans.nl/link.php?url=giftlist Frequent ranting: http://www.derickrethans.nl/ --------------------------------------------------------------------------- PHP: Scripting the Web - derick@php.net All your branches are belong to me! SRM: Script Running Machine - www.vl-srm.net ---------------------------------------------------------------------------

« previous php.cvs (#12669) next »