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


C++ path_basename函数代码示例

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


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

示例1: file_archive_extract_cb

static int file_archive_extract_cb(const char *name, const char *valid_exts,
                                   const uint8_t *cdata,
                                   unsigned cmode, uint32_t csize, uint32_t size,
                                   uint32_t checksum, void *userdata)
{
    const char *ext                   = path_get_extension(name);
    struct zip_extract_userdata *data = (struct zip_extract_userdata*)userdata;

    /* Extract first content that matches our list. */
    if (ext && string_list_find_elem(data->ext, ext))
    {
        char new_path[PATH_MAX_LENGTH] = {0};

        if (data->extraction_directory)
            fill_pathname_join(new_path, data->extraction_directory,
                               path_basename(name), sizeof(new_path));
        else
            fill_pathname_resolve_relative(new_path, data->zip_path,
                                           path_basename(name), sizeof(new_path));

        data->first_extracted_file_path = strdup(new_path);
        data->found_content             = file_archive_perform_mode(new_path,
                                          valid_exts, cdata, cmode, csize, size,
                                          0, NULL);
        return 0;
    }

    return 1;
}
开发者ID:GeneralFailer,项目名称:RetroArch,代码行数:29,代码来源:archive_file.c

示例2: makeflow_wrapper_umbrella_set_input_files

void makeflow_wrapper_umbrella_set_input_files(struct makeflow_wrapper_umbrella *w, struct batch_queue *queue, struct dag_node *n) {
	bool remote_rename_support = false;

	if(!w) return;

	// every rule may have its own umbrella spec file.
	// to avoid w->wrapper->input_files accumulating umbrella spec files for different rules, first delete it and then recreate it.
	list_delete(w->wrapper->input_files);
	w->wrapper->input_files = list_create();

	if(!n->umbrella_spec)  return;

	if (batch_queue_supports_feature(queue, "remote_rename")) {
		remote_rename_support = true;
	}

	// add umbrella_spec (if specified) and umbrella_binary (if specified) into the input file list of w->wrapper
	if (!remote_rename_support) {
		makeflow_wrapper_add_input_file(w->wrapper, n->umbrella_spec);
		if(w->binary) makeflow_wrapper_add_input_file(w->wrapper, w->binary);
	} else {
		{
			char *s = string_format("%s=%s", n->umbrella_spec, path_basename(n->umbrella_spec));
			if(!s) fatal("string_format for umbrella spec failed: %s.\n", strerror(errno));
			makeflow_wrapper_add_input_file(w->wrapper, s);
			free(s);
		}
		if(w->binary) {
			char *s = string_format("%s=%s", w->binary, path_basename(w->binary));
			if(!s) fatal("string_format for umbrella binary failed: %s.\n", strerror(errno));
			makeflow_wrapper_add_input_file(w->wrapper, s);
			free(s);
		}
	}
}
开发者ID:hmeng-19,项目名称:cctools,代码行数:35,代码来源:makeflow_wrapper_umbrella.c

示例3: OnListModule

static void OnListModule(void* param, const char* name)
{
	Result* result = (Result*)param;
	if(streq(path_basename(result->module), path_basename(name)))
	{
		result->result = 0; // find it
	}
}
开发者ID:hemengsi123,项目名称:bookspider,代码行数:8,代码来源:WebProcess.cpp

示例4: zip_extract_cb

static int zip_extract_cb(const char *name, const char *valid_exts,
      const uint8_t *cdata,
      unsigned cmode, uint32_t csize, uint32_t size,
      uint32_t checksum, void *userdata)
{
   struct zip_extract_userdata *data = (struct zip_extract_userdata*)userdata;

   /* Extract first content that matches our list. */
   const char *ext = path_get_extension(name);

   if (ext && string_list_find_elem(data->ext, ext))
   {
      char new_path[PATH_MAX_LENGTH] = {0};

      if (data->extraction_directory)
         fill_pathname_join(new_path, data->extraction_directory,
               path_basename(name), sizeof(new_path));
      else
         fill_pathname_resolve_relative(new_path, data->zip_path,
               path_basename(name), sizeof(new_path));

      switch (cmode)
      {
         case ZLIB_MODE_UNCOMPRESSED:
            data->found_content = zlib_write_file(new_path, cdata, size);
            return false;
         case ZLIB_MODE_DEFLATE:
            {
               int ret = 0;
               zlib_file_handle_t handle = {0};
               if (!zlib_inflate_data_to_file_init(&handle, cdata, csize, size))
                  return 0;

               do{
                  ret = zlib_inflate_data_to_file_iterate(handle.stream);
               }while(ret == 0);

               if (zlib_inflate_data_to_file(&handle, ret, new_path, valid_exts,
                        cdata, csize, size, checksum))
               {
                  strlcpy(data->zip_path, new_path, data->zip_path_size);
                  data->found_content = true;
                  return 0;
               }
               return 0;
            }

         default:
            return 0;
      }
   }

   return 1;
}
开发者ID:hbfelizzola,项目名称:RetroArch,代码行数:54,代码来源:file_extract.c

