您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ split_path函数代码示例

51自学网 2021-06-03 08:10:51
  C++
这篇教程C++ split_path函数代码示例写得很实用,希望能帮到您。

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

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


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例8: postgresqlfs_mkdir

static intpostgresqlfs_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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例15: postgresqlfs_unlink

static intpostgresqlfs_unlink(const char *path){	struct dbpath dbpath;	split_path(path, &dbpath);	return -EPERM;}
开发者ID:GunioRobot,项目名称:postgresqlfs,代码行数:9,


示例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,


示例17: postgresqlfs_getattr

static intpostgresqlfs_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,


示例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,


示例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,


示例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,


示例21: TORRENT_ASSERT

	void file_storage::add_file(std::string const& file, size_type size, int flags		, std::time_t mtime, std::string const& symlink_path)	{		TORRENT_ASSERT(size >= 0);		if (size < 0) size = 0;		if (!has_parent_path(file))		{			// you have already added at least one file with a			// path to the file (branch_path), which means that			// all the other files need to be in the same top			// directory as the first file.			TORRENT_ASSERT(m_files.empty());			m_name = file;		}		else		{			if (m_files.empty())				m_name = split_path(file).c_str();		}		TORRENT_ASSERT(m_name == split_path(file).c_str());		m_files.push_back(internal_file_entry());		internal_file_entry& e = m_files.back();		e.set_name(file.c_str());		e.size = size;		e.offset = m_total_size;		e.pad_file = (flags & pad_file) != 0;		e.hidden_attribute = (flags & attribute_hidden) != 0;		e.executable_attribute = (flags & attribute_executable) != 0;		e.symlink_attribute = (flags & attribute_symlink) != 0;		if (e.symlink_attribute)		{			e.symlink_index = m_symlinks.size();			m_symlinks.push_back(symlink_path);		}		if (mtime)		{			if (m_mtime.size() < m_files.size()) m_mtime.resize(m_files.size());			m_mtime[m_files.size() - 1] = mtime;		}				update_path_index(e);		m_total_size += size;	}
开发者ID:pedia,项目名称:raidget,代码行数:43,


示例22: dcc_resolve

static krb5_error_code KRB5_CALLCONVdcc_resolve(krb5_context context, krb5_ccache *cache_out, const char *residual){    krb5_error_code ret;    krb5_ccache fcc;    char *primary_path = NULL, *sresidual = NULL, *dirname, *filename;    *cache_out = NULL;    if (*residual == ':') {        /* This is a subsidiary cache within the directory. */        ret = split_path(context, residual + 1, &dirname, &filename);        if (ret)            return ret;        ret = verify_dir(context, dirname);        free(dirname);        free(filename);        if (ret)            return ret;    } else {        /* This is the directory itself; resolve to the primary cache. */        ret = verify_dir(context, residual);        if (ret)            return ret;        ret = primary_pathname(residual, &primary_path);        if (ret)            goto cleanup;        ret = read_primary_file(context, primary_path, residual, &sresidual);        if (ret == ENOENT) {            /* Create an initial primary file. */            ret = write_primary_file(primary_path, "tkt");            if (ret)                goto cleanup;            ret = subsidiary_residual(residual, "tkt", &sresidual);            if (ret)                goto cleanup;        }        residual = sresidual;    }    ret = krb5_fcc_ops.resolve(context, &fcc, residual + 1);    if (ret)        goto cleanup;    ret = make_cache(residual, fcc, cache_out);    if (ret)        krb5_fcc_ops.close(context, fcc);cleanup:    free(primary_path);    free(sresidual);    return ret;}
开发者ID:Losteven,项目名称:krb5-test,代码行数:55,


示例23: split_path

xml_node_t* xml_node_t::get_node( const std::string& path,                                  const std::string& parm_name,                                  const std::string& parm_value ){  std::string name_str;  xml_node_t* node = split_path( name_str, path );  if ( node ) node = node -> search_tree( name_str, parm_name, parm_value );  return node;}
开发者ID:svn2github,项目名称:simulationcraft-ffxiv,代码行数:11,


示例24: split_path

bool file_utils::split_path(const char *p, dynamic_string &path, dynamic_string &filename){    dynamic_string temp_drive, temp_path, temp_ext;    if (!split_path(p, &temp_drive, &temp_path, &filename, &temp_ext))        return false;    filename += temp_ext;    combine_path(path, temp_drive.get_ptr(), temp_path.get_ptr());    return true;}
开发者ID:Nicky-D,项目名称:vogl,代码行数:11,


示例25: while

char *interpret_args(int argc, char *argv[]) {	const char *HELP_TEXT =		"Syntax: podcastgen <options> <input file>/n"		"/n"		"	-h, --help/t/tDisplay this help text/n"		"	-v/t/t/tVerbose output/n"		"	-C/t/t/tSet the Low Energy Coefficient/n"		"	-T/t/t/tSet the Upper Music Threshold/n"		"	--very-verbose/t/tVERY verbose output/n"		"	--no-intro/t/tRemove music at start of file/n/n";	static struct option long_options[] = {		{"help", no_argument, NULL, 'h'},		{"very-verbose", no_argument, (int*) &very_verbose, true},		{"no-intro", no_argument, (int*) &has_intro, false}	};	int opt;	while ((opt = getopt_long(argc, argv, "vhC:T:", long_options, NULL)) != -1) {		switch (opt) {			case 'v':				verbose = true;				break;			case 'h':				printf(HELP_TEXT);				exit(0);			case 'C':				LOW_ENERGY_COEFFICIENT = atof(optarg);				break;			case 'T':				UPPER_MUSIC_THRESHOLD = atof(optarg);				break;			case '?':				logger(ERROR, "Unknown argument /'-%c/'.", optopt);				exit(1);		}	}	if (very_verbose) {		verbose = true;	}	if (argc-optind == 1) {		input_path = malloc(100);		file_folders = malloc(100);		filename = malloc(100);		strcpy(input_path, argv[optind]);		split_path(input_path, &file_folders, &filename);	} else {		logger(ERROR, "Please supply a source file.");		exit(1);	}}
开发者ID:RadioRevolt,项目名称:podcastgen,代码行数:54,


示例26: ext2_remove_file

int ext2_remove_file(uint8_t *fs, char *path) {    uint32_t inum = get_inode_by_path(fs, path);    if (!inum) {        DEBUG("Bad path");        return 0;    }    struct ext2_inode *inode = get_inode(fs, inum);    // check if file    if (!ext2_inode_has_mode(inode, EXT2_S_IFREG)) {        DEBUG("FILE DELETE: Not a file %x", inode->i_mode);        return 0;    }    // get directory path    int num_parts = 0;    char **parts = split_path(path, &num_parts);    if (!num_parts) {        DEBUG("No parts");        return 0;    }    int newstring_size = 0;    for (int i=0; i < num_parts-1; i++) {        newstring_size += strlen(parts[i]) + 1;    }    char* newstring = malloc(newstring_size);    strcpy(newstring, "/");    for (int i=0; i < num_parts-1; i++) {        strcat(newstring,parts[i]);        if (i != num_parts-2) {            strcat(newstring, "/");        }    }    // get inode of directory    int dir_num = 0;    if(strcmp(newstring, "/")) {        dir_num = get_inode_by_path(fs, newstring);    }    else {        dir_num = EXT2_ROOT_INO;    }    // create dentry    if (dir_num) {        dentry_remove(fs, dir_num, inum);    }    else {        DEBUG("Bad dir path");        return 0;    }    return 1;}
开发者ID:bradylee,项目名称:nautilus_fs,代码行数:53,


示例27: md_build_library_name

/* Build a machine dependent library name out of a path and file name.  */voidmd_build_library_name(char *holder, int holderlen, char *pname, char *fname){    int n;    int i;    char  c;    char  **pelements;    const int pnamelen = pname ? (int)strlen(pname) : 0;    c = (pnamelen > 0) ? pname[pnamelen-1] : 0;    /* Quietly truncates on buffer overflow. Should be an error. */    if (pnamelen + strlen(fname) + 10 > (unsigned int)holderlen) {        *holder = '/0';        return;    }    if (pnamelen == 0) {        md_snprintf(holder, holderlen, "%s.dll", fname);    } else if (c == ':' || c == '//') {        md_snprintf(holder, holderlen, "%s%s.dll", pname, fname);    } else if (strchr(pname, PATH_SEPARATOR_CHAR) != NULL) {        pelements = split_path(pname, &n);        for (i = 0 ; i < n ; i++) {            char* path = pelements[i];            char lastchar;            // really shouldn't be NULL but what the heck, check can't hurt            size_t plen = (path == NULL) ? 0 : strlen(path);            if (plen == 0) {                continue; // skip empty path values            }            lastchar = path[plen - 1];            if (lastchar == ':' || lastchar == '//') {                md_snprintf(holder, holderlen, "%s%s.dll", pelements[i], fname);            } else {                md_snprintf(holder, holderlen, "%s//%s.dll", pelements[i], fname);            }            if (GetFileAttributes(holder) != INVALID_FILE_ATTRIBUTES) {                break;            }        }        // release the storage        for (i = 0 ; i < n ; i++) {           if (pelements[i] != NULL) {              free(pelements[i]);	   }        }        if (pelements != NULL) {           free(pelements);	}    } else {        md_snprintf(holder, holderlen, "%s//%s.dll", pname, fname);    }}
开发者ID:EricDeCoff,项目名称:Android-KeyStore,代码行数:54,


示例28: guestfs_impl_copy_in

intguestfs_impl_copy_in (guestfs_h *g, const char *localpath, const char *remotedir){  CLEANUP_CMD_CLOSE struct command *cmd = guestfs_int_new_command (g);  int fd;  int r;  char fdbuf[64];  size_t buf_len = strlen (localpath) + 1;  char buf[buf_len];  const char *dirname, *basename;  int remote_is_dir = guestfs_is_dir (g, remotedir);  if (remote_is_dir == -1)    return -1;  if (!remote_is_dir) {    error (g, _("target '%s' is not a directory"), remotedir);    return -1;  }  if (split_path (g, buf, buf_len, localpath, &dirname, &basename) == -1)    return -1;  guestfs_int_cmd_add_arg (cmd, "tar");  if (dirname) {    guestfs_int_cmd_add_arg (cmd, "-C");    guestfs_int_cmd_add_arg (cmd, dirname);  }  guestfs_int_cmd_add_arg (cmd, "-cf");  guestfs_int_cmd_add_arg (cmd, "-");  guestfs_int_cmd_add_arg (cmd, basename);  r = guestfs_int_cmd_run_async (cmd, NULL, NULL, &fd, NULL);  if (r == -1)    return -1;  snprintf (fdbuf, sizeof fdbuf, "/dev/fd/%d", fd);  r = guestfs_tar_in (g, fdbuf, remotedir);  if (close (fd) == -1) {    perrorf (g, "close (tar subprocess)");    return -1;  }  r = guestfs_int_cmd_wait (cmd);  if (r == -1)    return -1;  if (!(WIFEXITED (r) && WEXITSTATUS (r) == 0))    return -1;  return 0;}
开发者ID:FengYang,项目名称:libguestfs,代码行数:53,



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


C++ split_str函数代码示例
C++ split_page函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。