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


C++ path_is_absolute函数代码示例

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


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

示例1: path_prepend

char* path_prepend( char* tail, const char* base )
{
	if( !tail )
		return path_clean( string_clone( base ), path_is_absolute( base ) );
	tail = string_prepend( tail, "/" );
	tail = string_prepend( tail, base );
	tail = path_clean( tail, path_is_absolute( tail ) );
	return tail;
}
开发者ID:HardlyHaki,项目名称:ProDBG,代码行数:9,代码来源:path.c

示例2: path_append

char* path_append( char* base, const char* tail )
{
	if( !base )
		return path_clean( string_clone( tail ), path_is_absolute( tail ) );
	base = string_append( base, "/" );
	base = string_append( base, tail );
	base = path_clean( base, path_is_absolute( base ) );
	return base;
}
开发者ID:HardlyHaki,项目名称:ProDBG,代码行数:9,代码来源:path.c

示例3: ps_default_search_args

void
ps_default_search_args(cmd_ln_t *config)
{
#ifdef MODELDIR
    /* Set default acoustic and language models. */
    const char *hmmdir = cmd_ln_str_r(config, "-hmm");
    if (hmmdir == NULL && hmmdir_exists(MODELDIR "/en-us/en-us")) {
        hmmdir = MODELDIR "/en-us/en-us";
        cmd_ln_set_str_r(config, "-hmm", hmmdir);
    }

    const char *lmfile = cmd_ln_str_r(config, "-lm");

    if (lmfile == NULL && !cmd_ln_str_r(config, "-fsg")
        && !cmd_ln_str_r(config, "-jsgf")
        && !cmd_ln_str_r(config, "-lmctl")
        && !cmd_ln_str_r(config, "-kws")
        && !cmd_ln_str_r(config, "-keyphrase")
        && file_exists(MODELDIR "/en-us/en-us.lm.dmp")) {
        lmfile = MODELDIR "/en-us/en-us.lm.dmp";
        cmd_ln_set_str_r(config, "-lm", lmfile);
    }

    const char *dictfile = cmd_ln_str_r(config, "-dict");
    if (dictfile == NULL && file_exists(MODELDIR "/en-us/cmudict-en-us.dict")) {
        dictfile = MODELDIR "/en-us/cmudict-en-us.dict";
        cmd_ln_set_str_r(config, "-dict", dictfile);
    }

    /* Expand acoustic and language model filenames relative to installation
     * path. */
    if (hmmdir && !path_is_absolute(hmmdir) && !hmmdir_exists(hmmdir)) {
        char *tmphmm = string_join(MODELDIR "/hmm/", hmmdir, NULL);
        if (hmmdir_exists(tmphmm)) {
            cmd_ln_set_str_r(config, "-hmm", tmphmm);
        } else {
            E_ERROR("Failed to find mdef file inside the model folder "
                    "specified with -hmm `%s'\n", hmmdir);
        }
        ckd_free(tmphmm);
    }
    if (lmfile && !path_is_absolute(lmfile) && !file_exists(lmfile)) {
        char *tmplm = string_join(MODELDIR "/lm/", lmfile, NULL);
        cmd_ln_set_str_r(config, "-lm", tmplm);
        ckd_free(tmplm);
    }
    if (dictfile && !path_is_absolute(dictfile) && !file_exists(dictfile)) {
        char *tmpdict = string_join(MODELDIR "/lm/", dictfile, NULL);
        cmd_ln_set_str_r(config, "-dict", tmpdict);
        ckd_free(tmpdict);
    }
#endif
}
开发者ID:jhector,项目名称:sphinxfuzz,代码行数:53,代码来源:pocketsphinx.c

示例4: bin2hex_process_files

