mirror of
https://github.com/php/php-src.git
synced 2024-09-21 09:57:23 +00:00
Add virtual_real_chdir_file. Silly name for a useful function.
This commit is contained in:
parent
f75db1e3cb
commit
c86ec8b1a9
@ -324,7 +324,7 @@ PHPAPI int cfg_get_string(char *varname, char **result);
|
||||
#define V_OPEN(open_args) open open_args
|
||||
#define V_CREAT(path, mode) creat(path, mode)
|
||||
#define V_CHDIR(path) chdir(path)
|
||||
#define V_CHDIR_FILE(path) chdir_file(path)
|
||||
#define V_CHDIR_FILE(path) virtual_real_chdir_file(path)
|
||||
#define V_GETWD(buf) getwd(buf)
|
||||
#define V_STAT(path, buff) stat(path, buff)
|
||||
#define V_LSTAT(path, buff) lstat(path, buff)
|
||||
|
@ -745,6 +745,26 @@ CWD_API FILE *virtual_popen(const char *command, const char *type)
|
||||
|
||||
#endif
|
||||
|
||||
/* taken from Apache 1.3 */
|
||||
|
||||
CWD_API void virtual_real_chdir_file(const char *file)
|
||||
{
|
||||
const char *x;
|
||||
char buf[4096];
|
||||
|
||||
x = strrchr(file, '/');
|
||||
if (x == NULL) {
|
||||
chdir(file);
|
||||
}
|
||||
else if (x - file < sizeof(buf) - 1) {
|
||||
memcpy(buf, file, x - file);
|
||||
buf[x - file] = '\0';
|
||||
chdir(buf);
|
||||
}
|
||||
/* XXX: well, this is a silly function, no method of reporting an
|
||||
* error... ah well. */
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
main(void)
|
||||
|
@ -78,6 +78,7 @@ CWD_API char *virtual_getcwd_ex(int *length);
|
||||
CWD_API char *virtual_getcwd(char *buf, size_t size);
|
||||
CWD_API int virtual_chdir(char *path);
|
||||
CWD_API int virtual_chdir_file(char *path);
|
||||
CWD_API int virtual_real_chdir_file(char *path);
|
||||
CWD_API int virtual_filepath(char *path, char **filepath);
|
||||
CWD_API char *virtual_realpath(char *path, char *real_path);
|
||||
CWD_API FILE *virtual_fopen(const char *path, const char *mode);
|
||||
|
Loading…
Reference in New Issue
Block a user