本文整理汇总了C++中IsFileSep函数的典型用法代码示例。如果您正苦于以下问题:C++ IsFileSep函数的具体用法?C++ IsFileSep怎么用?C++ IsFileSep使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IsFileSep函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IsAbsoluteFileName
int IsAbsoluteFileName(const char *f)
{
int off = 0;
// Check for quoted strings
for (off = 0; f[off] == '\"'; off++)
{
}
#ifdef _WIN32
if (IsFileSep(f[off]) && IsFileSep(f[off + 1]))
{
return true;
}
if (isalpha(f[off]) && f[off + 1] == ':' && IsFileSep(f[off + 2]))
{
return true;
}
#endif
if (f[off] == '/')
{
return true;
}
return false;
}
示例2: CompressPath
int CompressPath(char *dest, const char *src)
{
char node[CF_BUFSIZE];
int nodelen;
int rootlen;
memset(dest, 0, CF_BUFSIZE);
rootlen = RootDirLength(src);
strncpy(dest, src, rootlen);
for (const char *sp = src + rootlen; *sp != '\0'; sp++)
{
if (IsFileSep(*sp))
{
continue;
}
for (nodelen = 0; (sp[nodelen] != '\0') && (!IsFileSep(sp[nodelen])); nodelen++)
{
if (nodelen > CF_MAXLINKSIZE)
{
Log(LOG_LEVEL_ERR, "Link in path suspiciously large");
return false;
}
}
strncpy(node, sp, nodelen);
node[nodelen] = '\0';
sp += nodelen - 1;
if (strcmp(node, ".") == 0)
{
continue;
}
if (strcmp(node, "..") == 0)
{
if (!ChopLastNode(dest))
{
Log(LOG_LEVEL_DEBUG, "used .. beyond top of filesystem!");
return false;
}
continue;
}
else
{
AddSlash(dest);
}
if (!JoinPath(dest, node))
{
return false;
}
}
return true;
}
示例3: StringWriter
char *MapNameCopy(const char *s)
{
Writer *w = StringWriter();
/* c:\a\b -> /cygdrive/c\a\b */
if (s[0] && isalpha(s[0]) && s[1] == ':')
{
WriterWriteF(w, "/cygdrive/%c", s[0]);
s += 2;
}
for (; *s; s++)
{
/* a//b//c -> a/b/c */
/* a\\b\\c -> a\b\c */
if (IsFileSep(*s) && IsFileSep(*(s + 1)))
{
continue;
}
/* a\b\c -> a/b/c */
WriterWriteChar(w, *s == '\\' ? '/' : *s);
}
return StringWriterClose(w);
}
示例4: DeleteRedundantSlashes
void DeleteRedundantSlashes(char *str)
{
int move_from;
// Invariant: newpos <= oldpos
int oldpos = RootDirLength(str);
int newpos = oldpos;
while (str[oldpos] != '\0')
{
// Skip over subsequent separators.
while (IsFileSep(str[oldpos]))
{
oldpos++;
}
move_from = oldpos;
// And then skip over the next path component.
while (str[oldpos] != '\0' && !IsFileSep(str[oldpos]))
{
oldpos++;
}
// If next character is file separator, move past it, since we want to keep one.
if (IsFileSep(str[oldpos]))
{
oldpos++;
}
int move_len = oldpos - move_from;
memmove(&str[newpos], &str[move_from], move_len);
newpos += move_len;
}
str[newpos] = '\0';
}
示例5: RootDirLength
int RootDirLength(char *f)
/* Return length of Initial directory in path - */
{
#ifdef NT
int len;
if (IsFileSep(f[0]) && IsFileSep(f[1]))
{
/* UNC style path */
/* Skip over host name */
for (len=2; !IsFileSep(f[len]); len++)
{
if (f[len] == '\0')
{
return len;
}
}
/* Skip over share name */
for (len++; !IsFileSep(f[len]); len++)
{
if (f[len] == '\0')
{
return len;
}
}
/* Skip over file separator */
len++;
return len;
}
if ( isalpha(f[0]) && f[1] == ':' && IsFileSep(f[2]) )
{
return 3;
}
#endif
if (*f == '/')
{
return 1;
}
return 0;
}
示例6: NTRootDirLength
static int NTRootDirLength(const char *f)
{
int len;
if (IsFileSep(f[0]) && IsFileSep(f[1]))
{
/* UNC style path */
/* Skip over host name */
for (len = 2; !IsFileSep(f[len]); len++)
{
if (f[len] == '\0')
{
return len;
}
}
/* Skip over share name */
for (len++; !IsFileSep(f[len]); len++)
{
if (f[len] == '\0')
{
return len;
}
}
/* Skip over file separator */
len++;
return len;
}
if (isalpha(f[0]) && f[1] == ':')
{
if (IsFileSep(f[2]))
{
return 3;
}
return 2;
}
return UnixRootDirLength(f);
}
示例7: UnixRootDirLength
static int UnixRootDirLength(const char *f)
{
if (IsFileSep(*f))
{
return 1;
}
return 0;
}
示例8: IsAbsPath
int IsAbsPath(const char *path)
{
if (IsFileSep(*path))
{
return true;
}
else
{
return false;
}
}
示例9: IsAbsoluteFileName
int IsAbsoluteFileName(char *f)
{
#ifdef NT
if (IsFileSep(f[0]) && IsFileSep(f[1]))
{
return true;
}
if ( isalpha(f[0]) && f[1] == ':' && IsFileSep(f[2]) )
{
return true;
}
#endif
if (*f == '/')
{
return true;
}
return false;
}
示例10: AddSlash
void AddSlash(char *str)
{
char *sp, *sep = FILE_SEPARATOR_STR;
int f = false, b = false;
if (str == NULL)
{
return;
}
// add root slash on Unix systems
if (strlen(str) == 0)
{
#if !defined(_WIN32)
strcpy(str, "/");
#endif
return;
}
/* Try to see what convention is being used for filenames
in case this is a cross-system copy from Win/Unix */
for (sp = str; *sp != '\0'; sp++)
{
switch (*sp)
{
case '/':
f = true;
break;
case '\\':
b = true;
break;
default:
break;
}
}
if (f && (!b))
{
sep = "/";
}
else if (b && (!f))
{
sep = "\\";
}
if (!IsFileSep(str[strlen(str) - 1]))
{
strcat(str, sep);
}
}
示例11: DeleteSlash
// Can remove several slashes if they are redundant.
void DeleteSlash(char *str)
{
int size = strlen(str);
if ((size == 0) || (str == NULL))
{
return;
}
int root = RootDirLength(str);
while (IsFileSep(str[size - 1]) && size - 1 > root)
{
size--;
}
str[size] = '\0'; /* no-op if we didn't change size */
}
示例12: DeleteSlash
void DeleteSlash(char *str)
{
if ((strlen(str) == 0) || (str == NULL))
{
return;
}
if (strcmp(str, "/") == 0)
{
return;
}
if (IsFileSep(str[strlen(str) - 1]))
{
str[strlen(str) - 1] = '\0';
}
}
示例13: assert
const char *FirstFileSeparator(const char *str)
{
assert(str);
assert(strlen(str) > 0);
if(strncmp(str, "\\\\", 2) == 0) // windows share
{
return str + 1;
}
for(const char *pos = str; *pos != '\0'; pos++)
{
if(IsFileSep(*pos))
{
return pos;
}
}
return NULL;
}
示例14: strlen
const char *LastFileSeparator(const char *str)
/* Return pointer to last file separator in string, or NULL if
string does not contains any file separtors */
{
const char *sp;
/* Walk through string backwards */
sp = str + strlen(str) - 1;
while (sp >= str)
{
if (IsFileSep(*sp))
{
return sp;
}
sp--;
}
return NULL;
}
示例15: CompressPath
int CompressPath(char *dest,char *src)
{ char *sp;
char node[CF_BUFSIZE];
int nodelen;
int rootlen;
Debug2("CompressPath(%s,%s)\n",dest,src);
memset(dest,0,CF_BUFSIZE);
rootlen = RootDirLength(src);
strncpy(dest,src,rootlen);
for (sp = src+rootlen; *sp != '\0'; sp++)
{
if (IsFileSep(*sp))
{
continue;
}
for (nodelen = 0; sp[nodelen] != '\0' && !IsFileSep(sp[nodelen]); nodelen++)
{
if (nodelen > CF_MAXLINKSIZE)
{
CfLog(cferror,"Link in path suspiciously large","");
return false;
}
}
strncpy(node, sp, nodelen);
node[nodelen] = '\0';
sp += nodelen - 1;
if (strcmp(node,".") == 0)
{
continue;
}
if (strcmp(node,"..") == 0)
{
if (!ChopLastNode(dest))
{
Debug("cfengine: used .. beyond top of filesystem!\n");
return false;
}
continue;
}
else
{
AddSlash(dest);
}
if (BufferOverflow(dest,node))
{
return false;
}
strcat(dest,node);
}
return true;
}