示例5: netplay_announce

static void netplay_announce(void)
{
   char buf [2048];
   char url [2048]               = "http://newlobby.libretro.com/add/";
   char *username                = NULL;
   char *corename                = NULL;
   char *gamename                = NULL;
   char *coreversion             = NULL;
   char *frontend_ident          = NULL;
   settings_t *settings          = config_get_ptr();
   rarch_system_info_t *system   = runloop_get_system_info();
   uint32_t content_crc          = content_get_crc();
   char frontend_architecture[PATH_MAX_LENGTH];

   netplay_get_architecture(frontend_architecture, sizeof(frontend_architecture));

   net_http_urlencode(&username, settings->paths.username);
   net_http_urlencode(&corename, system->info.library_name);
   net_http_urlencode(&gamename,
      !string_is_empty(path_basename(path_get(RARCH_PATH_BASENAME))) ?
      path_basename(path_get(RARCH_PATH_BASENAME)) : "N/A");
   net_http_urlencode(&coreversion, system->info.library_version);
   net_http_urlencode(&frontend_ident, frontend_architecture);

   buf[0] = '\0';

   snprintf(buf, sizeof(buf), "username=%s&core_name=%s&core_version=%s&"
      "game_name=%s&game_crc=%08X&port=%d&mitm_server=%s"
      "&has_password=%d&has_spectate_password=%d&force_mitm=%d&retroarch_version=%s&frontend=%s",
      username, corename, coreversion, gamename, content_crc,
      settings->uints.netplay_port,
      settings->arrays.netplay_mitm_server,
      *settings->paths.netplay_password ? 1 : 0,
      *settings->paths.netplay_spectate_password ? 1 : 0,
      settings->bools.netplay_use_mitm_server,
      PACKAGE_VERSION, frontend_architecture);
#if 0
   RARCH_LOG("[netplay] announcement URL: %s\n", buf);
#endif
   task_push_http_post_transfer(url, buf, true, NULL, netplay_announce_cb, NULL);

   if (username)
      free(username);
   if (corename)
      free(corename);
   if (gamename)
      free(gamename);
   if (coreversion)
      free(coreversion);
   if (frontend_ident)
      free(frontend_ident);
}
开发者ID:DoctorGoat,项目名称:RetroArch_LibNX,代码行数:52,代码来源:netplay_frontend.c

示例6: chirp_fs_confuga_open

static INT64_T chirp_fs_confuga_open (const char *path, INT64_T flags, INT64_T mode)
{
	int rc;
	char *data = NULL;
	int fd = getfd();

	strncpy(open_files[fd].path, path, sizeof(open_files[fd].path)-1);
	switch (flags & O_ACCMODE) {
		case O_RDONLY:
			if (strncmp(path_basename(path), ".__", 3) == 0) {
				size_t len;
				buffer_init(&open_files[fd].f.metadata);
				CATCH(confuga_metadata_lookup(C, path, &data, &len));
				CATCHUNIX(buffer_putlstring(&open_files[fd].f.metadata, data, len));
				open_files[fd].type = CHIRP_FS_CONFUGA_META_READ;
			} else {
				confuga_fid_t fid;
				CATCH_CONFUGA(confuga_lookup(C, path, &fid, NULL));
				CATCH_CONFUGA(confuga_replica_open(C, fid, &open_files[fd].f.replica, STOPTIME));
				open_files[fd].type = CHIRP_FS_CONFUGA_REPL_READ;
			}
			break;
		case O_WRONLY:
			if (strncmp(path_basename(path), ".__", 3) == 0) {
				buffer_init(&open_files[fd].f.metadata);
				open_files[fd].type = CHIRP_FS_CONFUGA_META_WRITE;
			} else {
				CATCH_CONFUGA(confuga_file_create(C, &open_files[fd].f.file.file, STOPTIME));
				open_files[fd].f.file.size = 0;
				open_files[fd].f.file.flags = 0;
				if (flags & O_EXCL)
					open_files[fd].f.file.flags |= CONFUGA_O_EXCL;
				open_files[fd].type = CHIRP_FS_CONFUGA_FILE_WRITE;
			}
			break;
		case O_RDWR:
			CATCH(EINVAL);
		default:
			assert(0);
	}

	rc = 0;
	goto out;
out:
	free(data);
	if (rc)
		return (errno = rc, -1);
	else
		return fd; /* N.B. return fd on success */

}
开发者ID:LydiaBrothers,项目名称:cctools,代码行数:51,代码来源:chirp_fs_confuga.c

