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

C++ path_join函数代码示例

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

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



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

示例1: compress_directory

result_t compress_directory(struct pak_file* pak, struct paki_args* args, const char* subdir)
{
    result_t r;
    char directory[DH_PATH_MAX];
    char filepath[DH_PATH_MAX];
    char fullfilepath[DH_PATH_MAX];

    strcpy(directory, args->path);
    if (subdir[0] != 0)     {
        path_join(directory, directory, subdir, NULL);
    }

    WIN32_FIND_DATA fdata;
    char filter[DH_PATH_MAX];
    path_join(filter, directory, "*", NULL);
    HANDLE find_hdl = FindFirstFile(filter, &fdata);
    if (find_hdl == INVALID_HANDLE_VALUE)    {
        printf(TERM_BOLDRED "Creating pak failed: directory '%s' does not exist.\n" TERM_RESET,
               directory);
        return RET_FAIL;
    }

    /* read directory recuresively, and compress files into pak */
    BOOL fr = TRUE;
    while (fr)     {
        if (!str_isequal(fdata.cFileName, ".") && !str_isequal(fdata.cFileName, ".."))    {
            filepath[0] = 0;
            if (subdir[0] != 0)     {
                strcpy(filepath, subdir);
            }

            if (!BIT_CHECK(fdata.dwFileAttributes, FILE_ATTRIBUTE_DIRECTORY))  {
                /* put the file into the archive */
                path_join(filepath, filepath, fdata.cFileName, NULL);
                path_join(fullfilepath, directory, fdata.cFileName, NULL);

                r = archive_put(pak, args, fullfilepath, filepath);
                if (IS_OK(r) && BIT_CHECK(args->usage, PAKI_USAGE_VERBOSE))     {
                    puts(filepath);
                }   else if (IS_FAIL(r))  {
                    err_sendtolog(FALSE);
                    args->err_cnt ++;
                }
                args->file_cnt ++;
            }   else    {
                /* it's a directory, recurse */
                path_join(filepath, filepath, fdata.cFileName, NULL);
                compress_directory(pak, args, filepath);
            }
        }
        fr = FindNextFile(find_hdl, &fdata);
    }

    FindClose(find_hdl);
    return RET_OK;
}
开发者ID:shadercoder,项目名称:darkhammer,代码行数:56,代码来源:paki.c


示例2: path_cache_get

string path_cache_get(const string& sub)
{
#if defined(__linux__) || defined(__APPLE__)
	if(cached_xdg_cache_path == "") {
		cached_xdg_cache_path = path_xdg_cache_get();
	}
	string result = path_join(cached_xdg_cache_path, "cycles");
	return path_join(result, sub);
#else
	/* TODO(sergey): What that should be on Windows? */
	return path_user_get(path_join("cache", sub));
#endif
}
开发者ID:UPBGE,项目名称:blender,代码行数:13,代码来源:util_path.cpp


示例3: getenv

const char *cuewCompilerPath(void) {
#ifdef _WIN32
  const char *defaultpaths[] = {"C:/CUDA/bin", NULL};
  const char *executable = "nvcc.exe";
#else
  const char *defaultpaths[] = {
    "/Developer/NVIDIA/CUDA-5.0/bin",
    "/usr/local/cuda-5.0/bin",
    "/usr/local/cuda/bin",
    "/Developer/NVIDIA/CUDA-6.0/bin",
    "/usr/local/cuda-6.0/bin",
    "/Developer/NVIDIA/CUDA-5.5/bin",
    "/usr/local/cuda-5.5/bin",
    NULL};
  const char *executable = "nvcc";
#endif
  int i;

  const char *binpath = getenv("CUDA_BIN_PATH");

  static char nvcc[65536];

  if (binpath) {
    path_join(binpath, executable, sizeof(nvcc), nvcc);
    if (path_exists(nvcc))
      return nvcc;
  }

  for (i = 0; defaultpaths[i]; ++i) {
    path_join(defaultpaths[i], executable, sizeof(nvcc), nvcc);
    if (path_exists(nvcc))
      return nvcc;
  }

#ifndef _WIN32
  {
    FILE *handle = popen("which nvcc", "r");
    if (handle) {
      char buffer[4096] = {0};
      int len = fread(buffer, 1, sizeof(buffer) - 1, handle);
      buffer[len] = '\0';
      pclose(handle);

      if (buffer[0])
        return "nvcc";
    }
  }
#endif

  return NULL;
}
开发者ID:pawkoz,项目名称:dyplom,代码行数:51,代码来源:cuew.c


