|
|
|
@ -59,7 +59,8 @@ |
|
|
|
#define PHP_PATHINFO_DIRNAME 1 |
|
|
|
#define PHP_PATHINFO_BASENAME 2 |
|
|
|
#define PHP_PATHINFO_EXTENSION 4 |
|
|
|
#define PHP_PATHINFO_ALL (PHP_PATHINFO_DIRNAME | PHP_PATHINFO_BASENAME | PHP_PATHINFO_EXTENSION) |
|
|
|
#define PHP_PATHINFO_FILENAME 8 |
|
|
|
#define PHP_PATHINFO_ALL (PHP_PATHINFO_DIRNAME | PHP_PATHINFO_BASENAME | PHP_PATHINFO_EXTENSION | PHP_PATHINFO_FILENAME) |
|
|
|
|
|
|
|
#define STR_STRSPN 0 |
|
|
|
#define STR_STRCSPN 1 |
|
|
|
@ -74,6 +75,7 @@ void register_string_constants(INIT_FUNC_ARGS) |
|
|
|
REGISTER_LONG_CONSTANT("PATHINFO_DIRNAME", PHP_PATHINFO_DIRNAME, CONST_CS | CONST_PERSISTENT); |
|
|
|
REGISTER_LONG_CONSTANT("PATHINFO_BASENAME", PHP_PATHINFO_BASENAME, CONST_CS | CONST_PERSISTENT); |
|
|
|
REGISTER_LONG_CONSTANT("PATHINFO_EXTENSION", PHP_PATHINFO_EXTENSION, CONST_CS | CONST_PERSISTENT); |
|
|
|
REGISTER_LONG_CONSTANT("PATHINFO_FILENAME", PHP_PATHINFO_FILENAME, CONST_CS | CONST_PERSISTENT); |
|
|
|
|
|
|
|
#ifdef HAVE_LOCALECONV |
|
|
|
/* If last members of struct lconv equal CHAR_MAX, no grouping is done */ |
|
|
|
@ -1385,6 +1387,26 @@ PHP_FUNCTION(pathinfo) |
|
|
|
efree(ret); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if ((opt & PHP_PATHINFO_FILENAME) == PHP_PATHINFO_FILENAME) { |
|
|
|
char *p; |
|
|
|
int idx; |
|
|
|
int have_basename = ((opt & PHP_PATHINFO_BASENAME) == PHP_PATHINFO_BASENAME); |
|
|
|
|
|
|
|
/* Have we alrady looked up the basename? */ |
|
|
|
if (!have_basename) { |
|
|
|
php_basename(path, path_len, NULL, 0, &ret, &ret_len TSRMLS_CC); |
|
|
|
} |
|
|
|
|
|
|
|
p = strrchr(ret, '.'); |
|
|
|
|
|
|
|
idx = p ? (p - ret) : ret_len; |
|
|
|
add_assoc_stringl(tmp, "filename", ret, idx, 1); |
|
|
|
|
|
|
|
if (!have_basename) { |
|
|
|
efree(ret); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (opt == PHP_PATHINFO_ALL) { |
|
|
|
RETURN_ZVAL(tmp, 0, 1); |
|
|
|
|