示例7: OnListProcess

static int OnListProcess(void* param, const char* name, process_t pid)
{
	Result* result = (Result*)param;
	if(streq(path_basename(name), path_basename(result->name)))
	{
		process_getmodules(pid, OnListModule, param);
		if(0 == result->result)
		{
			*result->pid = pid;
			return 1;
		}
	}
	return 0;
}
开发者ID:hemengsi123,项目名称:bookspider,代码行数:14,代码来源:WebProcess.cpp

示例8: do_put

static INT64_T do_put(int argc, char **argv)
{
	char target_full_path[CHIRP_PATH_MAX];
	char source_full_path[CHIRP_PATH_MAX];
	timestamp_t start, stop;
	double elapsed;
	INT64_T result;

	if(!argv[2])
		argv[2] = (char *) path_basename(argv[1]);

	complete_local_path(argv[1], source_full_path);
	complete_remote_path(argv[2], target_full_path);

	start = timestamp_get();
	result = chirp_recursive_put(current_host, source_full_path, target_full_path, stoptime);
	stop = timestamp_get();

	elapsed = (stop - start) / 1000000.0;

	if(result > 0) {
		printf("%sB written in %.2fs ", string_metric(result, -1, 0), elapsed);
		printf("(%sB/s)\n", string_metric(result / elapsed, -1, 0));
	}

	return result;
}
开发者ID:ailurus1991,项目名称:cctools,代码行数:27,代码来源:chirp_tool.c

示例9: path_basename

/* Returns the filename extension.
 *
 * To extract multiple extensions (e.g. .tar.gz) call path_extension multiple
 * times and concatenate the results.
 */
const char *path_extension (const char *path)
{
	const char *base = path_basename(path);
	const char *dot = strrchr(base, '.');
	if(!dot || dot == base) return NULL;
	return dot + 1;
}
开发者ID:Macainian,项目名称:cctools,代码行数:12,代码来源:path.c

示例10: tal_fmt

/* Creates and adds an example file. */
static char *add_example(struct manifest *m, struct ccan_file *source,
			 struct doc_section *example)
{
	char *name, *linemarker;
	unsigned int i;
	int fd;
	struct ccan_file *f;

	name = tal_fmt(m, "example-%s-%s",
		       source->name, example->function);
	/* example->function == 'struct foo' */
	while (strchr(name, ' '))
		*strchr(name, ' ') = '_';

	name = temp_file(m, ".c", take(name));
	f = new_ccan_file(m, take(path_dirname(m, name)),
			  take(path_basename(m, name)));
	tal_steal(f, name);
	list_add_tail(&m->examples, &f->list);

	fd = open(f->fullname, O_WRONLY | O_CREAT | O_EXCL, 0600);
	if (fd < 0)
		return tal_fmt(m, "Creating temporary file %s: %s",
			       f->fullname, strerror(errno));

	/* Add #line to demark where we are from, so errors are correct! */
	linemarker = tal_fmt(f, "#line %i \"%s\"\n",
			     example->srcline+2, source->fullname);
	if (write(fd, linemarker, strlen(linemarker)) != (int)strlen(linemarker)) {
		close(fd);
		return cast_const(char *, "Failure writing to temporary file");
	}
开发者ID:dgibson,项目名称:ccan,代码行数:33,代码来源:examples_exist.c

示例11: core_info_database_supports_content_path

bool core_info_database_supports_content_path(const char *database_path, const char *path)
{
   size_t i;
   char *database = NULL;

   if (!core_info_curr_list)
      return false;

   database = strdup(path_basename(database_path));

   path_remove_extension(database);

   for (i = 0; i < core_info_curr_list->count; i++)
   {
      const core_info_t *info = &core_info_curr_list->list[i];

      if (string_list_find_elem(info->supported_extensions_list, path_get_extension(path)))
         if (string_list_find_elem(info->databases_list, database))
         {
            free(database);
            return true;
         }
   }

   free(database);
   return false;
}
开发者ID:KitoHo,项目名称:RetroArch,代码行数:27,代码来源:core_info.c

示例12: fill_short_pathname_representation

/**
 * fill_short_pathname_representation:
 * @out_rep            : output representation
 * @in_path            : input path
 * @size               : size of output representation
 *
 * Generates a short representation of path. It should only
 * be used for displaying the result; the output representation is not
 * binding in any meaningful way (for a normal path, this is the same as basename)
 * In case of more complex URLs, this should cut everything except for
 * the main image file.
 *
 * E.g.: "/path/to/game.img" -> game.img
 *       "/path/to/myarchive.7z#folder/to/game.img" -> game.img
 */
void fill_short_pathname_representation(char* out_rep,
                                        const char *in_path, size_t size)
{
    char path_short[PATH_MAX_LENGTH];
#ifdef HAVE_COMPRESSION
    char *last_slash                  = NULL;
#endif

    path_short[0] = '\0';

    fill_pathname(path_short, path_basename(in_path), "",
                  sizeof(path_short));

#ifdef HAVE_COMPRESSION
    last_slash  = find_last_slash(path_short);
    if (last_slash != NULL)
    {
        /* We handle paths like:
         * /path/to/file.7z#mygame.img
         * short_name: mygame.img:
         *
         * We check whether something is actually
         * after the hash to avoid going over the buffer.
         */
        retro_assert(strlen(last_slash) > 1);
        strlcpy(out_rep, last_slash + 1, size);
    }
    else
#endif
        strlcpy(out_rep, path_short, size);
}
开发者ID:heuripedes,项目名称:RetroArch,代码行数:46,代码来源:file_path.c

示例13:

char *path_remove_extension(char *path)
{
   char *last = (char*)strrchr(path_basename(path), '.');
   if (*last)
      *last = '\0';
   return last;
}
开发者ID:SuperrSonic,项目名称:RA-SS,代码行数:7,代码来源:file_path.c

示例14: action_ok_remap_file_save_game

static int action_ok_remap_file_save_game(const char *path,
      const char *label, unsigned type, size_t idx)
{
   global_t *global = global_get_ptr();
   settings_t *settings = config_get_ptr();

   const char *core_name;
   core_name = global->system.info.library_name;

   const char *game_name;
   game_name = path_basename(global->basename);

   char directory[PATH_MAX_LENGTH];
   char file[PATH_MAX_LENGTH];

   fill_pathname_join(directory,settings->input_remapping_directory,core_name,PATH_MAX_LENGTH);
   fill_pathname_join(file,core_name,game_name,PATH_MAX_LENGTH);

   if(!path_file_exists(directory))
       path_mkdir(directory);

   if(input_remapping_save_file(file))
      rarch_main_msg_queue_push("Remap file saved successfully", 1, 100, true);
   else
      rarch_main_msg_queue_push("Error saving remap file", 1, 100, true);

   return 0;
}
开发者ID:beshio,项目名称:RetroArch,代码行数:28,代码来源:menu_entries_cbs_ok.c

示例15: hi_linux_sysfs_readlink_aas

/**
 * Reads symbolic link destination from sysfs, and copies it to
 * auto-allocated string `aas`.
 * 
 * @param aas		auto-allocated string 
 * @param basename	if this flag is set, take basename of link destination	\
 * 					before copying
 * 
 * @return HI_LINUX_SYSFS_OK if everything went fine or HI_LINUX_SYSFS_ERROR if	\
 * 		   `path_join_aas()` or `readlink()` were failed
 */
int hi_linux_sysfs_readlink_aas(const char* root, const char* name, const char* object,
						   	    char** aas, boolean_t basename) {
	AUTOSTRING char* path;
	
	char link[PATHMAXLEN];
	ssize_t link_sz;
	
	if(path_join_aas(&path, root, name, object, NULL) == NULL) {
		hi_sysfs_dprintf("hi_linux_sysfs_readlink_aas: failed to do path_join\n");
		return HI_LINUX_SYSFS_ERROR;
	}
	
	link_sz = readlink(path, link, PATHMAXLEN);
	if(link_sz == -1) {
		hi_sysfs_dprintf("hi_linux_sysfs_readlink_aas: failed to readlink(): errno = %d\n", errno);
		return HI_LINUX_SYSFS_ERROR;
	}
	
	link[link_sz] = '\0';
	
	hi_sysfs_dprintf("hi_linux_sysfs_readlink_aas: %s/%s/%s => %s\n", root, name, object, link);
	
	if(basename) {
		path_split_iter_t iter;
		aas_copy(aas, path_basename(&iter, link));
	}
	else {
		aas_copy(aas, link);
	}
	
	return HI_LINUX_SYSFS_OK;
}
开发者ID:myaut,项目名称:tsload,代码行数:43,代码来源:sysfs.c


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