}
/* }}} */
-/* {{{ proto void Phar::getRunningPhar()
- * return the name of the currently running phar archive
+/* {{{ proto void Phar::running([bool retphar = true])
+ * return the name of the currently running phar archive. If the optional parameter
+ * is set to true, return the phar:// URL to the currently running phar
*/
-PHP_METHOD(Phar, getRunningPhar)
+PHP_METHOD(Phar, running)
{
char *fname, *arch, *entry;
int fname_len, arch_len, entry_len;
+ zend_bool retphar = 1;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &retphar) == FAILURE) {
+ return;
+ }
fname = zend_get_executed_filename(TSRMLS_C);
fname_len = strlen(fname);
if (SUCCESS == phar_split_fname(fname, fname_len, &arch, &arch_len, &entry, &entry_len TSRMLS_CC)) {
efree(entry);
- RETURN_STRINGL(arch, arch_len, 0);
+ if (retphar) {
+ RETVAL_STRINGL(fname, arch_len + 7, 1);
+ efree(arch);
+ return;
+ } else {
+ RETURN_STRINGL(arch, arch_len, 0);
+ }
}
- efree(entry);
RETURN_STRING("", 0);
}
/* }}} */
carry_on:
if (SUCCESS != phar_mount_entry(*pphar, actual, actual_len, path, path_len TSRMLS_CC)) {
zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "Mounting of %s to %s within phar %s failed", path, actual, arch);
- efree(arch);
}
efree(arch);
return;
ZEND_ARG_INFO(0, maxlen)
ZEND_END_ARG_INFO();
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_running, 0, 0, 1)
+ ZEND_ARG_INFO(0, retphar)
+ZEND_END_ARG_INFO();
+
#endif /* HAVE_SPL */
zend_function_entry php_archive_methods[] = {
PHP_ME(Phar, isValidPharFilename, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL)
PHP_ME(Phar, loadPhar, arginfo_phar_loadPhar, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL)
PHP_ME(Phar, mapPhar, arginfo_phar_mapPhar, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL)
- PHP_ME(Phar, getRunningPhar, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL)
+ PHP_ME(Phar, running, arginfo_phar_running, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL)
PHP_ME(Phar, mount, arginfo_phar_mount, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL)
PHP_ME(Phar, mungServer, arginfo_phar_mungServer, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL)
PHP_ME(Phar, webPhar, arginfo_phar_webPhar, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL)