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

C++ split_path函数代码示例

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

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



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

示例1: is_ancestor_path

bool is_ancestor_path(const char *ancestor, const char *path)
{
    char **path_components, **ancestor_components;
    int i, path_count, ancestor_count;
    bool result = false;

    path_components = split_path(path, &path_count);
    ancestor_components = split_path(ancestor, &ancestor_count);

    if (!path_components || !ancestor_components) {
        goto exit;
    }

    if (ancestor_count >= path_count) {
        goto exit;
    }

    for (i = 0; i < ancestor_count; i++) {
        if (strcmp(path_components[i], ancestor_components[i]) != 0) {
            goto exit;
        }
    }

    result = true;

 exit:
    free(path_components);
    free(ancestor_components);
    return result;
}
开发者ID:SSSD,项目名称:ding-libs,代码行数:30,代码来源:path_utils.c


示例2: get_paths

  std::vector<std::string> get_paths(const std::string& name, bool resolve, size_t* lineno = nullptr) {
    std::string paths_str = get_string(name, lineno);

    std::vector<std::string> paths;
    split_path(paths_str.c_str(), ":", &paths);

    std::vector<std::pair<std::string, std::string>> params;
    params.push_back({ "LIB", kLibParamValue });
    if (target_sdk_version_ != 0) {
      char buf[16];
      async_safe_format_buffer(buf, sizeof(buf), "%d", target_sdk_version_);
      params.push_back({ "SDK_VER", buf });
    }

    static std::string vndk = Config::get_vndk_version_string('-');
    params.push_back({ "VNDK_VER", vndk });

    for (auto&& path : paths) {
      format_string(&path, params);
    }

    if (resolve) {
      std::vector<std::string> resolved_paths;

      // do not remove paths that do not exist
      resolve_paths(paths, &resolved_paths);

      return resolved_paths;
    } else {
      return paths;
    }
  }
开发者ID:MIPS,项目名称:bionic,代码行数:32,代码来源:linker_config.cpp


示例3: http_serve

void http_serve(int fd, const char *name)
{
    void (*handler)(int, const char *) = http_serve_none;
    char pn[1024];
    struct stat st;

    getcwd(pn, sizeof(pn));
    setenv("DOCUMENT_ROOT", pn, 1);

    strcat(pn, name);
    split_path(pn);

    if (!stat(pn, &st))
    {
        /* executable bits -- run as CGI script */
        if (S_ISREG(st.st_mode) && (st.st_mode & S_IXUSR))
            handler = http_serve_executable;
        else if (S_ISDIR(st.st_mode))
            handler = http_serve_directory;
        else
            handler = http_serve_file;
    }

    handler(fd, pn);
}
开发者ID:chapter09,项目名称:mit_6858,代码行数:25,代码来源:http.c


示例4: defined

bool file_utils::full_path(dynamic_string &path)
{
#if defined(PLATFORM_WINDOWS)
    char buf[1024];
    char *p = _fullpath(buf, path.get_ptr(), sizeof(buf));
    if (!p)
        return false;
#else
    char buf[PATH_MAX];
    char *p;
    dynamic_string pn, fn;
    split_path(path.get_ptr(), pn, fn);
    if ((fn == ".") || (fn == ".."))
    {
        p = realpath(path.get_ptr(), buf);
        if (!p)
            return false;
        path.set(buf);
    }
    else
    {
        if (pn.is_empty())
            pn = "./";
        p = realpath(pn.get_ptr(), buf);
        if (!p)
            return false;
        combine_path(path, buf, fn.get_ptr());
    }
#endif

    return true;
}
开发者ID:Nicky-D,项目名称:vogl,代码行数:32,代码来源:vogl_file_utils.cpp


示例5: get_parm

std::vector<xml_node_t*> xml_node_t::get_nodes( const std::string&        path,
                           const std::string&        parm_name,
                           const std::string&        parm_value )
{
  std::vector<xml_node_t*> nodes;
  if ( path.empty() || path == name_str )
  {
    xml_parm_t* parm = get_parm( parm_name );
    if ( parm && parm -> value_str == parm_value )
    {
      nodes.push_back( this );
    }
  }
  else
  {
    std::string name_str;
    xml_node_t* node = split_path( name_str, path );
    if ( ! node ) return nodes;

    for ( size_t i = 0; i < children.size(); ++i )
    {
      if ( node -> children[ i ] )
      {
        std::vector<xml_node_t*> n = node -> children[ i ] -> get_nodes( name_str, parm_name, parm_value );
        nodes.insert( nodes.end(), n.begin(), n.end() );
      }
    }
  }

  return nodes;
}
开发者ID:svn2github,项目名称:simulationcraft-ffxiv,代码行数:31,代码来源:sc_xml.cpp


示例6: deal_with_command

int			deal_with_command(t_lst *node, char **arg)
{
	char			**path;
	char			*right_path;
	char			**env;

	env = get_env(node);
	path = (char **)malloc(sizeof(char *) * 7);
	if (!path)
		return (-1);
	path = split_path(node);
	if (path && *arg && env)
	{
		right_path = check_path(path, *arg);
		if (right_path)
		{
			exec_right_path(node, arg, env, right_path);
			return (-1);
		}
	}
	if (*arg && env)
	{
		right_path = "";
		check_command(node, arg, right_path, env);
		ft_strdel(arg);
	}
	return (-1);
}
开发者ID:Zethir,项目名称:minishell,代码行数:28,代码来源:fork.c


示例7: split_path

        std::auto_ptr<const parameter_reader_t> parameter_reader_t::get_child(const std::string& path) const
        {
            std::string name;
            std::string subpath;
            boost::tie(name, subpath) = split_path(path);

            if( path.empty() )
            {
                PRX_FATAL_S("Calling get child with empty path");
            }

            else if( subpath.empty() ) // No slash found
            {
                return std::auto_ptr<const parameter_reader_t > (get_subreader(path));
            }
            else
            {
                if( !has_element(name) )
                    PRX_WARN_S("Can't follow path \"" << path << "\" from " << trace());

                const parameter_reader_t* subreader = get_subreader(name);
                std::auto_ptr<const parameter_reader_t> child_reader = subreader->get_child(subpath);
                delete subreader;
                return child_reader;
            }
        }
开发者ID:rshnn,项目名称:baxter_planning,代码行数:26,代码来源:parameter_reader.cpp


示例8: postgresqlfs_mkdir

static int
postgresqlfs_mkdir(const char *path, mode_t mode __attribute__((unused)))
{
	struct dbpath dbpath;

	split_path(path, &dbpath);

	// TODO: use mode sensibly

	if (dbpath_is_root(dbpath))
		return -EEXIST;
	else if (dbpath_is_database(dbpath))
		return db_command(dbconn, "CREATE DATABASE %s;", dbpath.database);
	else {
		/* Note: Don't switch the database when creating a database. */
		if (!switch_database(&dbpath))
			return -EIO;

		if (dbpath_is_schema(dbpath))
			return db_command(dbconn, "CREATE SCHEMA %s;", dbpath.schema);
		else if (dbpath_is_table(dbpath))
			return -ENOSYS; /* maybe: create zero column table */
		else if (dbpath_is_row(dbpath))
			return -ENOSYS; /* maybe: translate to INSERT with primary key and default values? */
		else
			return -ENOENT;
	}
}
开发者ID:GunioRobot,项目名称:postgresqlfs,代码行数:28,代码来源:postgresqlfs.c


示例9: myfs2_link

static int myfs2_link(const char* to, const char* from) {
  struct Inode *node = lookup(to);
  node->n_links++;
  
  char* parent = calloc(1, BLOCK_SIZE);
  char* leaf = calloc(1, BLOCK_SIZE);

  split_path(from, parent, leaf);

  struct Inode *parent_dir = lookup(parent);
  
  int block_id = parent_dir->size / 4;
  int pos = parent_dir->size % 4;
  if (!pos) {
    parent_dir->blocks[block_id] = calloc(1, BLOCK_SIZE);
  }
  parent_dir->size = parent_dir->size + 1;

  void *ptr = parent_dir->blocks[block_id] + pos*sizeof(struct DirRecord);
  struct DirRecord *rec = (struct DirRecord*) ptr;

  rec->inode_id = get_inode_id(node);
  strcpy(rec->name, leaf);

  return 0;
}
开发者ID:anxolerd,项目名称:myfs,代码行数:26,代码来源:myfs.c


示例10: get_inode_by_path

// Find the inode number for a file by its full path.
// This is the functionality that ext2cat ultimately needs.
__u32 get_inode_by_path(void * fs, char * path) {
    int num_slashes = get_number_of_slashes(path);
    char ** pathComponents = split_path(path);
    struct ext2_inode * dir = get_root_dir(fs);
    __u32 inode = 0;
    // loop through each part of path to file
    for (int i = 0; i < num_slashes; i++) {
        // look up inode of ith part of path
        inode = get_inode_from_dir(fs, dir, pathComponents[i]);
        // check if invalid
        if (inode == 0) {
            return 0;
        }
        // unless last iteration update inode entry to next file/directory
        if (i < num_slashes - 1) {
            dir = get_inode(fs,inode);
            // can't find right constant for this (value for dir is 16832)
            // so going to leave out error checking for now
            //if (dir->i_mode != LINUX_S_IFDIR) {
                 // error path is too long
            //     printf("Error path is too long\n");
            //     return 0;
            //}
        }
    }

    return inode;
}
开发者ID:menlocaleb,项目名称:eecs343-proj4,代码行数:30,代码来源:ext2_access.c


示例11: split_path

bool TestPathops::process ()
{
#ifdef _MSC_VER
    const char* paths [] = {"\\kokos\\banan", "d:\\Encyclopedia\\Data\\Genomes\\E.coli.K12\\proteins\\fasta\\", "", "\\", "\\ananas\\", NULL};
#else
    const char* paths [] = {"/kokos/banan", "~/Encyclopedia/Data/Genomes/E.coli.K12/proteins/fasta/", "", "/", "/ananas/", NULL};
#endif
    const char** path = paths;
    for (; *path != NULL; path ++)
    {
        o_ << "Path " << *path << std::endl;
        StrVec comps = split_path (*path);
        o_ << "path " << *path << ", " << comps.size () << " components" << std::endl;
        StrVec::const_iterator i = comps.begin ();
        for (;i < comps.end (); i ++)
            o_ << "  '" << (*i).c_str () << "'" << std::endl;
        std::string rejoined = join_path (comps);
        o_ << "  Rejoined: " << rejoined.c_str () << std::endl;
    }

    std::string jp = join_path ("kokos", "banan", "ananas", "yabloko", NULL);
    o_ << jp.c_str () << std::endl;
    jp = join_path ("", "kokos", NULL);
    o_ << jp.c_str () << std::endl;
    jp = join_path ("", NULL);
    o_ << jp.c_str () << std::endl;
    jp = join_path ("kokos", NULL);
    o_ << jp.c_str () << std::endl;
    jp = join_path (NULL);
    o_ << jp.c_str () << std::endl;
    return true;
}
开发者ID:Lingrui,项目名称:TS,代码行数:32,代码来源:test_file_utils.cpp


示例12: split_path

void simple_controller_t::remove_system(const std::string& path)
{
    std::string name;
    std::string subpath;
    boost::tie(name, subpath) = split_path(path);

    PRX_DEBUG_S("--- REMOVE system : name : " << name << "  subpath : " << subpath);
    if( subsystems.find(name) != subsystems.end() )
        if( subpath.empty() )
        {
            PRX_ERROR_S("Trying to remove system from a simple controller.  Throwing exception...");
            throw simple_add_remove_exception();
        }
        else
        {
            try
            {
                subsystems[name]->remove_system(subpath);
            }
            catch( removal_exception e )
            {
                subsystems.erase(name);
            }
        }

    else
        throw invalid_path_exception("The system " + name + " does not exist in the path " + pathname);

    construct_spaces();
    verify();
}
开发者ID:rshnn,项目名称:baxter_planning,代码行数:31,代码来源:simple_controller.cpp


