X-Git-Url: http://ftp.carnet.hr/carnet-debian/scm?p=php5-apc.git;a=blobdiff_plain;f=apc.c;h=14fc3eab113c4491650fd49a6cba451bba7a36c2;hp=ad770f8e203ba762bd2e4d9dc50a3a5e672034ce;hb=3682e0a7a26931aabca2b6e54eb08efd7dc0430b;hpb=575ce08215526bb71a967d69d601e77e1afbcd11 diff --git a/apc.c b/apc.c index ad770f8..14fc3ea 100644 --- a/apc.c +++ b/apc.c @@ -29,7 +29,7 @@ */ -/* $Id: apc.c,v 3.18 2007/11/29 22:15:53 shire Exp $ */ +/* $Id: apc.c,v 3.18.2.1 2008/03/25 18:04:53 gopalv Exp $ */ #include "apc.h" #include /* for POSIX regular expressions */ @@ -270,26 +270,13 @@ char** apc_tokenize(const char* s, char delim) /* }}} */ -/* {{{ filesystem functions */ - -#ifdef PHP_WIN32 -int apc_win32_stat(const char *path, struct stat *buf TSRMLS_DC) -{ - char rpath[MAXPATHLEN]; - BY_HANDLE_FILE_INFORMATION fi; - HANDLE f; - - if (VCWD_STAT(path, buf)) { - return -1; - } - - VCWD_REALPATH(path, rpath); - f = CreateFile(rpath, 0, 0, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS | FILE_ATTRIBUTE_READONLY, NULL); - GetFileInformationByHandle(f, &fi); - buf->st_ino = (ino_t)fi.nFileIndexLow; - CloseHandle (f); - return 0; -} +/* similar to php_stream_stat_path */ +#ifdef ZEND_ENGINE_2 +#define APC_URL_STAT(wrapper, filename, pstatbuf) \ + ((wrapper)->wops->url_stat((wrapper), (filename), 0, (pstatbuf), NULL TSRMLS_CC)) +#else +#define APC_URL_STAT(wrapper, filename, pstatbuf) \ + ((wrapper)->wops->url_stat((wrapper), (filename), (pstatbuf) TSRMLS_CC)) #endif int apc_search_paths(const char* filename, const char* path, apc_fileinfo_t* fileinfo) @@ -299,12 +286,33 @@ int apc_search_paths(const char* filename, const char* path, apc_fileinfo_t* fil int exec_fname_length; int found = 0; int i; + php_stream_wrapper *wrapper = NULL; + char *path_for_open = NULL; + TSRMLS_FETCH(); assert(filename && fileinfo); - if (IS_ABSOLUTE_PATH(filename, strlen(filename)) && apc_stat(filename, &fileinfo->st_buf) == 0) { - strncpy(fileinfo->fullpath, filename, MAXPATHLEN); + + wrapper = php_stream_locate_url_wrapper(filename, &path_for_open, 0 TSRMLS_CC); + + if(!wrapper || !wrapper->wops || !wrapper->wops->url_stat) { + return -1; + } + +#ifdef ZEND_ENGINE_2 + if(wrapper != &php_plain_files_wrapper) { + if(APC_URL_STAT(wrapper, path_for_open, &fileinfo->st_buf) == 0) { + strncpy(fileinfo->fullpath, path_for_open, MAXPATHLEN); + return 0; + } + return -1; /* cannot stat */ + } +#endif + + if (IS_ABSOLUTE_PATH(path_for_open, strlen(path_for_open)) && + APC_URL_STAT(wrapper, path_for_open, &fileinfo->st_buf) == 0) { + strncpy(fileinfo->fullpath, path_for_open, MAXPATHLEN); return 0; } @@ -314,8 +322,8 @@ int apc_search_paths(const char* filename, const char* path, apc_fileinfo_t* fil /* for each directory in paths, look for filename inside */ for (i = 0; paths[i]; i++) { - snprintf(fileinfo->fullpath, sizeof(fileinfo->fullpath), "%s%c%s", paths[i], DEFAULT_SLASH, filename); - if (apc_stat(fileinfo->fullpath, &fileinfo->st_buf) == 0) { + snprintf(fileinfo->fullpath, sizeof(fileinfo->fullpath), "%s%c%s", paths[i], DEFAULT_SLASH, path_for_open); + if (APC_URL_STAT(wrapper, fileinfo->fullpath, &fileinfo->st_buf) == 0) { found = 1; break; } @@ -331,9 +339,9 @@ int apc_search_paths(const char* filename, const char* path, apc_fileinfo_t* fil /* not: [no active file] or no path */ memcpy(fileinfo->fullpath, exec_fname, exec_fname_length); fileinfo->fullpath[exec_fname_length] = DEFAULT_SLASH; - strcpy(fileinfo->fullpath +exec_fname_length +1, filename); - /* apc_wprint("filename: %s, exec_fname: %s, fileinfo->fullpath: %s", filename, exec_fname, fileinfo->fullpath); */ - if (apc_stat(fileinfo->fullpath, &fileinfo->st_buf) == 0) { + strlcpy(fileinfo->fullpath +exec_fname_length +1, path_for_open,sizeof(fileinfo->fullpath)-exec_fname_length-1); + /* apc_wprint("filename: %s, exec_fname: %s, fileinfo->fullpath: %s", path_for_open, exec_fname, fileinfo->fullpath); */ + if (APC_URL_STAT(wrapper, fileinfo->fullpath, &fileinfo->st_buf) == 0) { found = 1; } }