示例4: construct_path

/* still needs freeing! */
static char* construct_path(vaht_resource* res, char* out, const char* ext)
{
    const char* origname = vaht_resource_name(res);
    char* name = NULL;
    if (strlen(origname) > 0)
        name = make_path_safe(origname);

    uint32_t name_len = 0;
    if (name)
    {
        name_len = strlen(name);
    }
    
    /* 11 = 4 + 1 + ... + 1 + 4 + 1
     * that is
     * '0000.[stuff].type\0'
     */
    char* filename = malloc(sizeof(char) * (name_len + 11));
    
    const char* type = vaht_resource_type(res);
    if (ext == NULL)
        ext = type;
    
    if (name)
    {
        sprintf(filename, "%04i.%s.%s", vaht_resource_id(res), name, ext);
    } else {
        sprintf(filename, "%04i.%s", vaht_resource_id(res), ext);
    }
    
    /* we don't need this anymore */
    if (name)
    {
        free(name);
        name = NULL;
    }
    
    char* directory;
    char* path;
    
    directory = path_join(out, type);
    path = path_join(directory, filename);
    
    free(directory);
    directory = NULL;
    free(filename);
    filename = NULL;
    
    return path;
}
开发者ID:agrif,项目名称:libvaht,代码行数:51,代码来源:mode-extract.c


示例5: path_compare

/*!
 * \brief An strcmp() for paths
 *
 * This function will normalize \a path1 and \a path2 before they are passed to
 * std::string::compare(). This way, extra slashes, '.', '..', etc. are handled
 * before the string comparison is performed.
 *
 * \note This function does not traverse the filesystem at all. It works purely
 *       on the given path strings.
 *
 * \return An integer less than, equal to, or greater than zero if \a path1 is
 *         found, respectively, to be less than, equal to, or greater than
 *         \a path2 lexicographically.
 */
int path_compare(const std::string &path1, const std::string &path2)
{
    if (path1.empty() || path2.empty()) {
        return false;
    }

    std::vector<std::string> path1_pieces(path_split(path1));
    std::vector<std::string> path2_pieces(path_split(path2));

    normalize_path(path1_pieces);
    normalize_path(path2_pieces);

    return path_join(path1_pieces).compare(path_join(path2_pieces));
}
开发者ID:Nonta72,项目名称:DualBootPatcher,代码行数:28,代码来源:path.cpp


示例6: blast_coarse

/*Runs BLAST on the coarse database and stores the results in a temporary
  XML file.*/
void blast_coarse(struct opt_args *args, uint64_t dbsize){
    char *blastn,
         *input_path = path_join(args->args[0], CABLAST_COARSE_FASTA),
         *blastn_command =
           "blastn -db  -outfmt 5 -query  -dbsize  -task blastn -evalue  "
           "> CaBLAST_temp_blast_results.xml";
    int command_length = strlen(blastn_command) + strlen(input_path) +
                                                  strlen(args->args[1]) + 31;

    blastn = malloc(command_length*sizeof(*blastn));
    assert(blastn);

    sprintf(blastn,
            "blastn -db %s -outfmt 5 -query %s -dbsize %lu -task blastn"
            " -evalue %s > CaBLAST_temp_blast_results.xml",
            input_path, args->args[1], dbsize, search_flags.coarse_evalue);

    if (!search_flags.hide_progress)
        fprintf(stderr, "%s\n", blastn);

    system(blastn);

    free(input_path);
    free(blastn);
}
开发者ID:BergerLab,项目名称:CAST,代码行数:27,代码来源:cablast-search.c


示例7: main

