当前位置: 首页>>代码示例>>C++>>正文


C++ IS_DIR_SEPARATOR函数代码示例

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


在下文中一共展示了IS_DIR_SEPARATOR函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: lprofApplyPathPrefix

COMPILER_RT_VISIBILITY void
lprofApplyPathPrefix(char *Dest, const char *PathStr, const char *Prefix,
                     size_t PrefixLen, int PrefixStrip) {

  const char *Ptr;
  int Level;
  const char *StrippedPathStr = PathStr;

  for (Level = 0, Ptr = PathStr + 1; Level < PrefixStrip; ++Ptr) {
    if (*Ptr == '\0')
      break;

    if (!IS_DIR_SEPARATOR(*Ptr))
      continue;

    StrippedPathStr = Ptr;
    ++Level;
  }

  memcpy(Dest, Prefix, PrefixLen);

  if (!IS_DIR_SEPARATOR(Prefix[PrefixLen - 1]))
    Dest[PrefixLen++] = DIR_SEPARATOR;

  memcpy(Dest + PrefixLen, StrippedPathStr, strlen(StrippedPathStr) + 1);
}
开发者ID:CTSRD-CHERI,项目名称:cheribsd,代码行数:26,代码来源:InstrProfilingUtil.c

示例2: apply_vpath

/* If T begins with any of the partial pathnames listed in d->vpathv,
   then advance T to point beyond that pathname.  */
static const char *
apply_vpath (struct deps *d, const char *t)
{
  if (d->vpathv)
    {
      unsigned int i;
      for (i = 0; i < d->nvpaths; i++)
	{
	  if (!strncmp (d->vpathv[i], t, d->vpathlv[i]))
	    {
	      const char *p = t + d->vpathlv[i];
	      if (!IS_DIR_SEPARATOR (*p))
		goto not_this_one;

	      /* Do not simplify $(vpath)/../whatever.  ??? Might not
		 be necessary. */
	      if (p[1] == '.' && p[2] == '.' && IS_DIR_SEPARATOR (p[3]))
		goto not_this_one;

	      /* found a match */
	      t = t + d->vpathlv[i] + 1;
	      break;
	    }
	not_this_one:;
	}
    }

  /* Remove leading ./ in any case.  */
  while (t[0] == '.' && IS_DIR_SEPARATOR (t[1]))
    t += 2;

  return t;
}
开发者ID:DJHartley,项目名称:iphone-dev,代码行数:35,代码来源:mkdeps.c

示例3: mkdir_p

int
mkdir_p (const char *path, int mode)
{
  int len;
  char *new_path;
  int ret = 0;

  new_path = (char *) malloc (strlen(path) + 1);
  strcpy (new_path, path);

  len = strlen (new_path);
  while (len > 0 && IS_DIR_SEPARATOR(new_path[len-1]))
    {
      new_path[len-1] = 0;
      len--;
    }

#if defined(_MSC_VER) || defined(__MINGW32__)
  while (!_mkdir (new_path))
#else
  while (!mkdir (new_path, mode))
#endif
    {
      char *slash;
      int last_error = errno;
      if (last_error == EEXIST)
        break;
      if (last_error != ENOENT)
        {
          ret = -1;
          break;
        }
      slash = new_path + strlen (new_path);
      while (slash > new_path && !IS_DIR_SEPARATOR(*slash))
        slash--;
      if (slash == new_path)
        {
          ret = -1;
          break;
        }
      len = slash - new_path;
      new_path[len] = 0;
      if (!mkdir_p (new_path, mode))
        {
          ret = -1;
          break;
        }
      new_path[len] = '/';
    }
    free (new_path);
    return ret;
}
开发者ID:GNsunghokim,项目名称:rtos,代码行数:52,代码来源:test_common.c

示例4: strip_path_and_suffix

static char *
strip_path_and_suffix (const char *full_name, const char *new_suffix)
{
  char *name;
  char *p;

  if (!full_name || !new_suffix)
    return NULL;

  /* Strip path name.  */
  p = (char *)full_name + strlen (full_name);
  while (p != full_name && !IS_DIR_SEPARATOR (p[-1]))
    --p;

  /* Now 'p' is a file name with suffix.  */
  name = (char *) malloc (strlen (p) + 1 + strlen (new_suffix));

  strcpy (name, p);

  p = name + strlen (name);
  while (p != name && *p != '.')
    --p;

  /* If did not reach at the beginning of name then '.' is found.
     Replace '.' with NULL.  */
  if (p != name)
    *p = '\0';

  strcat (name, new_suffix);
  return name;
}
开发者ID:IntegerCompany,项目名称:linaro-android-gcc,代码行数:31,代码来源:driverdriver.c

