summaryrefslogtreecommitdiff
path: root/command_line/CmdLine/Src/OSLib/Posix.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--command_line/CmdLine/Src/OSLib/Posix.c36
1 files changed, 17 insertions, 19 deletions
diff --git a/command_line/CmdLine/Src/OSLib/Posix.c b/command_line/CmdLine/Src/OSLib/Posix.c
index e836653..dc22651 100644
--- a/command_line/CmdLine/Src/OSLib/Posix.c
+++ b/command_line/CmdLine/Src/OSLib/Posix.c
@@ -31,7 +31,7 @@ int _plen = strlen((spec)->s); \
if (_plen >= sizeof(pathbuf)) return 63;\
memcpy((pathbuf), (spec)->s, _plen + 1);\
if (_plen > 1) { \
-if ((pathbuf)[_plen - 1] == '/') \
+if ((pathbuf)[_plen - 1] == OS_PATHSEP) \
(pathbuf)[_plen - 1] = 0; \
} \
} while (0)
@@ -260,7 +260,7 @@ int OS_GetCWD(OSPathSpec *spec) {
return errno;
ptr = &spec->s[strlen(spec->s)];
- if (ptr[-1] != '/')
+ if (ptr[-1] != OS_PATHSEP)
strcpy(ptr, "/");
return 0;
}
@@ -332,15 +332,13 @@ int OS_IsLegalPath(const char *path) {
fnlen = 0;
while (*scan) {
- if (*scan == '/')
+ if (*scan == OS_PATHSEP)
fnlen = 0;
else
fnlen++;
++pthlen;
if (fnlen > 63 || pthlen > 255)
return ENAMETOOLONG;
- //if ((fnlen = (*scan == '/') ? 0 : (fnlen + 1)) > 63 || ++pthlen > 255)
- // return ENAMETOOLONG;
++scan;
}
@@ -348,7 +346,7 @@ int OS_IsLegalPath(const char *path) {
}
int OS_IsFullPath(const char *path) {
- return path[0] == '/';
+ return path[0] == OS_PATHSEP;
}
char *OS_GetDirPtr(char *path) {
@@ -375,7 +373,7 @@ static int OS_CompactPath(char *src, char *dst) {
to = bptr;
while (*from) {
brk = from + 1;
- while (*brk && *brk != '/')
+ while (*brk && *brk != OS_PATHSEP)
++brk;
if ((brk - from) == 1) {
@@ -386,7 +384,7 @@ static int OS_CompactPath(char *src, char *dst) {
if (to > bptr) {
do {
to--;
- } while (to >= bptr && *to != '/');
+ } while (to >= bptr && *to != OS_PATHSEP);
}
from = brk;
} else {
@@ -396,8 +394,8 @@ static int OS_CompactPath(char *src, char *dst) {
}
}
- if (to == bptr || from[-1] == '/')
- *(to++) = '/';
+ if (to == bptr || from[-1] == OS_PATHSEP)
+ *(to++) = OS_PATHSEP;
*to = 0;
if (!dst)
@@ -421,7 +419,7 @@ int OS_CanonPath(char *src, char *dst) {
for (idx = 0; src[idx]; idx++) {
if (src[idx] == '\\')
- dst[idx] = '/';
+ dst[idx] = OS_PATHSEP;
else
dst[idx] = src[idx];
}
@@ -451,8 +449,8 @@ int OS_MakeSpec(const char *path, OSSpec *spec, Boolean *isfile) {
return errno;
ptr = tmp + strlen(tmp) - 1;
- if (ptr[0] != '/') {
- ptr[1] = '/';
+ if (ptr[0] != OS_PATHSEP) {
+ ptr[1] = OS_PATHSEP;
ptr[2] = 0;
ptr += 2;
}
@@ -475,12 +473,12 @@ int OS_MakeSpec(const char *path, OSSpec *spec, Boolean *isfile) {
if (!stat(tmp, &st)) {
ptr = tmp + strlen(tmp);
- if (ptr[-1] == '/')
+ if (ptr[-1] == OS_PATHSEP)
ptr--;
if ((st.st_mode & S_IFMT) == S_IFDIR) {
if (isfile)
*isfile = 0;
- ptr[0] = '/';
+ ptr[0] = OS_PATHSEP;
ptr++;
} else {
if (isfile)
@@ -494,7 +492,7 @@ int OS_MakeSpec(const char *path, OSSpec *spec, Boolean *isfile) {
*isfile = 1;
}
- ptr = strrchr(tmp, '/') + 1;
+ ptr = strrchr(tmp, OS_PATHSEP) + 1;
len = ptr - tmp;
if (len >= 256) {
spec->path.s[0] = 0;
@@ -561,7 +559,7 @@ int OS_MakeNameSpec(const char *name, OSNameSpec *spec) {
spec->s[0] = 0;
if (len > 63)
return ENAMETOOLONG;
- if (strchr(name, '/'))
+ if (strchr(name, OS_PATHSEP))
return EISDIR;
if (strlen(name) > 63)
return ENAMETOOLONG;
@@ -694,7 +692,7 @@ int OS_IsLink(const OSSpec *spec) {
return 0;
ptr = intbuf + strlen(intbuf) - 1;
- if (*ptr == '/')
+ if (*ptr == OS_PATHSEP)
*ptr = 0;
if (lstat(intbuf, &st) < 0)
@@ -716,7 +714,7 @@ int OS_ResolveLink(const OSSpec *link, OSSpec *target) {
return errno;
fn[len] = 0;
- sprintf(path, "%s%s", (fn[0] != '/') ? link->path.s : "", fn);
+ sprintf(path, "%s%s", (fn[0] != OS_PATHSEP) ? link->path.s : "", fn);
return OS_MakeSpec(path, target, 0);
}