示例13: add_node

static int add_node(node* n, const std::wstring& path) {
   std::vector<std::wstring> vp;
   bool is_folder = split_path(path, vp);

   node* r = g_lv.root;
   std::vector<std::wstring>::iterator itt = vp.begin();
   for (; itt != vp.end(); ++itt) {
      std::vector<node*>::iterator it = r->childs.begin();
      bool found = false;
      for (; it != r->childs.end(); ++it) {
         node* c = *it;
         if (*itt == c->name) {
            c->p = r;
            r = c;
            found = true;
            break;
         }
      }
      if (!found) {
         std::vector<std::wstring>::iterator ittt = vp.end();
         --ittt;
         if (ittt != itt) { 
            node* c = new node;
            c->name = *itt;
            c->p = r;
            c->type = 0;
            c->time = n->time;
            r->childs.push_back(c);
            r = c;
         } else {
            n->name = *itt;
            if (is_folder) {
               n->type = 0;
               n->size = 0;
            } else {
               n->type = 2;
               wchar_t* suffix[] = { L"jpg", L"jpeg", L"png", L"bmp", L"gif", L"tif", L"tiff"};
               int pos = n->name.find(L'.');
               if (pos != std::wstring::npos) {
                  std::wstring sf = n->name.substr(pos+1);
                  sf = to_lower(sf);
                  for (int i  = 0; i < 7; ++i) {
                     if (sf == suffix[i]) {
                        n->type = 1;
                        if (i == 4) {
                           n->gif = true;
                        }
                        break;
                     }
                  }
               }
            }
            n->p = r;
            r->childs.push_back(n);
            break;
         }
      }
   }
   return 0;
}
开发者ID:wangch,项目名称:zipk,代码行数:60,代码来源:zipk.cpp


示例14: object_create_entry

static int object_create_entry(const char *entry, const char *url)
{
	struct strbuf buf = STRBUF_INIT;
	char *args[3], path[PATH_MAX];
	int nr, ret = -EINVAL;
	uint64_t size;

	nr = split_path(entry, ARRAY_SIZE(args), args);
	if (nr != ARRAY_SIZE(args)) {
		sheepfs_pr("Invalid argument %d, %s", nr, entry);
		goto out;
	}

	strbuf_addf(&buf, "%s", PATH_HTTP);
	for (int i = 0; i < nr; i++) {
		strbuf_addf(&buf, "/%s", args[i]);
		snprintf(path, sizeof(path), "%.*s", (int)buf.len, buf.buf);
		if (i == (nr - 1)) {
			if (shadow_file_create(path) < 0) {
				sheepfs_pr("Create file %s fail", path);
				goto out;
			}
			size = curl_get_object_size(url);
			if (size <= 0) {
				sheepfs_pr("Failed to get size of object");
				shadow_file_delete(path);
				goto out;
			}
			if (shadow_file_setxattr(path, HTTP_SIZE_NAME, &size,
						 HTTP_SIZE_SIZE) < 0) {
				sheepfs_pr("Failed to setxattr for %s",
				       HTTP_SIZE_NAME);
				shadow_file_delete(path);
				goto out;
			}
			if (sheepfs_set_op(path, OP_OBJECT) < 0) {
				sheepfs_pr("Set_op %s fail", path);
				shadow_file_delete(path);
				goto out;
			}
		} else {
			if (shadow_dir_create(path) < 0) {
				sheepfs_pr("Create dir %s fail", path);
				goto out;
			}
			if (sheepfs_set_op(path, OP_CONTAINER) < 0) {
				sheepfs_pr("Set_op %s fail", path);
				shadow_dir_delete(path);
				goto out;
			}
		}
	}
	ret = 0;
out:
	for (int i = 0; i < ARRAY_SIZE(args); i++)
		free(args[i]);
	strbuf_release(&buf);
	return ret;
}
开发者ID:Abioy,项目名称:sheepdog,代码行数:59,代码来源:http.c