int bin2hex_process_files( char const* const* input, char const* const* output, int columns )
{
    int result = BIN2HEX_RESULT_OK;
    unsigned int ifile, files_size;
    for( ifile = 0, files_size = array_size( input ); ( result == BIN2HEX_RESULT_OK ) && ( ifile < files_size ); ++ifile )
    {
        char* input_filename = 0;
        char* output_filename = 0;

        stream_t* input_file = 0;
        stream_t* output_file = 0;

        input_filename = path_clean( string_clone( input[ifile] ), path_is_absolute( input[ifile] ) );
        error_context_push( "parsing file", input_filename );

        output_filename = path_clean( string_clone( output[ifile] ), path_is_absolute( output[ifile] ) );

        log_infof( 0, "bin2hex %s -> %s", input_filename, output_filename );

        input_file = stream_open( input_filename, STREAM_IN | STREAM_BINARY );

        if( !input_file )
        {
            log_warnf( 0, WARNING_BAD_DATA, "Unable to open input file: %s", input_filename );
            result = BIN2HEX_RESULT_MISSING_INPUT_FILE;
        }
        else
        {
            output_file = stream_open( output_filename, STREAM_OUT );
            if( !output_file )
            {
                log_warnf( 0, WARNING_BAD_DATA, "Unable to open output file: %s", output_filename );
                result = BIN2HEX_RESULT_UNABLE_TO_OPEN_OUTPUT_FILE;
            }
        }

        if( input_file && output_file )
            result = bin2hex_process_file( input_file, output_file, columns );

        stream_deallocate( input_file );
        stream_deallocate( output_file );

        string_deallocate( output_filename );

        error_context_pop();
        string_deallocate( input_filename );
    }

    if( ( result == BIN2HEX_RESULT_OK ) && ( files_size > 0 ) )
        log_info( 0, "All files generated" );

    return result;
}
开发者ID:apprisi,项目名称:foundation_lib,代码行数:53,代码来源:main.c

示例5: append_access_mounts

static int append_access_mounts(MountEntry **p, char **strv, MountMode mode, bool forcibly_require_prefix) {
        char **i;

        assert(p);

        /* Adds a list of user-supplied READWRITE/READONLY/INACCESSIBLE entries */

        STRV_FOREACH(i, strv) {
                bool ignore = false, needs_prefix = false;
                const char *e = *i;

                /* Look for any prefixes */
                if (startswith(e, "-")) {
                        e++;
                        ignore = true;
                }
                if (startswith(e, "+")) {
                        e++;
                        needs_prefix = true;
                }

                if (!path_is_absolute(e))
                        return -EINVAL;

                *((*p)++) = (MountEntry) {
                        .path_const = e,
                        .mode = mode,
                        .ignore = ignore,
                        .has_prefix = !needs_prefix && !forcibly_require_prefix,
                };
        }

        return 0;
}
开发者ID:heftig,项目名称:systemd,代码行数:34,代码来源:namespace.c

示例6: rWarning

void Doom3MapCompiler::dmapCmd(const cmd::ArgumentList& args)
{
	if (args.size() != 1)
	{
		rWarning() << "Usage: dmap <mapFile>" << std::endl;
		return;
	}

	std::string mapFile = args[0].getString();
	
	if (!boost::algorithm::iends_with(mapFile, ".map"))
	{
		mapFile.append(".map");
	}

	std::string mapPath = mapFile;

	// Find the map file
	if (!path_is_absolute(mapPath.c_str()))
	{
		mapPath = GlobalFileSystem().findFile(mapFile);

		if (mapPath.empty())
		{
			// Try again with maps/ prepended
			mapFile = "maps/" + mapFile;
			mapPath = GlobalFileSystem().findFile(mapFile);
		}

		mapPath += mapFile;
	}

	// Start the sequence
	runDmap(mapPath);
}
开发者ID:OpenTechEngine,项目名称:DarkRadiant,代码行数:35,代码来源:Doom3MapCompiler.cpp

示例7: _getSearchPaths

/* Parse a given config.ini file and extract the list of SDK search paths
 * from it. Returns the number of valid paths stored in 'searchPaths', or -1
 * in case of problem.
 *
 * Relative search paths in the config.ini will be stored as full pathnames
 * relative to 'sdkRootPath'.
 *
 * 'searchPaths' must be an array of char* pointers of at most 'maxSearchPaths'
 * entries.
 */
static int
_getSearchPaths( IniFile*    configIni,
                 const char* sdkRootPath,
                 int         maxSearchPaths,
                 char**      searchPaths )
{
    char  temp[PATH_MAX], *p = temp, *end= p+sizeof temp;
    int   nn, count = 0;

    for (nn = 0; nn < maxSearchPaths; nn++) {
        char*  path;

        p = bufprint(temp, end, "%s%d", SEARCH_PREFIX, nn+1 );
        if (p >= end)
            continue;

        path = iniFile_getString(configIni, temp, NULL);
        if (path != NULL) {
            DD("    found image search path: %s", path);
            if (!path_is_absolute(path)) {
                p = bufprint(temp, end, "%s/%s", sdkRootPath, path);
                AFREE(path);
                path = ASTRDUP(temp);
            }
            searchPaths[count++] = path;
        }
    }
    return count;
}
开发者ID:bindassdost,项目名称:razrd,代码行数:39,代码来源:info.c

