本文整理汇总了C++中path_join函数的典型用法代码示例。如果您正苦于以下问题:C++ path_join函数的具体用法?C++ path_join怎么用?C++ path_join使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了path_join函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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
}
示例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;
}
示例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;
}
示例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));
}
示例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);
}
示例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();
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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();
}
示例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;
}
示例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();
}
}
示例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;
};