/* This returns a MALLOCED string */ char *SLpath_dircat (SLFUTURE_CONST char *dir, SLFUTURE_CONST char *name) { unsigned int len, dirlen; char *file; #ifndef VMS int requires_fixup; #endif if (name == NULL) name = ""; if ((dir == NULL) #if !TEST_VMS_ON_UNIX || (SLpath_is_absolute_path (name)) #endif ) dir = ""; /* Both VMS and MSDOS have default directories associated with each drive. * That is, the meaning of something like C:X depends upon more than just * the syntax of the string. Since this concept has more power under VMS * it will be honored here. However, I am going to treat C:X as C:\X * under MSDOS. * * Note!!! * VMS has problems of its own regarding path names, so I am simply * going to strcat. Hopefully the VMS RTL is smart enough to deal with * the result. */ dirlen = strlen (dir); #ifndef VMS # if TEST_VMS_ON_UNIX requires_fixup = 0; # else requires_fixup = (dirlen && (0 == IS_PATH_SEP(dir[dirlen - 1]))); # endif #endif len = dirlen + strlen (name) + 2; if (NULL == (file = (char *)SLmalloc (len))) return NULL; strcpy (file, dir); #ifndef VMS if (requires_fixup) file[dirlen++] = PATH_SEP; #endif strcpy (file + dirlen, name); #if defined(IBMPC_SYSTEM) convert_slashes (file); #endif #if TEST_VMS_ON_UNIX || defined (VMS) return vms_fixup_filename (file); #else return file; #endif }
/* By relatively-absolute, I mean paths of the form ./foo, * and ../foo/bar. But not foo/bar. */ static int is_relatively_absolute (SLFUTURE_CONST char *file) { if (file == NULL) return -1; if (SLpath_is_absolute_path (file)) return 1; #if defined(VMS) return (*file == '['); #else if (*file == '.') file++; if (*file == '.') file++; return (*file == PATH_SEP); #endif }
static int path_is_absolute_path (char *s) { return SLpath_is_absolute_path (s); }