示例15: postgresqlfs_unlink

static int
postgresqlfs_unlink(const char *path)
{
	struct dbpath dbpath;

	split_path(path, &dbpath);

	return -EPERM;
}
开发者ID:GunioRobot,项目名称:postgresqlfs,代码行数:9,代码来源:postgresqlfs.c


示例16: dirname

    LIBUPCOREAPI UPALLOC UPWARNRESULT
    wchar_t* dirname(wchar_t const* p, size_t n) noexcept {
        split_result<wchar_t> result;
        if (split_path(p, n, &result)) {
            return nullptr;
        }

        return wcsndup(result.dirname, result.dirname_length);
    }
开发者ID:upcaste,项目名称:upcaste,代码行数:9,代码来源:posix_dirname.cpp


示例17: postgresqlfs_getattr

static int
postgresqlfs_getattr(const char *path, struct stat *buf)
{
	struct dbpath dbpath;

	buf->st_mode = 0;

	debug("path=%s", path);

	split_path(path, &dbpath);

	debug("%s", dbpath_to_string(&dbpath));

	if (!dbpath_is_database(dbpath) && !switch_database(&dbpath))
		return -EIO;

	if (!dbpath_exists(&dbpath, dbconn))
		return -ENOENT;

	buf->st_nlink = 1;
	buf->st_uid = getuid();
	buf->st_gid = getgid();

	if (dbpath_is_column(dbpath))
		buf->st_mode |= S_IFREG | 0444;
	else
		buf->st_mode |= S_IFDIR | 0755;

	buf->st_atime = starttime;
	buf->st_mtime = starttime;
	buf->st_ctime = starttime;

	buf->st_blksize = 1;

	if (dbpath_is_column(dbpath))
	{
		PGresult *res;

		res = db_query(dbconn,
					   "SELECT octet_length(CAST(%s AS text)) FROM %s.%s WHERE ctid = '%s';",
					   dbpath.column + 3, dbpath.schema, dbpath.table, rowname_to_ctid(dbpath.row));
		if (!res)
			return -EIO;

		buf->st_size = atol(PQgetvalue(res, 0, 0));

		PQclear(res);
	}
	else
	{
		buf->st_size = 42;
	}

	buf->st_blocks = buf->st_size;

	return 0;
}
开发者ID:GunioRobot,项目名称:postgresqlfs,代码行数:57,代码来源:postgresqlfs.c


示例18: path_to_segments

SegmentsVec path_to_segments(const std::string& path) {
    SegmentsVec segments{};

    for (const auto& chunk : split_path(path)) {
        segments.emplace_back(mux::path_segment_to_matcher(chunk));
    }

    return segments;
}
开发者ID:01org,项目名称:intelRSD,代码行数:9,代码来源:utils.cpp


示例19: get_filename

bool file_utils::get_filename(const char *p, dynamic_string &filename)
{
    dynamic_string temp_ext;
    if (!split_path(p, NULL, NULL, &filename, &temp_ext))
        return false;

    filename += temp_ext;
    return true;
}
开发者ID:Nicky-D,项目名称:vogl,代码行数:9,代码来源:vogl_file_utils.cpp


示例20: get_pathname

bool file_utils::get_pathname(const char *p, dynamic_string &path)
{
    dynamic_string temp_drive, temp_path;
    if (!split_path(p, &temp_drive, &temp_path, NULL, NULL))
        return false;

    combine_path(path, temp_drive.get_ptr(), temp_path.get_ptr());
    return true;
}
开发者ID:Nicky-D,项目名称:vogl,代码行数:9,代码来源:vogl_file_utils.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ split_str函数代码示例发布时间:2022-05-30
下一篇:
C++ split_page函数代码示例发布时间: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