int main(void)
{
	char cwd[1024], *path, *ctx = tal_strdup(NULL, "ctx");

	plan_tests(6);

	if (!getcwd(cwd, sizeof(cwd)))
		abort();

	unlink("run-is_dir-dir-link");
	unlink("run-is_dir-file-link");
	unlink("run-is_dir-dir/file");
	rmdir("run-is_dir-dir");
	if (mkdir("run-is_dir-dir", 0700) != 0)
		abort();
	if (symlink("run-is_dir-dir", "run-is_dir-dir-link") != 0)
		abort();
	if (symlink("run-is_dir-dir/file", "run-is_dir-file-link") != 0)
		abort();
	close(open("run-is_dir-dir/file", O_WRONLY|O_CREAT, 0600));

	ok1(path_is_dir("run-is_dir-dir-link"));
	ok1(!path_is_dir("run-is_dir-file-link"));
	ok1(!path_is_dir("run-is_dir-dir/file"));
	ok1(path_is_dir("run-is_dir-dir"));

	path = path_join(ctx, cwd, "run-is_dir-dir/file");
	ok1(!path_is_dir(path));
	ok1(path_is_dir(cwd));

	tal_free(ctx);

	return exit_status();
}
开发者ID:CodeShark,项目名称:lightning,代码行数:34,代码来源:run-is_dir.c


示例8: lf_path_join

int lf_path_join(lua_State *L)
{
	char buffer[1024*2];
	int n = lua_gettop(L);
	int err;
	const char *base;
	const char *extend;
	size_t base_len, extend_len;

	if(n != 2)
		luaL_error(L, "path_join: incorrect number of arguments");

	luaL_checktype(L, 1, LUA_TSTRING);
	luaL_checktype(L, 2, LUA_TSTRING);
	
	base = lua_tolstring(L, 1, &base_len);
	extend = lua_tolstring(L, 2, &extend_len);
	err = path_join(base, base_len, extend, extend_len, buffer, 2*1024);
	if(err != 0)
	{
		luaL_error(L, "path_join: error %d, couldn't join\n\t'%s'\n  and\n\t'%s'",
			err,
			lua_tostring(L, 1),
			lua_tostring(L, 2));
	}
	
	lua_pushstring(L, buffer);
	return 1;
}
开发者ID:EEmmanuel7,项目名称:bam,代码行数:29,代码来源:path.c


示例9: file_rmrf

int
file_rmrf (const char *path)
{
  if (file_isdir (path))
	{
	  dirlist_t list;
	  if (file_listdir (path, &list) != 0)
		return -1;
	  int i;
	  for (i = 0; i < list.length; i++)
		{
		  if (strcmp (".", list.paths[i]) == 0
			  || strcmp ("..", list.paths[i]) == 0)
			continue;
		  char *next = path_join (path, list.paths[i]);
		  int ret = file_rmrf (next);
		  free (next);
		  if (ret != 0)
			{
			  file_free_dirlist (&list);
			  return ret;
			}
		}
	  file_free_dirlist (&list);
	  if (rmdir (path) != 0)
		return -1;
	}
  else if (file_isfile (path) || file_islink (path))
	{
	  return unlink (path);
	}
  return 0;
}
开发者ID:csm,项目名称:arrow,代码行数:33,代码来源:helpers.c


示例10: getenv

static const char *stat_cache_path()
{
    const char *waitless_dir = getenv(WAITLESS_DIR);
    if (!waitless_dir)
        die("WAITLESS_DIR not set");
    return path_join(waitless_dir, stat_cache.name);
}
开发者ID:girving,项目名称:waitless,代码行数:7,代码来源:stat_cache.c


示例11: rimraf

int
rimraf(const char *path) {
  DIR *dir = opendir(path);
  if (NULL == dir) return -1;

  struct dirent *dp = NULL;
  while (NULL != (dp = readdir(dir))) {
    if (0 == strcmp(".", dp->d_name)
        || 0 == strcmp("..", dp->d_name)) continue;

    char *f = path_join(path, dp->d_name);
    if (NULL == f) return -1;

    struct stat s;
    if (0 != stat(f, &s)) return -1;
    if (s.st_mode & S_IFDIR) {
      // rimraf dirs
      if (-1 == rimraf(f)) return -1;
    } else {
      // unlink files
      if (-1 == unlink(f)) return -1;
    }
    free(f);
  }
  free(dp);
  closedir(dir);

  return rmdir(path);
}
开发者ID:stephenmathieson,项目名称:rimraf.c,代码行数:29,代码来源:rimraf.c


示例12: path_which