示例8: add_root_mount

static int add_root_mount(void) {
        _cleanup_free_ char *what = NULL;
        const char *opts;

        if (isempty(arg_root_what)) {
                log_debug("Could not find a root= entry on the kernel command line.");
                return 0;
        }

        what = fstab_node_to_udev_node(arg_root_what);
        if (!path_is_absolute(what)) {
                log_debug("Skipping entry what=%s where=/sysroot type=%s", what, strna(arg_root_fstype));
                return 0;
        }

        if (!arg_root_options)
                opts = arg_root_rw > 0 ? "rw" : "ro";
        else if (arg_root_rw >= 0 ||
                 !fstab_test_option(arg_root_options, "ro\0" "rw\0"))
                opts = strjoina(arg_root_options, ",", arg_root_rw > 0 ? "rw" : "ro");
        else
                opts = arg_root_options;

        log_debug("Found entry what=%s where=/sysroot type=%s", what, strna(arg_root_fstype));
        return add_mount(what,
                         "/sysroot",
                         arg_root_fstype,
                         opts,
                         1,
                         false,
                         false,
                         false,
                         SPECIAL_INITRD_ROOT_FS_TARGET,
                         "/proc/cmdline");
}
开发者ID:RaghavanSanthanam,项目名称:systemd,代码行数:35,代码来源:fstab-generator.c

示例9: path_make_absolute_cwd

int path_make_absolute_cwd(const char *p, char **ret) {
        char *c;

        assert(p);
        assert(ret);

        /* Similar to path_make_absolute(), but prefixes with the
         * current working directory. */

        if (path_is_absolute(p))
                c = strdup(p);
        else {
                _cleanup_free_ char *cwd = NULL;

                cwd = get_current_dir_name();
                if (!cwd)
                        return negative_errno();

                c = strjoin(cwd, "/", p, NULL);
        }
        if (!c)
                return -ENOMEM;

        *ret = c;
        return 0;
}
开发者ID:BenjaminLefoul,项目名称:systemd,代码行数:26,代码来源:path-util.c

示例10: strdup

char *path_make_absolute_cwd(const char *p)
{
	char *cwd, *r;
	size_t plen;
	size_t cwdlen;

	if (path_is_absolute(p))
		return strdup(p);

	cwd = get_current_dir_name();
	if (cwd == NULL)
		return NULL;

	plen = strlen(p);
	cwdlen = strlen(cwd);

	/* cwd + '/' + p + '\0' */
	r = realloc(cwd, cwdlen + 1 + plen + 1);
	if (r == NULL) {
		free(cwd);
		return NULL;
	}

	r[cwdlen] = '/';
	memcpy(&r[cwdlen + 1], p, plen + 1);

	return r;
}
开发者ID:StarchLinux,项目名称:kmod,代码行数:28,代码来源:libkmod-util.c

示例11: condition_test_needs_update

static int condition_test_needs_update(Condition *c) {
        const char *p;
        struct stat usr, other;

        assert(c);
        assert(c->parameter);
        assert(c->type == CONDITION_NEEDS_UPDATE);

        /* If the file system is read-only we shouldn't suggest an update */
        if (path_is_read_only_fs(c->parameter) > 0)
                return false;

        /* Any other failure means we should allow the condition to be true,
         * so that we rather invoke too many update tools then too
         * few. */

        if (!path_is_absolute(c->parameter))
                return true;

        p = strjoina(c->parameter, "/.updated");
        if (lstat(p, &other) < 0)
                return true;

        if (lstat("/usr/", &usr) < 0)
                return true;

        return usr.st_mtim.tv_sec > other.st_mtim.tv_sec ||
                (usr.st_mtim.tv_sec == other.st_mtim.tv_sec && usr.st_mtim.tv_nsec > other.st_mtim.tv_nsec);
}
开发者ID:blaskovic,项目名称:systemd-rhel,代码行数:29,代码来源:condition.c

示例12: cg_fix_path

int cg_fix_path(const char *path, char **result) {
        char *t, *c, *p;
        int r;

        assert(path);
        assert(result);

        /* First check if it already is a filesystem path */
        if (path_is_absolute(path) &&
            path_startswith(path, "/sys/fs/cgroup") &&
            access(path, F_OK) >= 0) {

                if (!(t = strdup(path)))
                        return -ENOMEM;

                *result = t;
                return 0;
        }

        /* Otherwise treat it as cg spec */
        if ((r = cg_split_spec(path, &c, &p)) < 0)
                return r;

        r = cg_get_path(c ? c : SYSTEMD_CGROUP_CONTROLLER, p ? p : "/", NULL, result);
        free(c);
        free(p);

        return r;
}
开发者ID:tizenorg,项目名称:external.systemd,代码行数:29,代码来源:cgroup-util.c

示例13: al_make_path_absolute

/* Function: al_make_path_absolute
 */
bool al_make_path_absolute(ALLEGRO_PATH *path)
{
   ALLEGRO_PATH *cwd_path;
   int i;

   ASSERT(path);

   if (path_is_absolute(path)) {
      return true;
   }

   cwd_path = al_get_current_directory();
   if (!cwd_path)
      return false;

   al_set_path_drive(path, al_get_path_drive(cwd_path));

   for (i = al_get_path_num_components(cwd_path) - 1; i >= 0; i--) {
      al_insert_path_component(path, 0, al_get_path_component(cwd_path, i));
   }

   al_destroy_path(cwd_path);

   return true;
}
开发者ID:sesc4mt,项目名称:mvcdecoder,代码行数:27,代码来源:path.c

示例14: get_home_dir

int get_home_dir(char **_h) {
        struct passwd *p;
        const char *e;
        char *h;
        uid_t u;

        assert(_h);

        /* Take the user specified one */
        e = secure_getenv("HOME");
        if (e && path_is_absolute(e)) {
                h = strdup(e);
                if (!h)
                        return -ENOMEM;

                *_h = h;
                return 0;
        }

        /* Hardcode home directory for root to avoid NSS */
        u = getuid();
        if (u == 0) {
                h = strdup("/root");
                if (!h)
                        return -ENOMEM;

                *_h = h;
                return 0;
        }

        /* Check the database... */
        errno = 0;
        p = getpwuid(u);
        if (!p)
                return errno > 0 ? -errno : -ESRCH;

        if (!path_is_absolute(p->pw_dir))
                return -EINVAL;

        h = strdup(p->pw_dir);
        if (!h)
                return -ENOMEM;

        *_h = h;
        return 0;
}
开发者ID:aulanov,项目名称:systemd,代码行数:46,代码来源:user-util.c

示例15: path_subdirectory_name

char* path_subdirectory_name( const char* path, const char* root )
{
	char* subpath;
	char* testpath;
	char* testroot;
	char* pathofpath;
	unsigned int pathprotocol, rootprotocol;
	char* cpath = string_clone( path );
	char* croot = string_clone( root );

	cpath = path_clean( cpath, path_is_absolute( cpath ) );
	croot = path_clean( croot, path_is_absolute( croot ) );

	pathofpath = path_directory_name( cpath );

	testpath = pathofpath;
	pathprotocol = string_find_string( testpath, "://", 0 );
	if( pathprotocol != STRING_NPOS )
		testpath += pathprotocol + 2; // add two to treat as absolute path

	testroot = croot;
	rootprotocol = string_find_string( testroot, "://", 0 );
	if( rootprotocol != STRING_NPOS )
		testroot += rootprotocol + 2;

	if( ( rootprotocol != STRING_NPOS ) && ( ( pathprotocol == STRING_NPOS ) || ( pathprotocol != rootprotocol ) || !string_equal_substr( cpath, croot, rootprotocol ) ) )
		subpath = string_allocate( 0 );
	else if( !string_equal_substr( testpath, testroot, string_length( testroot ) ) )
		subpath = string_allocate( 0 );
	else
	{
		char* filename = path_file_name( cpath );

		subpath = string_substr( testpath, string_length( testroot ), STRING_NPOS );
		subpath = path_clean( path_append( subpath, filename ), false );

		string_deallocate( filename );
	}
	string_deallocate( pathofpath );
	string_deallocate( cpath );
	string_deallocate( croot );

	return subpath;
}
开发者ID:HardlyHaki,项目名称:ProDBG,代码行数:44,代码来源:path.c


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