• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ IS_SLASH函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中IS_SLASH函数的典型用法代码示例。如果您正苦于以下问题:C++ IS_SLASH函数的具体用法?C++ IS_SLASH怎么用?C++ IS_SLASH使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了IS_SLASH函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:Apple-FOSS-Mirror,项目名称:CF,代码行数:32,代码来源:CFFileUtilities.c


示例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;
}
开发者ID:egraba,项目名称:kbuild_openbsd,代码行数:44,代码来源:kbuild_protection.c


示例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;
}
开发者ID:ASSmodeus,项目名称:dsploit,代码行数:32,代码来源:FileName.cpp


示例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;
}
开发者ID:tovchenko,项目名称:dCocoa,代码行数:30,代码来源:dString.cpp


示例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;
}
开发者ID:AhmadTux,项目名称:DragonFlyBSD,代码行数:59,代码来源:files.c


示例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;
}
开发者ID:zhangzm,项目名称:EnvTool,代码行数:15,代码来源:misc.c


示例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;
}
开发者ID:CodaFi,项目名称:swift-corelibs-foundation,代码行数:53,代码来源:CFFileUtilities.c


示例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);
}
开发者ID:zhangzm,项目名称:EnvTool,代码行数:56,代码来源:misc.c


示例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]);
}
开发者ID:HansN,项目名称:otp,代码行数:53,代码来源:win_prim_file.c


示例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;
}
开发者ID:AhmadTux,项目名称:DragonFlyBSD,代码行数:16,代码来源:files.c


示例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);
}
开发者ID:tovchenko,项目名称:dCocoa,代码行数:15,代码来源:dString.cpp


示例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);
}
开发者ID:Apple-FOSS-Mirror,项目名称:CF,代码行数:15,代码来源:CFFileUtilities.c


示例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);
	}
}
开发者ID:Distrotech,项目名称:php-src,代码行数:27,代码来源:php_ini.c


示例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;
}
开发者ID:ejasiunas,项目名称:bbclean-xzero450,代码行数:7,代码来源:moreutils.c


示例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;
}
开发者ID:0x4d52,项目名称:JavaScriptCore-X,代码行数:28,代码来源:CFFileUtilities.c


示例16: _CFCreateLastPathComponent

CF_PRIVATE CFStringRef _CFCreateLastPathComponent(CFAllocatorRef alloc, CFStringRef path, CFIndex *slashIndex) {
    CFIndex len = CFStringGetLength(path);
    if (len < 2) {
        // Can't be any path components in a string this short
        if (slashIndex) *slashIndex = -1;
        return (CFStringRef)CFRetain(path);
    }
    
    // Find the last slash
    for (CFIndex i = len - 1; i >= 0; i--) {
        if (IS_SLASH(CFStringGetCharacterAtIndex(path, i))) {
            if (slashIndex) *slashIndex = i;
            return CFStringCreateWithSubstring(alloc, path, CFRangeMake(i + 1, len - i - 1));
        }
    }
    
    // Strip any drive if we have one
    if (len > 2 && _hasDrive(path)) {
        if (slashIndex) *slashIndex = -1;
        return CFStringCreateWithSubstring(alloc, path, CFRangeMake(2, len - 2));
    }
    
    // No slash, so just return the same string
    if (slashIndex) *slashIndex = -1;
    return (CFStringRef)CFRetain(path);
}
开发者ID:CodaFi,项目名称:swift-corelibs-foundation,代码行数:26,代码来源:CFFileUtilities.c


示例17: _CFAppendConditionalTrailingPathSlash2

CF_PRIVATE void _CFAppendConditionalTrailingPathSlash2(CFMutableStringRef path) {
    static const UniChar slash[1] = { CFPreferredSlash };
    UniChar character = CFStringGetCharacterAtIndex((CFStringRef)path, CFStringGetLength(path) - 1);
    if (!IS_SLASH(character)) {
        CFStringAppendCharacters(path, slash, 1);
    }
}
开发者ID:CodaFi,项目名称:swift-corelibs-foundation,代码行数:7,代码来源:CFFileUtilities.c


示例18: _CFStripTrailingPathSlashes

__private_extern__ Boolean _CFStripTrailingPathSlashes(UniChar *unichars, CFIndex *length) {
    Boolean destHasDrive = (1 < *length) && HAS_DRIVE(unichars);
    CFIndex oldLength = *length;
    while (((destHasDrive && 3 < *length) || (!destHasDrive && 1 < *length)) && IS_SLASH(unichars[*length - 1])) {
        (*length)--;
    }
    return (oldLength != *length);
}
开发者ID:Apple-FOSS-Mirror,项目名称:CF,代码行数:8,代码来源:CFFileUtilities.c


示例19: _CFAppendPathExtension

__private_extern__ Boolean _CFAppendPathExtension(UniChar *unichars, CFIndex *length, CFIndex maxLength, UniChar *extension, CFIndex extensionLength) {
    if (maxLength < *length + 1 + extensionLength) {
        return false;
    }
    if ((0 < extensionLength && IS_SLASH(extension[0])) || (1 < extensionLength && HAS_DRIVE(extension))) {
        return false;
    }
    _CFStripTrailingPathSlashes(unichars, length);
    switch (*length) {
    case 0:
        return false;
    case 1:
        if (IS_SLASH(unichars[0]) || unichars[0] == '~') {
            return false;
        }
        break;
    case 2:
        if (HAS_DRIVE(unichars) || HAS_NET(unichars)) {
            return false;
        }
        break;
    case 3:
        if (IS_SLASH(unichars[2]) && HAS_DRIVE(unichars)) {
            return false;
        }
        break;
    }
    if (0 < *length && unichars[0] == '~') {
        CFIndex idx;
        Boolean hasSlash = false;
        for (idx = 1; idx < *length; idx++) {
            if (IS_SLASH(unichars[idx])) {
                hasSlash = true;
                break;
            }
        }
        if (!hasSlash) {
            return false;
        }
    }
    unichars[(*length)++] = '.';
    memmove(unichars + *length, extension, extensionLength * sizeof(UniChar));
    *length += extensionLength;
    return true;
}
开发者ID:Apple-FOSS-Mirror,项目名称:CF,代码行数:45,代码来源:CFFileUtilities.c


示例20: strlen

/* concatenate directory / file */
char *join_path(char *buffer, const char *dir, const char *filename)
{
    int l = strlen(dir);
    if (l) {
        memcpy(buffer, dir, l);
        if (!IS_SLASH(buffer[l-1]))
            buffer[l++] = '\\';
    }
    if (filename) {
        while (IS_SLASH(filename[0]))
            ++filename;
        strcpy(buffer + l, filename);
    } else {
        buffer[l] = 0;
        fix_path(buffer);
    }
    return buffer;
}
开发者ID:Jmos,项目名称:bbclean-xzero450,代码行数:19,代码来源:paths.c



注:本文中的IS_SLASH函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ IS_SMC函数代码示例发布时间:2022-05-30
下一篇:
C++ IS_SETLKW函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap