本文整理汇总了C++中IS_SLASH函数的典型用法代码示例。如果您正苦于以下问题:C++ IS_SLASH函数的具体用法?C++ IS_SLASH怎么用?C++ IS_SLASH使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IS_SLASH函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _CFIsAbsolutePath
__private_extern__ Boolean _CFIsAbsolutePath(UniChar *unichars, CFIndex length) {
if (length < 1) {
return false;
}
#if defined(WINDOWS_PATH_SEMANTICS)
if (unichars[0] == '~') {
return true;
}
if (length < 2) {
return false;
}
if (HAS_NET(unichars)) {
return true;
}
if (length < 3) {
return false;
}
if (IS_SLASH(unichars[2]) && HAS_DRIVE(unichars)) {
return true;
}
#elif defined(HFS_PATH_SEMANTICS)
return !IS_SLASH(unichars[0]);
#else
if (unichars[0] == '~') {
return true;
}
if (IS_SLASH(unichars[0])) {
return true;
}
#endif
return false;
}
示例2: countSubPathComponents
/**
* Counts the components in the specified sub path.
* This is a helper for count_path_components.
*
* etc = 1
* etc/ = 1
* etc/x11 = 2
* and so and and so forth.
*/
static int countSubPathComponents(const char *pszPath, int cDepth)
{
for (;;)
{
const char *pszEnd;
size_t cch;
/* skip slashes. */
while (IS_SLASH(*pszPath))
pszPath++;
if (!*pszPath)
break;
/* find end of component. */
pszEnd = pszPath;
while (!IS_SLASH(*pszEnd) && *pszEnd)
pszEnd++;
/* count it, checking for '..' and '.'. */
cch = pszEnd - pszPath;
if (cch == 2 && pszPath[0] == '.' && pszPath[1] == '.')
{
if (cDepth > 0)
cDepth--;
}
else if (cch != 1 || pszPath[0] != '.')
cDepth++;
/* advance */
if (!*pszEnd)
break;
pszPath = pszEnd + 1;
}
return cDepth;
}
示例3: pathName
FileName::FileName(const Firebird::PathName& name) :
pathName(getPool()), directory(getPool()), root(getPool()), extension(getPool())
{
pathName = name;
const char* const start = pathName.c_str();
const char* slash = NULL;
const char* dot = NULL;
const char* rootName = start;
absolute = IS_SLASH (start [0]);
for (const char* p = start; *p; ++p)
{
if (!dot && IS_SLASH (*p))
slash = p;
else if (*p == '.')
dot = p;
}
if (slash)
{
directory.assign (start, (int) (slash - rootName));
rootName = slash + 1;
}
if (dot)
{
extension = dot + 1;
root.assign (rootName, (int) (dot - rootName));
}
else
root = rootName;
}
示例4: string
dString*
dString::pathWithComponents(dArrayT<dString*>* components) {
dString* result = string();
dUInteger loc = 0;
for (dUInteger i = 0, cnt = components->count(); i < cnt; ++i) {
dString* str = components->objectAtIndex(i);
dUInteger len = str->length();
const TCHAR* buffer = str->chars();
if (len >= 1) {
if (IS_SLASH(buffer[len - 1])) --len;
if (0 != len && IS_SLASH(buffer[0])) {
++buffer;
--len;
}
}
if (0 != len) {
result->_setValueToRange(buffer, dMakeRange(loc, len), true);
result->_setValueToRange(SLASH_STR, dMakeRange(loc + len, 1), true);
loc += len + 1;
}
}
result->_chars->removeObjectsInRange(dMakeRange(result->_chars->count() - 2, 2));
result->_chars->addObject(_T('\0'));
return result;
}
示例5: expand_filename
/* Return the expansion of FILENAME. */
char *
expand_filename (char *filename, char *input_name)
{
int i;
if (filename)
{
filename = full_pathname (filename);
if (IS_ABSOLUTE (filename)
|| (*filename == '.' &&
(IS_SLASH (filename[1]) ||
(filename[1] == '.' && IS_SLASH (filename[2])))))
return filename;
}
else
{
filename = filename_non_directory (input_name);
if (!*filename)
{
free (filename);
filename = xstrdup ("noname.texi");
}
for (i = strlen (filename) - 1; i; i--)
if (filename[i] == '.')
break;
if (!i)
i = strlen (filename);
if (i + 6 > (strlen (filename)))
filename = xrealloc (filename, i + 6);
strcpy (filename + i, html ? ".html" : ".info");
return filename;
}
if (IS_ABSOLUTE (input_name))
{
/* Make it so that relative names work. */
char *result;
i = strlen (input_name) - 1;
result = xmalloc (1 + strlen (input_name) + strlen (filename));
strcpy (result, input_name);
while (!IS_SLASH (result[i]) && i)
i--;
if (IS_SLASH (result[i]))
i++;
strcpy (&result[i], filename);
free (filename);
return result;
}
return filename;
}
示例6: return
/*
* Return the left-trimmed place where paths 'p1' and 'p2' are similar.
* Not case sensitive. Treats '/' and '\\' equally.
*/
char *path_ltrim (const char *p1, const char *p2)
{
for ( ; *p1 && *p2; p1++, p2++)
{
if (IS_SLASH(*p1) || IS_SLASH(*p2))
continue;
if (TOUPPER(*p1) != TOUPPER(*p2))
break;
}
return (char*) p1;
}
示例7: _CFAppendPathExtension2
CF_PRIVATE Boolean _CFAppendPathExtension2(CFMutableStringRef path, CFStringRef extension) {
if (!path) {
return false;
}
if (0 < CFStringGetLength(extension) && IS_SLASH(CFStringGetCharacterAtIndex(extension, 0))) {
return false;
}
if (1 < CFStringGetLength(extension)) {
if (_hasDrive(extension)) return false;
}
Boolean destHasDrive = (1 < CFStringGetLength(path)) && _hasDrive(path);
while (((destHasDrive && 3 < CFStringGetLength(path)) || (!destHasDrive && 1 < CFStringGetLength(path))) && IS_SLASH(CFStringGetCharacterAtIndex(path, CFStringGetLength(path) - 1))) {
CFStringDelete(path, CFRangeMake(CFStringGetLength(path) - 1, 1));
}
if (CFStringGetLength(path) == 0) {
return false;
}
UniChar firstChar = CFStringGetCharacterAtIndex(path, 0);
CFIndex newLength = CFStringGetLength(path);
switch (newLength) {
case 0:
return false;
case 1:
if (IS_SLASH(firstChar) || firstChar == '~') {
return false;
}
break;
case 2:
if (_hasDrive(path) || _hasNet(path)) {
return false;
}
break;
case 3:
if (IS_SLASH(CFStringGetCharacterAtIndex(path, 2)) && _hasDrive(path)) {
return false;
}
break;
}
if (0 < newLength && firstChar == '~') {
// Make sure we have a slash in the string
if (!CFStringFindWithOptions(path, CFPreferredSlashStr, CFRangeMake(1, newLength - 1), 0, NULL)) {
return false;
}
}
static const UniChar dotChar = '.';
CFStringAppendCharacters(path, &dotChar, 1);
CFStringAppend(path, extension);
return true;
}
示例8: while
/*
* Return the malloc'ed directory part of a filename.
*/
char *dirname (const char *fname)
{
const char *p = fname;
const char *slash = NULL;
if (fname)
{
size_t dirlen;
char *dirpart;
if (*fname && fname[1] == ':')
{
slash = fname + 1;
p += 2;
}
/* Find the rightmost slash. */
while (*p)
{
if (IS_SLASH(*p))
slash = p;
p++;
}
if (slash == NULL)
{
fname = ".";
dirlen = 1;
}
else
{
/* Remove any trailing slashes. */
while (slash > fname && (IS_SLASH(slash[-1])))
slash--;
/* How long is the directory we will return? */
dirlen = slash - fname + (slash == fname || slash[-1] == ':');
if (*slash == ':' && dirlen == 1)
dirlen += 2;
}
dirpart = MALLOC (dirlen + 1);
if (dirpart)
{
strncpy (dirpart, fname, dirlen);
if (slash && *slash == ':' && dirlen == 3)
dirpart[2] = '.'; /* for "x:foo" return "x:." */
dirpart[dirlen] = '\0';
}
return (dirpart);
}
return (NULL);
}
示例9: is_path_root
/* Mirrors the PathIsRootW function of the shell API, but doesn't choke on
* paths longer than MAX_PATH. */
static int is_path_root(const efile_path_t *path) {
const WCHAR *path_start, *path_end, *path_iterator;
int length;
ASSERT_PATH_FORMAT(path);
if(!IS_LONG_UNC_PATH(PATH_LENGTH(path), path->data)) {
path_start = (WCHAR*)path->data + LP_PREFIX_LENGTH;
length = PATH_LENGTH(path) - LP_PREFIX_LENGTH;
/* A single \ refers to the root of the current working directory. */
if(length == 1) {
return IS_SLASH(path_start[0]);
}
/* Drive letter. */
if(length == 3 && iswalpha(path_start[0]) && path_start[1] == L':') {
return IS_SLASH(path_start[2]);
}
return 0;
}
/* Check whether we're a UNC root, eg. \\server, \\server\share */
path_start = (WCHAR*)path->data + LP_UNC_PREFIX_LENGTH;
length = PATH_LENGTH(path) - LP_UNC_PREFIX_LENGTH;
path_end = &path_start[length];
path_iterator = path_start;
/* Server name must be at least one character. */
if(length <= 1) {
return 0;
}
/* Slide to the slash between the server and share names, if present. */
while(path_iterator < path_end && !IS_SLASH(*path_iterator)) {
path_iterator++;
}
/* Slide past the end of the string, stopping at the first slash we
* encounter. */
do {
path_iterator++;
} while(path_iterator < path_end && !IS_SLASH(*path_iterator));
/* If we're past the end of the string and it didnt't end with a slash,
* then we're a root path. */
return path_iterator >= path_end && !IS_SLASH(path_start[length - 1]);
}
示例10: skip_directory_part
/* Return the index of the first character in the filename
which is past all the leading directory characters. */
static int
skip_directory_part (char *filename)
{
int i = strlen (filename) - 1;
while (i && !IS_SLASH (filename[i]))
i--;
if (IS_SLASH (filename[i]))
i++;
else if (filename[i] && HAVE_DRIVE (filename))
i = 2;
return i;
}
示例11: length
dString*
dString::stringByDeletingPathExtension() const {
dUInteger len = length();
const TCHAR* buffer = chars();
if (len > 1 && IS_SLASH(buffer[len - 1]))
--len;
for (dUInteger i = len; --i > 0;) {
if (IS_SLASH(buffer[i]) || IS_SLASH(buffer[i - 1])) break;
else if (buffer[i] == _T('.')) return stringWithCharacters(buffer, i);
}
return stringWithCharacters(buffer, len);
}
示例12: _CFTransmutePathSlashes
__private_extern__ Boolean _CFTransmutePathSlashes(UniChar *unichars, CFIndex *length, UniChar replSlash) {
CFIndex didx, sidx, scnt = *length;
sidx = (1 < *length && HAS_NET(unichars)) ? 2 : 0;
didx = sidx;
while (sidx < scnt) {
if (IS_SLASH(unichars[sidx])) {
unichars[didx++] = replSlash;
for (sidx++; sidx < scnt && IS_SLASH(unichars[sidx]); sidx++);
} else {
unichars[didx++] = unichars[sidx++];
}
}
*length = didx;
return (scnt != didx);
}
示例13: php_load_zend_extension_cb
/* {{{ php_load_zend_extension_cb
*/
static void php_load_zend_extension_cb(void *arg)
{
char *filename = *((char **) arg);
const int length = (int)strlen(filename);
#ifndef PHP_WIN32
(void) length;
#endif
if (IS_ABSOLUTE_PATH(filename, length)) {
zend_load_extension(filename);
} else {
char *libpath;
char *extension_dir = INI_STR("extension_dir");
int extension_dir_len = (int)strlen(extension_dir);
if (IS_SLASH(extension_dir[extension_dir_len-1])) {
spprintf(&libpath, 0, "%s%s", extension_dir, filename);
} else {
spprintf(&libpath, 0, "%s%c%s", extension_dir, DEFAULT_SLASH, filename);
}
zend_load_extension(libpath);
efree(libpath);
}
}
示例14: memcpy
char *add_slash(char *d, const char *s)
{
int l; memcpy(d, s, l = (int)strlen(s));
if (l && !IS_SLASH(d[l-1])) d[l++] = '\\';
d[l] = 0;
return d;
}
示例15: _CFAppendPathComponent
__private_extern__ Boolean _CFAppendPathComponent(UniChar *unichars, CFIndex *length, CFIndex maxLength, UniChar *component, CFIndex componentLength) {
if (0 == componentLength) {
return true;
}
if (maxLength < *length + 1 + componentLength) {
return false;
}
switch (*length) {
case 0:
break;
case 1:
if (!IS_SLASH(unichars[0])) {
unichars[(*length)++] = CFPreferredSlash;
}
break;
case 2:
if (!HAS_DRIVE(unichars) && !HAS_NET(unichars)) {
unichars[(*length)++] = CFPreferredSlash;
}
break;
default:
unichars[(*length)++] = CFPreferredSlash;
break;
}
memmove(unichars + *length, component, componentLength * sizeof(UniChar));
*length += componentLength;
return true;
}