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


C++ ISSLASH函数代码示例

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


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

示例1: rpl_rmdir

int
rpl_rmdir (char const *dir)
{
  /* Work around cygwin 1.5.x bug where rmdir("dir/./") succeeds.  */
  size_t len = strlen (dir);
  int result;
  while (len && ISSLASH (dir[len - 1]))
    len--;
  if (len && dir[len - 1] == '.' && (1 == len || ISSLASH (dir[len - 2])))
    {
      errno = EINVAL;
      return -1;
    }
  result = rmdir (dir);
  /* Work around mingw bug, where rmdir("file/") fails with EINVAL
     instead of ENOTDIR.  We've already filtered out trailing ., the
     only reason allowed by POSIX for EINVAL.  */
  if (result == -1 && errno == EINVAL)
    errno = ENOTDIR;
  return result;
}
开发者ID:tluyben,项目名称:oath-toolkit-9-digits,代码行数:21,代码来源:rmdir.c

示例2: MakePathName

/*
** void MakePathName(char ARG_PTR *pszPath, char ARG_PTR *pszFileName);
**
** Append a filename to a path string.
**
** Arguments:  pszPath     - path string to which pszFileName will be appended
**             pszFileName - file name to append
**
** Returns:    void
**
** Globals:    none
*/
VOID MakePathName(CHAR ARG_PTR *pszPath, CHAR ARG_PTR *pszFileName)
{
   CHAR chLastPathChar;

   // Make sure we have an isolated file name.
   pszFileName = ExtractFileName(pszFileName);

   // Dont append to a NULL string or a single ".".
#ifdef DBCS
   if (*pszFileName != '\0' &&
       ! (! IsDBCSLeadByte(pszFileName[0]) && pszFileName[0] == PERIOD &&
          ! IsDBCSLeadByte(pszFileName[1]) && pszFileName[1] == '\0'))
   {
      CHAR ARG_PTR *psz, *pszPrevious;

      for (psz = pszPrevious = pszPath; *psz != '\0'; psz = AnsiNext(psz))
         pszPrevious = psz;

      chLastPathChar = *pszPrevious;

      if (! IsDBCSLeadByte(chLastPathChar) && ! ISSLASH(chLastPathChar) &&
          chLastPathChar != COLON)
         STRCAT(pszPath, SEP_STR);

      STRCAT(pszPath, pszFileName);
   }
#else
   if (*pszFileName != '\0' &&
       ! (*pszFileName == PERIOD && pszFileName[1] == '\0'))
   {
      chLastPathChar = pszPath[STRLEN(pszPath) - 1];

      if (! ISSLASH(chLastPathChar) && chLastPathChar != COLON)
         STRCAT(pszPath, SEP_STR);

      STRCAT(pszPath, pszFileName);
   }
#endif
}
开发者ID:mingpen,项目名称:OpenNT,代码行数:51,代码来源:utils.c

示例3: relocate

const char *
relocate (const char *pathname)
{
#if defined PIC && defined INSTALLDIR
  static int initialized;

  
  if (!initialized)
    {
      const char *orig_installprefix = INSTALLPREFIX;
      const char *orig_installdir = INSTALLDIR;
      const char *curr_prefix_better;

      curr_prefix_better =
	compute_curr_prefix (orig_installprefix, orig_installdir,
			     get_shared_library_fullname ());
      if (curr_prefix_better == NULL)
	curr_prefix_better = curr_prefix;

      set_relocation_prefix (orig_installprefix, curr_prefix_better);

      initialized = 1;
    }
#endif

  if (orig_prefix != NULL && curr_prefix != NULL
      && strncmp (pathname, orig_prefix, orig_prefix_len) == 0)
    {
      if (pathname[orig_prefix_len] == '\0')
	
	return curr_prefix;
      if (ISSLASH (pathname[orig_prefix_len]))
	{
	  
	  const char *pathname_tail = &pathname[orig_prefix_len];
	  char *result =
	    (char *) xmalloc (curr_prefix_len + strlen (pathname_tail) + 1);

#ifdef NO_XMALLOC
	  if (result != NULL)
#endif
	    {
	      memcpy (result, curr_prefix, curr_prefix_len);
	      strcpy (result + curr_prefix_len, pathname_tail);
	      return result;
	    }
	}
    }
  
  return pathname;
}
开发者ID:qtekfun,项目名称:htcDesire820Kernel,代码行数:51,代码来源:relocatable.c

示例4: replace_slashes

/* Replace '/' with '\0' in FILENAME if it marks a place that
   needs testing for the existence of directory.  Return the address
   of the last location replaced, or 0 if none were replaced.  */