示例5: add_new_plugin

void
add_new_plugin (const char* plugin_name)
{
  struct plugin_name_args *plugin;
  void **slot;
  char *base_name;
  bool name_is_short;
  const char *pc;

  flag_plugin_added = true;

  /* Replace short names by their full path when relevant.  */
  name_is_short  = !IS_ABSOLUTE_PATH (plugin_name);
  for (pc = plugin_name; name_is_short && *pc; pc++)
    if (*pc == '.' || IS_DIR_SEPARATOR (*pc))
      name_is_short = false;

  if (name_is_short)
    {
      base_name = CONST_CAST (char*, plugin_name);
      /* FIXME: the ".so" suffix is currently builtin, since plugins
	 only work on ELF host systems like e.g. Linux or Solaris.
	 When plugins shall be available on non ELF systems such as
	 Windows or MacOS, this code has to be greatly improved.  */
      plugin_name = concat (default_plugin_dir_name (), "/",
			    plugin_name, ".so", NULL);
      if (access (plugin_name, R_OK))
	fatal_error
	  ("inacessible plugin file %s expanded from short plugin name %s: %m",
	   plugin_name, base_name);
    }
  else
开发者ID:AsherBond,项目名称:MondocosmOS-Dependencies,代码行数:32,代码来源:plugin.c

示例6: is_sysrooted_pathname

static bfd_boolean
is_sysrooted_pathname (const char *name, bfd_boolean notsame)
{
  char * realname = ld_canon_sysroot ? lrealpath (name) : NULL;
  int len;
  bfd_boolean result;

  if (! realname)
    return FALSE;

  len = strlen (realname);

  if (((! notsame && len == ld_canon_sysroot_len)
       || (len >= ld_canon_sysroot_len
	   && IS_DIR_SEPARATOR (realname[ld_canon_sysroot_len])
	   && (realname[ld_canon_sysroot_len] = '\0') == '\0'))
      && FILENAME_CMP (ld_canon_sysroot, realname) == 0)
    result = TRUE;
  else
    result = FALSE;

  if (realname)
    free (realname);

  return result;
}
开发者ID:Akheon23,项目名称:nvopencc,代码行数:26,代码来源:ldfile.c

示例7: child_path

const char *
child_path (const char *parent, const char *child)
{
  /* The child path must start with the parent path.  */
  size_t parent_len = strlen (parent);
  if (filename_ncmp (parent, child, parent_len) != 0)
    return NULL;

  /* The parent path must be a directory and the child must contain at
     least one component underneath the parent.  */
  const char *child_component;
  if (IS_DIR_SEPARATOR (parent[parent_len - 1]))
    {
      /* The parent path ends in a directory separator, so it is a
	 directory.  The first child component starts after the common
	 prefix.  */
      child_component = child + parent_len;
    }
  else
    {
      /* The parent path does not end in a directory separator.  The
	 first character in the child after the common prefix must be
	 a directory separator.

	 Note that CHILD must hold at least parent_len characters for
	 filename_ncmp to return zero.  If the character at parent_len
	 is nul due to CHILD containing the same path as PARENT, the
	 IS_DIR_SEPARATOR check will fail here.  */
      if (!IS_DIR_SEPARATOR (child[parent_len]))
	return NULL;

      /* The first child component starts after the separator after the
	 common prefix.  */
      child_component = child + parent_len + 1;
    }

  /* The child must contain at least one non-separator character after
     the parent.  */
  while (*child_component != '\0')
    {
      if (!IS_DIR_SEPARATOR (*child_component))
	return child_component;

      child_component++;
    }
  return NULL;
}
开发者ID:T-J-Teru,项目名称:binutils-gdb,代码行数:47,代码来源:pathstuff.c

示例8: IS_DIR_SEPARATOR

/* Define IS_DIR_SEPARATOR.  */
#ifndef DIR_SEPARATOR_2
# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
#else /* DIR_SEPARATOR_2 */
# define IS_DIR_SEPARATOR(ch) \
	(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
#endif /* DIR_SEPARATOR_2 */
char *basename (const char *name) {
  const char *base;
  for (base = name; *name; name++) {
    if (IS_DIR_SEPARATOR (*name)) {
	    base = name + 1;
	  }
  }
  return (char *) base;
}
开发者ID:orez-,项目名称:imgserver,代码行数:16,代码来源:client.c

示例9: get_prog_name_len

static int
get_prog_name_len (const char *prog)
{
  int result = 0;
  const char *progend = prog + strlen(prog);
  const char *progname = progend;
  while (progname != prog && !IS_DIR_SEPARATOR (progname[-1]))
    --progname;
  return progend-progname;
}
开发者ID:IntegerCompany,项目名称:linaro-android-gcc,代码行数:10,代码来源:driverdriver.c

示例10: create_file_directory

static int
create_file_directory (char *filename)
{
#if !defined(TARGET_POSIX_IO) && !defined(_WIN32)
  (void) filename;
  return -1;
#else
  char *s;

  s = filename;

  if (HAS_DRIVE_SPEC(s))
    s += 2;
  if (IS_DIR_SEPARATOR(*s))
    ++s;
  for (; *s != '\0'; s++)
    if (IS_DIR_SEPARATOR(*s))
      {
        char sep = *s;
	*s  = '\0';

        /* Try to make directory if it doesn't already exist.  */
        if (access (filename, F_OK) == -1
#ifdef TARGET_POSIX_IO
            && mkdir (filename, 0755) == -1
#else
            && mkdir (filename) == -1
#endif
            /* The directory might have been made by another process.  */
	    && errno != EEXIST)
	  {
            fprintf (stderr, "profiling:%s:Cannot create directory\n",
		     filename);
            *s = sep;
	    return -1;
	  };

	*s = sep;
      };
  return 0;
#endif
}
开发者ID:rgmabs19357,项目名称:gcc,代码行数:42,代码来源:libgcov.c

示例11: contains_dir_separator

bool
contains_dir_separator (const char *path)
{
  for (; *path != '\0'; path++)
    {
      if (IS_DIR_SEPARATOR (*path))
	return true;
    }

  return false;
}
开发者ID:T-J-Teru,项目名称:binutils-gdb,代码行数:11,代码来源:pathstuff.c

示例12: split_dir_and_file

/****************************************************************************
 * split_dir_and_file:
 * Takes a string and fills one pre-allocated array with any path prior to
 * the file name, and fills another pre-allocated array with the file name
 * The path name will include a trailing directory separator
 * The path name will be the empty string if there was no path in the input
 */
void split_dir_and_file(const char *inString, char *dirName, char *fileName)
{
  int ii;

   /* Start at end of inString. */
  ii = strlen(inString) - 1;

  /* Work backwards until we hit a directory separator. */
  while ((ii>0) && !IS_DIR_SEPARATOR(inString[ii])) {
    ii--;
  }

  /* ii could be -1, if the input string was empty */
  if (ii < 0) ii = 0;

  if (IS_DIR_SEPARATOR(inString[ii])) {
    ii++;
  }

  strcpy(dirName, inString);
  dirName[ii] = '\0';

  strcpy(fileName, &inString[ii]);
}
开发者ID:glshort,项目名称:MapReady,代码行数:31,代码来源:fileUtil.c

示例13: filebasename

/**
 * returns a pointer on the basename part of name
 */
const char* filebasename(const char* name)
{
#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
	/* Skip over the disk name in MSDOS pathnames. */
	if (isalpha(name[0]) && name[1] == ':') 
		name += 2;
#endif
	const char* base;
	for (base = name; *name; name++) {
		if (IS_DIR_SEPARATOR(*name)) {
			base = name + 1;
		}
    }
	return base;
}
开发者ID:onukore,项目名称:radium,代码行数:18,代码来源:enrobage.cpp

示例14: base_name

const char *
base_name (const char *name)
{
  const char *base;
#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
  /* Skip over the disk name in MSDOS pathnames. */
  if (isalpha ((unsigned char) name[0]) && name[1] == ':')
    name += 2;
#endif

  for (base = name; *name; name++)
    if (IS_DIR_SEPARATOR (*name))
      base = name + 1;
  return base;
}
开发者ID:GNsunghokim,项目名称:rtos,代码行数:15,代码来源:test_common.c

示例15: CreatePath

/*
============
CreatePath
============
*/
void CreatePath (char *path)
{
	char	*ofs, c;

	if (!path || !*path)
		return;

	ofs = path;
	if (HAS_DRIVE_SPEC(ofs))
		ofs = STRIP_DRIVE_SPEC(ofs);
	if (IS_DIR_SEPARATOR(*ofs))
		ofs++;

	for ( ; *ofs; ofs++)
	{
		c = *ofs;
		if (IS_DIR_SEPARATOR(c))
		{
			*ofs = 0;
			Q_mkdir (path);
			*ofs = c;
		}
	}
}
开发者ID:svn2github,项目名称:uhexen2,代码行数:29,代码来源:util_io.c


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