Skip to content

Commit

Permalink
- add php_mkdir_ex, works like php_mkdir but allows to silent any error
Browse files Browse the repository at this point in the history
  when no options are used
  • Loading branch information
pierrejoye committed Jan 13, 2006
1 parent f113090 commit 6c509aa
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
3 changes: 2 additions & 1 deletion NEWS
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? 2006, PHP 5.1.3

- Added intern function php_mkdir_ex, works like php_mkdir but supports
the streams options (only REPORT_ERRORS is used) (Pierre)
12 Jan 2006, PHP 5.1.2
- Updated libsqlite in ext/sqlite to 2.8.17. (Ilia)
- Updated libsqlite in ext/pdo_sqlite to 3.2.8. (Ilia)
Expand Down
13 changes: 9 additions & 4 deletions ext/standard/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -1355,10 +1355,10 @@ PHPAPI PHP_FUNCTION(fseek)
/* {{{ proto int mkdir(char *dir int mode)
*/

PHPAPI int php_mkdir(char *dir, long mode TSRMLS_DC)
PHPAPI int php_mkdir_ex(char *dir, long mode, int options TSRMLS_DC)
{
int ret;

if (PG(safe_mode) && (!php_checkuid(dir, NULL, CHECKUID_CHECK_FILE_AND_DIR))) {
return -1;
}
Expand All @@ -1367,11 +1367,16 @@ PHPAPI int php_mkdir(char *dir, long mode TSRMLS_DC)
return -1;
}

if ((ret = VCWD_MKDIR(dir, (mode_t)mode)) < 0) {
if ((ret = VCWD_MKDIR(dir, (mode_t)mode)) < 0 && (options & REPORT_ERRORS)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", strerror(errno));
}

return ret;
return ret;
}

PHPAPI int php_mkdir(char *dir, long mode TSRMLS_DC)
{
return php_mkdir_ex(dir, mode, REPORT_ERRORS TSRMLS_CC);
}
/* }}} */

Expand Down
1 change: 1 addition & 0 deletions ext/standard/file.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ PHP_MINIT_FUNCTION(user_streams);
PHPAPI int php_le_stream_context(void);
PHPAPI int php_set_sock_blocking(int socketd, int block TSRMLS_DC);
PHPAPI int php_copy_file(char *src, char *dest TSRMLS_DC);
PHPAPI int php_mkdir_ex(char *dir, long mode, int options TSRMLS_DC);
PHPAPI int php_mkdir(char *dir, long mode TSRMLS_DC);

#define META_DEF_BUFSIZE 8192
Expand Down

0 comments on commit 6c509aa

Please sign in to comment.