static char *
replace_slashes (char *filename)
{
  char *f;
  char *last_location_replaced = 0;
  char const *component_start;

  for (f = filename + FILE_SYSTEM_PREFIX_LEN (filename);  ISSLASH (*f);  f++)
    /* do nothing */ ;

  component_start = f;

  for (; *f; f++)
    if (ISSLASH (*f))
      {
	char *slash = f;

	/* Treat multiple slashes as if they were one slash.  */
	while (ISSLASH (f[1]))
	  f++;

	/* Ignore slashes at the end of the path.  */
	if (! f[1])
	  break;

	/* "." and ".." need not be tested.  */
	if (! (slash - component_start <= 2
	       && component_start[0] == '.' && slash[-1] == '.'))
	  {
	    *slash = '\0';
	    last_location_replaced = slash;
	  }

	component_start = f + 1;
      }

  return last_location_replaced;
}
开发者ID:infoburp,项目名称:patch,代码行数:41,代码来源:util.c

示例5: dir_len

size_t
dir_len (char const *file)
{
  size_t prefix_length = FILE_SYSTEM_PREFIX_LEN (file);
  size_t length;

  /* Advance prefix_length beyond important leading slashes.  */
  prefix_length += (prefix_length != 0
                    ? (FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
                       && ISSLASH (file[prefix_length]))
                    : (ISSLASH (file[0])
                       ? ((DOUBLE_SLASH_IS_DISTINCT_ROOT
                           && ISSLASH (file[1]) && ! ISSLASH (file[2])
                           ? 2 : 1))
                       : 0));

  /* Strip the basename and any redundant slashes before it.  */
  for (length = last_component (file) - file;
       prefix_length < length; length--)
    if (! ISSLASH (file[length - 1]))
      break;
  return length;
}
开发者ID:stevenylai,项目名称:clib,代码行数:23,代码来源:dirname-lgpl.c

示例6: last_component

char *
last_component (char const *name)
{
  char const *base = name + FILE_SYSTEM_PREFIX_LEN (name);
  char const *p;
  bool saw_slash = false;

  while (ISSLASH (*base))
    base++;

  for (p = base; *p; p++)
    {
      if (ISSLASH (*p))
	saw_slash = true;
      else if (saw_slash)
	{
	  base = p;
	  saw_slash = false;
	}
    }

  return (char *) base;
}
开发者ID:4solo,项目名称:cs35,代码行数:23,代码来源:basename.c

示例7: FILESYSTEM_PREFIX_LEN

char *basename(char const *name)
{
	char const *base = name += FILESYSTEM_PREFIX_LEN(name);
	int all_slashes = 1;
	char const *p;

	for (p = name; *p; p++)
	{
		if (ISSLASH(*p))
			base = p + 1;
		else
			all_slashes = 0;
	}

	/* If NAME is all slashes, arrange to return `/'. */
	if (*base == '\0' && ISSLASH(*name) && all_slashes)
		--base;

	/* Make sure the last byte is not a slash. */
	//assert(all_slashes || !ISSLASH(*(p - 1)));

	return (char *)base;
}
开发者ID:Daniel1892,项目名称:tora,代码行数:23,代码来源:utils.cpp

示例8: removedirs

/* Remove empty ancestor directories of FILENAME.
   Ignore errors, since the path may contain ".."s, and when there
   is an EEXIST failure the system may return some other error number.  */
void
removedirs (char const *name)
{
  char *filename = xstrdup (name);
  size_t i;

  for (i = strlen (filename);  i != 0;  i--)
    if (ISSLASH (filename[i])
	&& ! (ISSLASH (filename[i - 1])
	      || (filename[i - 1] == '.'
		  && (i == 1
		      || ISSLASH (filename[i - 2])
		      || (filename[i - 2] == '.'
			  && (i == 2
			      || ISSLASH (filename[i - 3])))))))
      {
	filename[i] = '\0';
	if (rmdir (filename) == 0 && verbosity == VERBOSE)
	  say ("Removed empty directory %s\n", quotearg (filename));
	filename[i] = '/';
      }
  free (filename);
}
开发者ID:infoburp,项目名称:patch,代码行数:26,代码来源:util.c

示例9: strip_leading_slashes

/* Strip up to STRIP_LEADING leading slashes.
   If STRIP_LEADING is negative, strip all leading slashes.
   Returns a pointer into NAME on success, and NULL otherwise.
  */
static bool
strip_leading_slashes (char *name, int strip_leading)
{
  int s = strip_leading;
  char *p, *n;

  for (p = n = name;  *p;  p++)
    {
      if (ISSLASH (*p))
	{
	  while (ISSLASH (p[1]))
	    p++;
	  if (strip_leading < 0 || --s >= 0)
	      n = p+1;
	}
    }
  if ((strip_leading < 0 || s <= 0) && *n)
    {
      memmove (name, n, strlen (n) + 1);
      return true;
    }
  else
    return false;
}
开发者ID:infoburp,项目名称:patch,代码行数:28,代码来源:util.c

示例10: dir_name

char *
dir_name (char const *file)
{
  size_t length = dir_len (file);
  bool append_dot = (length == 0
		     || (FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
			 && length == FILE_SYSTEM_PREFIX_LEN (file)
			 && file[2] != '\0' && ! ISSLASH (file[2])));
  char *dir = xmalloc (length + append_dot + 1);
  memcpy (dir, file, length);
  if (append_dot)
    dir[length++] = '.';
  dir[length] = '\0';
  return dir;
}
开发者ID:4solo,项目名称:cs35,代码行数:15,代码来源:dirname.c