String path_which(const String &p_name) {

#ifdef WINDOWS_ENABLED
	Vector<String> exts = OS::get_singleton()->get_environment("PATHEXT").split(ENV_PATH_SEP, false);
#endif
	Vector<String> env_path = OS::get_singleton()->get_environment("PATH").split(ENV_PATH_SEP, false);

	if (env_path.empty())
		return String();

	for (int i = 0; i < env_path.size(); i++) {
		String p = path_join(env_path[i], p_name);

#ifdef WINDOWS_ENABLED
		for (int j = 0; j < exts.size(); j++) {
			String p2 = p + exts[j];

			if (FileAccess::exists(p2))
				return p2;
		}
#else
		if (FileAccess::exists(p))
			return p;
#endif
	}

	return String();
}
开发者ID:SaracenOne,项目名称:godot,代码行数:28,代码来源:path_utils.cpp


示例13: find_device

int find_device(const char *id, const char *prefix, sd_device **ret) {
        _cleanup_free_ char *buf = NULL;

        assert(id);
        assert(ret);

        if (prefix && !path_startswith(id, prefix)) {
                buf = path_join(NULL, prefix, id);
                if (!buf)
                        return -ENOMEM;
                id = buf;
        }

        if (path_startswith(id, "/sys/"))
                return sd_device_new_from_syspath(ret, id);

        if (path_startswith(id, "/dev/")) {
                struct stat st;

                if (stat(id, &st) < 0)
                        return -errno;

                return device_new_from_stat_rdev(ret, &st);
        }

        return -EINVAL;
}
开发者ID:htejun,项目名称:systemd,代码行数:27,代码来源:udevadm-util.c


示例14: exec_list

static int exec_list(sd_device_enumerator *e, const char *action, Set *settle_set) {
        sd_device *d;
        int r;

        FOREACH_DEVICE_AND_SUBSYSTEM(e, d) {
                _cleanup_free_ char *filename = NULL;
                const char *syspath;

                if (sd_device_get_syspath(d, &syspath) < 0)
                        continue;

                if (arg_verbose)
                        printf("%s\n", syspath);
                if (arg_dry_run)
                        continue;

                filename = path_join(syspath, "uevent");
                if (!filename)
                        return log_oom();

                r = write_string_file(filename, action, WRITE_STRING_FILE_DISABLE_BUFFER);
                if (r < 0) {
                        log_debug_errno(r, "Failed to write '%s' to '%s', ignoring: %m", action, filename);
                        continue;
                }

                if (settle_set) {
                        r = set_put_strdup(settle_set, syspath);
                        if (r < 0)
                                return log_oom();
                }
        }
开发者ID:Keruspe,项目名称:systemd,代码行数:32,代码来源:udevadm-trigger.c


示例15: log_writef

module_t *module_load(const char *Path, const char *File) {
	log_writef("Loading %s, path = %s.\n", File, Path);
	if (Path) return module_load_internal(Path, File, 0);
	//pthread_t Thread = pthread_self();
	//printf("<thread @ %x> Entering module_load:%d(%s, %s)\n", Thread, __LINE__, Path, File);
	const char *Alias = path_join("library:", File);
	pthread_mutex_lock(LibRivaMutex);
	module_t *Module = stringtable_get(Modules, Alias);
	pthread_mutex_unlock(LibRivaMutex);
	if (Module) {
		module_reload(Module);
		//printf("Found module %s = 0x%x\n", Alias, Module);
		//printf("<thread @ %x> Leaving module_load:%d(%s, %s)\n", Thread, __LINE__, Path, File);
		return Module;
	};
	for (path_node *Path = ModuleLibrary; Path; Path = Path->Next) {
		Module = module_load_internal(Path->Dir, File, Alias);
		if (Module) {
			//printf("<thread @ %x> Leaving module_load:%d(%s, %s)\n", Thread, __LINE__, Path, File);
			return Module;
		};
	};
	//printf("<thread @ %x> Leaving module_load:%d(%s, %s)\n", Thread, __LINE__, Path, File);
	return 0;
};
开发者ID:wrapl,项目名称:wrapl,代码行数:25,代码来源:module.c


示例16: remember_hash_path

// TODO: calling getcwd() every time might be slow.  This could be sped up by
// caching the current directory and intercepting chdir calls.
void remember_hash_path(struct hash *hash, const char *path)
{
    char cwd[PATH_MAX];
    if (!real_getcwd(cwd, PATH_MAX))
        die("remember_hash_path: getcwd failed: %s", strerror(errno));
    remember_hash_string(hash, path_join(cwd, path));
}
开发者ID:girving,项目名称:waitless,代码行数:9,代码来源:inverse_map.c


示例17: path_user_get

string path_user_get(const string& sub)
{
	if(cached_user_path == "")
		cached_user_path = path_dirname(Sysutil::this_program_path());

	return path_join(cached_user_path, sub);
}
开发者ID:UPBGE,项目名称:blender,代码行数:7,代码来源:util_path.cpp


示例18: extract_archive

static int extract_archive(struct vt_options* opt, vaht_archive* archive, char* out)
{
    uint16_t resource_types_count = vaht_archive_get_resource_types(archive);
    unsigned int t;
    for (t = 0; t < resource_types_count; t++)
    {
        const char* type = vaht_archive_get_resource_type(archive, t);
        
        /* check if we pass the type filter */
        if (opt->filter_type != NULL && strcmp(opt->filter_type, type) != 0)
        {
            /* we have failed the type filter! */
            continue;
        }

        /* if we're converting, but there's no extension for this type,
         * skip it
         */
        if (opt->convert && get_ext(opt, type) == NULL)
            continue;
        
        char* newdir = path_join(out, type);
        if (create_directory(opt, newdir))
        {
            free(newdir);
            return 1;
        }
        
        free(newdir);
        
        vaht_resource** resources = vaht_resources_open(archive, type);
        
        unsigned int r;
        for (r = 0; resources[r] != NULL; r++)
        {
            /* check if we pass the id filter */
            if (opt->filter_id != -1 && opt->filter_id != vaht_resource_id(resources[r]))
            {
                /* we failed the resource id filter! */
                continue;
            }
            
            char* ext = get_ext(opt, type);
            char* path = construct_path(resources[r], out, ext);
            
            if (write_resource(opt, resources[r], path))
            {
                vaht_resources_close(resources);
                free(path);
                return 1;
            }
            
            free(path);
        }
        
        vaht_resources_close(resources);
    }
    
    return 0;
}
开发者ID:agrif,项目名称:libvaht,代码行数:60,代码来源:mode-extract.c


示例19: load_modules

int load_modules() {
	plat_dir_t* dir = plat_opendir(mod_search_path);
	plat_dir_entry_t* d = NULL;
	char path[MODPATHLEN];

	if(!dir) {
		logmsg(LOG_CRIT, "Failed to open directory %s", mod_search_path);
		logerror();

		return -1;
	}

	while((d = plat_readdir(dir)) != NULL) {
		if( plat_dirent_hidden(d) ||
			plat_dirent_type(d) != DET_REG)
			continue;

		path_join(path, MODPATHLEN, mod_search_path, d->d_name, NULL);

		mod_load(path);
	}

	plat_closedir(dir);
	return 0;
}
开发者ID:ajantis,项目名称:vPerfGenerator,代码行数:25,代码来源:modules.c


示例20: link_update

/* manage "stack of names" with possibly specified device priorities */
static int link_update(sd_device *dev, const char *slink, bool add) {
        _cleanup_free_ char *target = NULL, *filename = NULL, *dirname = NULL;
        char name_enc[PATH_MAX];
        const char *id_filename;
        int r;

        assert(dev);
        assert(slink);

        r = device_get_id_filename(dev, &id_filename);
        if (r < 0)
                return log_device_debug_errno(dev, r, "Failed to get id_filename: %m");

        util_path_encode(slink + STRLEN("/dev"), name_enc, sizeof(name_enc));
        dirname = path_join("/run/udev/links/", name_enc);
        if (!dirname)
                return log_oom();
        filename = path_join(dirname, id_filename);
        if (!filename)
                return log_oom();

        if (!add && unlink(filename) == 0)
                (void) rmdir(dirname);

        r = link_find_prioritized(dev, add, dirname, &target);
        if (r < 0) {
                log_device_debug(dev, "No reference left, removing '%s'", slink);
                if (unlink(slink) == 0)
                        (void) rmdir_parents(slink, "/");
        } else
                (void) node_symlink(dev, target, slink);

        if (add)
                do {
                        _cleanup_close_ int fd = -1;

                        r = mkdir_parents(filename, 0755);
                        if (!IN_SET(r, 0, -ENOENT))
                                break;
                        fd = open(filename, O_WRONLY|O_CREAT|O_CLOEXEC|O_TRUNC|O_NOFOLLOW, 0444);
                        if (fd < 0)
                                r = -errno;
                } while (r == -ENOENT);

        return r;
}
开发者ID:tblume,项目名称:systemd-testsuite-suse,代码行数:47,代码来源:udev-node.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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