]> granicus.if.org Git - php/commitdiff
Provide PHP_SEPARATOR which expands to the default directory separator
authorSascha Schumann <sas@php.net>
Sun, 20 Aug 2000 14:02:57 +0000 (14:02 +0000)
committerSascha Schumann <sas@php.net>
Sun, 20 Aug 2000 14:02:57 +0000 (14:02 +0000)
on the target platform.

ext/session/mod_files.c
main/fopen_wrappers.c
main/php.h

index cc8b7f9a662f7d309b0553174a7fe58db5ff459e..3257186a03fe8b6642a64f706c54474bfe4276c7 100644 (file)
@@ -55,12 +55,6 @@ ps_module ps_mod_files = {
        PS_MOD(files)
 };
 
-#ifdef PHP_WIN32
-#define DIR_DELIMITER '\\'
-#else
-#define DIR_DELIMITER '/'
-#endif
-
 static int _ps_files_valid_key(const char *key)
 {
        size_t len;
@@ -98,10 +92,10 @@ static char *_ps_files_path_create(char *buf, size_t buflen, ps_files *data, con
                        (strlen(data->basedir) + 2 * data->dirdepth + keylen + 5 + sizeof(FILE_PREFIX))) 
                return NULL;
        p = key;
-       n = sprintf(buf, "%s%c", data->basedir, DIR_DELIMITER);
+       n = sprintf(buf, "%s%c", data->basedir, PHP_SEPARATOR);
        for (i = 0; i < data->dirdepth; i++) {
                buf[n++] = *p++;
-               buf[n++] = DIR_DELIMITER;
+               buf[n++] = PHP_SEPARATOR;
        }
        buf[n] = '\0';
        strcat(buf, FILE_PREFIX);
@@ -175,7 +169,7 @@ static int _ps_files_cleanup_dir(const char *dirname, int maxlifetime)
                /* does the file start with our prefix? */
                if (!strncmp(entry->d_name, FILE_PREFIX, sizeof(FILE_PREFIX) - 1) &&
                                /* create full path */
-                               snprintf(buf, MAXPATHLEN, "%s%c%s", dirname, DIR_DELIMITER,
+                               snprintf(buf, MAXPATHLEN, "%s%c%s", dirname, PHP_SEPARATOR,
                                        entry->d_name) > 0 &&
                                /* stat the directory entry */
                                V_STAT(buf, &sbuf) == 0 &&
index bb9cad4b4ae0b5db1bfe13024e3241cf1216f45e..89a24308ffcfe441063385206f0bb76fe990e909 100644 (file)
  * a joint header file when we move virtual_cwd to TSRM */
 #ifdef ZEND_WIN32
 #define IS_SLASH(c)    ((c) == '/' || (c) == '\\')
-#define DEFAULT_SLASH '\\'
 #else
 #define IS_SLASH(c)    ((c) == '/')
-#define DEFAULT_SLASH '/'
 #endif
 
 
@@ -319,8 +317,8 @@ PHPAPI FILE *php_fopen_primary_script(void)
                        if (pw && pw->pw_dir) {
                                filename = emalloc(strlen(PG(user_dir)) + strlen(path_info) + strlen(pw->pw_dir) + 4);
                                if (filename) {
-                                       sprintf(filename, "%s%c%s%c%s", pw->pw_dir, DEFAULT_SLASH,
-                                                               PG(user_dir), DEFAULT_SLASH, s+1); /* Safe */
+                                       sprintf(filename, "%s%c%s%c%s", pw->pw_dir, PHP_SEPARATOR,
+                                                               PG(user_dir), PHP_SEPARATOR, s+1); /* Safe */
                                        STR_FREE(SG(request_info).path_translated);
                                        SG(request_info).path_translated = filename;
                                }
@@ -340,7 +338,7 @@ PHPAPI FILE *php_fopen_primary_script(void)
                        if (filename) {
                                memcpy(filename, PG(doc_root), length);
                                if (!IS_SLASH(filename[length - 1])) {  /* length is never 0 */
-                                       filename[length++] = DEFAULT_SLASH;
+                                       filename[length++] = PHP_SEPARATOR;
                                }
                                if (IS_SLASH(path_info[0])) {
                                        length--;
index b0b25500d5c31f59499289fa15583516a0b648a8..8d8b4c503470767b1773026c3c4da30d8ef4d477 100644 (file)
@@ -65,9 +65,11 @@ extern unsigned char second_arg_allow_ref[];
 #      else
 #      define PHPAPI __declspec(dllimport) 
 #      endif
+#define PHP_SEPARATOR '\\'
 #else
 #define PHPAPI
 #define THREAD_LS
+#define PHP_SEPARATOR '/'
 #endif
 
 #include "php_regex.h"