示例11: FILESYSTEM_PREFIX_LEN

char *xine_private_basename(char *name) {
  char const *base = name + FILESYSTEM_PREFIX_LEN (name);
  char const *p;

  for (p = base; *p; p++) {
    if (ISSLASH (*p)) {
      /* Treat multiple adjacent slashes like a single slash.  */
      do p++;
      while (ISSLASH (*p));

      /* If the file name ends in slash, use the trailing slash as
         the basename if no non-slashes have been found.  */
      if (! *p) {
        if (ISSLASH (*base)) base = p - 1;
        break;
      }

      /* *P is a non-slash preceded by a slash.  */
      base = p;
    }
  }

  return (char *)base;
}
开发者ID:Caught,项目名称:openpliPC,代码行数:24,代码来源:basename.c

示例12: is_unc_root

/* Return TRUE if the given file name denotes an UNC root.  */
static BOOL
is_unc_root (const char *rname)
{
  /* Test whether it has the syntax '\\server\share'.  */
  if (ISSLASH (rname[0]) && ISSLASH (rname[1]))
    {
      /* It starts with two slashes.  Find the next slash.  */
      const char *p = rname + 2;
      const char *q = p;
      while (*q != '\0' && !ISSLASH (*q))
        q++;
      if (q > p && *q != '\0')
        {
          /* Found the next slash at q.  */
          q++;
          const char *r = q;
          while (*r != '\0' && !ISSLASH (*r))
            r++;
          if (r > q && *r == '\0')
            return TRUE;
        }
    }
  return FALSE;
}
开发者ID:komh,项目名称:tar-os2,代码行数:25,代码来源:stat.c

示例13: excluded_name

/* Return nonzero if file NAME is excluded.  */
bool
excluded_name (char const *name, struct tar_stat_info *st)
{
  struct exclist *ep;
  const char *rname = NULL;
  char *bname = NULL;
  bool result;
  int nr = 0;

  name += FILE_SYSTEM_PREFIX_LEN (name);

  /* Try global exclusion list first */
  if (excluded_file_name (excluded, name))
    return true;

  if (!st)
    return false;

  for (result = false; st && !result; st = st->parent, nr = EXCL_NON_RECURSIVE)
    {
      for (ep = st->exclude_list; ep; ep = ep->next)
	{
	  if (ep->flags & nr)
	    continue;
	  if ((result = excluded_file_name (ep->excluded, name)))
	    break;

	  if (!rname)
	    {
	      rname = name;
	      /* Skip leading ./ */
	      while (*rname == '.' && ISSLASH (rname[1]))
		rname += 2;
	    }
	  if ((result = excluded_file_name (ep->excluded, rname)))
	    break;

	  if (!bname)
	    bname = base_name (name);
	  if ((result = excluded_file_name (ep->excluded, bname)))
	    break;
	}
    }

  free (bname);

  return result;
}
开发者ID:mfragkoulis,项目名称:tar,代码行数:49,代码来源:exclist.c

示例14: target_directory_operand

static bool
target_directory_operand (char const *file)
{
  char const *b = last_component (file);
  size_t blen = strlen (b);
  bool looks_like_a_dir = (blen == 0 || ISSLASH (b[blen - 1]));
  struct stat st;
  int stat_result =
    (dereference_dest_dir_symlinks ? stat (file, &st) : lstat (file, &st));
  int err = (stat_result == 0 ? 0 : errno);
  bool is_a_dir = !err && S_ISDIR (st.st_mode);
  if (err && err != ENOENT)
    error (EXIT_FAILURE, err, _("accessing %s"), quote (file));
  if (is_a_dir < looks_like_a_dir)
    error (EXIT_FAILURE, err, _("target %s is not a directory"), quote (file));
  return is_a_dir;
}
开发者ID:chubbymaggie,项目名称:forest,代码行数:17,代码来源:ln.c

示例15: slash

/* Returns true if all names from the namelist were processed.
   P is the stat_info of the most recently processed entry.
   The decision is postponed until the next entry is read if:

   1) P ended with a slash (i.e. it was a directory)
   2) P matches any entry from the namelist *and* represents a subdirectory
   or a file lying under this entry (in the terms of directory structure).

   This is necessary to handle contents of directories. */
bool
all_names_found (struct tar_stat_info *p)
{
  struct name const *cursor;
  size_t len;

  if (!p->file_name || occurrence_option == 0 || p->had_trailing_slash)
    return false;
  len = strlen (p->file_name);
  for (cursor = namelist; cursor; cursor = cursor->next)
    {
      if ((cursor->name[0] && !WASFOUND (cursor))
	  || (len >= cursor->length && ISSLASH (p->file_name[cursor->length])))
	return false;
    }
  return true;
}
开发者ID:jelaas,项目名称:bifrost-build,代码行数:26,代码来源:names.c


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