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

C++ create_temp_file函数代码示例

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

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



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

示例1: test_3_1

void test_3_1(void) {
  chidb *db;
  BTreeNode *btn;
  
  create_temp_file(TESTFILE_1);
	
  db = malloc(sizeof(chidb));
  chidb_Btree_open(TEMPFILE, db, &db->bt);
  
  chidb_Btree_getNodeByPage(db->bt, 1, &btn);
  btn->type = PGTYPE_INDEX_INTERNAL;
  btn->n_cells = 2;
  btn->right_page = 3;
  btn->free_offset = 116;
  btn->cells_offset = 1008;
  chidb_Btree_writeNode(db->bt, btn);
  chidb_Btree_freeMemNode(db->bt, btn);	
  
  chidb_Btree_getNodeByPage(db->bt, 1, &btn);
  btn_sanity_check(db->bt, btn, false);
  CU_ASSERT(btn->type == PGTYPE_INDEX_INTERNAL);
  CU_ASSERT(btn->n_cells == 2);
  CU_ASSERT(btn->right_page == 3);
  CU_ASSERT(btn->free_offset == 116);
  CU_ASSERT(btn->cells_offset == 1008);
  chidb_Btree_freeMemNode(db->bt, btn);	
  
  chidb_Btree_close(db->bt);
  free(db);
}
开发者ID:jsachs,项目名称:uchidb,代码行数:30,代码来源:tests-btree.c


示例2: test_3_2

void test_3_2(void)
{
  chidb *db;
  BTreeNode *btn;
  
  create_temp_file(TESTFILE_1);
  
  db = malloc(sizeof(chidb));
  chidb_Btree_open(TEMPFILE, db, &db->bt);
  
  chidb_Btree_getNodeByPage(db->bt, 2, &btn);
  btn->type = PGTYPE_INDEX_LEAF;
  btn->n_cells = 3;
  btn->free_offset = 14;
  btn->cells_offset = 616;
  chidb_Btree_writeNode(db->bt, btn);
  chidb_Btree_freeMemNode(db->bt, btn);	
  
  chidb_Btree_getNodeByPage(db->bt, 2, &btn);
  btn_sanity_check(db->bt, btn, false);
  CU_ASSERT(btn->type == PGTYPE_INDEX_LEAF);
  CU_ASSERT(btn->n_cells == 3);
  CU_ASSERT(btn->free_offset == 14);
  CU_ASSERT(btn->cells_offset == 616);
  chidb_Btree_freeMemNode(db->bt, btn);	
  
  chidb_Btree_close(db->bt);
  free(db);
}
开发者ID:jsachs,项目名称:uchidb,代码行数:29,代码来源:tests-btree.c


示例3: prepare

static void
prepare (void)
{
  fd = create_temp_file ("wrewind.", NULL);
  if (fd == -1)
    exit (3);
}
开发者ID:AubrCool,项目名称:glibc,代码行数:7,代码来源:bug-rewind.c


示例4: svn_repos__hooks_pre_revprop_change

svn_error_t  *
svn_repos__hooks_pre_revprop_change(svn_repos_t *repos,
                                    svn_revnum_t rev,
                                    const char *author,
                                    const char *name,
                                    const svn_string_t *new_value,
                                    char action,
                                    apr_pool_t *pool)
{
  const char *hook = svn_repos_pre_revprop_change_hook(repos, pool);
  svn_boolean_t broken_link;

  if ((hook = check_hook_cmd(hook, &broken_link, pool)) && broken_link)
    {
      return hook_symlink_error(hook);
    }
  else if (hook)
    {
      const char *args[7];
      apr_file_t *stdin_handle = NULL;
      char action_string[2];

      /* Pass the new value as stdin to hook */
      if (new_value)
        SVN_ERR(create_temp_file(&stdin_handle, new_value, pool));
      else
        SVN_ERR(svn_io_file_open(&stdin_handle, SVN_NULL_DEVICE_NAME,
                                 APR_READ, APR_OS_DEFAULT, pool));

      action_string[0] = action;
      action_string[1] = '\0';

      args[0] = hook;
      args[1] = svn_dirent_local_style(svn_repos_path(repos, pool), pool);
      args[2] = apr_psprintf(pool, "%ld", rev);
      args[3] = author ? author : "";
      args[4] = name;
      args[5] = action_string;
      args[6] = NULL;

      SVN_ERR(run_hook_cmd(NULL, SVN_REPOS__HOOK_PRE_REVPROP_CHANGE, hook,
                           args, repos->hooks_env, stdin_handle, pool));

      SVN_ERR(svn_io_file_close(stdin_handle, pool));
    }
  else
    {
      /* If the pre- hook doesn't exist at all, then default to
         MASSIVE PARANOIA.  Changing revision properties is a lossy
         operation; so unless the repository admininstrator has
         *deliberately* created the pre-hook, disallow all changes. */
      return
        svn_error_create
        (SVN_ERR_REPOS_DISABLED_FEATURE, NULL,
         _("Repository has not been enabled to accept revision propchanges;\n"
           "ask the administrator to create a pre-revprop-change hook"));
    }

  return SVN_NO_ERROR;
}
开发者ID:dtrebbien,项目名称:subversion,代码行数:60,代码来源:hooks.c


示例5: do_prepare

static void
do_prepare (int argc, char *argv[])
{
  int fd = create_temp_file ("tst-sysvmsg.", &name);
  if (fd == -1)
    FAIL_EXIT1 ("cannot create temporary file (errno=%d)", errno);
}
开发者ID:riscv,项目名称:riscv-glibc,代码行数:7,代码来源:test-sysvmsg.c


示例6: do_prepare

static void
do_prepare (void)
{
  int logfd = create_temp_file ("logfile", &logname);
  close (logfd);

  int fd1 = create_temp_file ("testscript", &fname1);
  dprintf (fd1, "echo foo $1 $2 $3 > %s\n", logname);
  fchmod (fd1, 0700);
  close (fd1);

  int fd2 = create_temp_file ("testscript", &fname2);
  dprintf (fd2, "echo foo > %s\n", logname);
  fchmod (fd2, 0700);
  close (fd2);
}
开发者ID:bminor,项目名称:glibc,代码行数:16,代码来源:tst-execvpe6.c


示例7: svn_fs__access_get_lock_tokens

/* Set *HANDLE to an open filehandle for a temporary file (i.e.,
   automatically deleted when closed), into which the LOCK_TOKENS have
   been written out in the format described in the pre-commit hook
   template.

   LOCK_TOKENS is as returned by svn_fs__access_get_lock_tokens().

   Allocate *HANDLE in POOL, and use POOL for temporary allocations. */
static svn_error_t *
lock_token_content(apr_file_t **handle, apr_hash_t *lock_tokens,
                   apr_pool_t *pool)
{
  svn_stringbuf_t *lock_str = svn_stringbuf_create("LOCK-TOKENS:\n", pool);
  apr_hash_index_t *hi;

  for (hi = apr_hash_first(pool, lock_tokens); hi;
       hi = apr_hash_next(hi))
    {
      void *val;
      const char *path, *token;

      apr_hash_this(hi, (void *)&token, NULL, &val);
      path = val;
      svn_stringbuf_appendstr(lock_str,
        svn_stringbuf_createf(pool, "%s|%s\n",
                              svn_path_uri_autoescape(path, pool),
                              token));
    }

  svn_stringbuf_appendcstr(lock_str, "\n");
  return create_temp_file(handle,
                          svn_stringbuf__morph_into_string(lock_str), pool);
}
开发者ID:dtrebbien,项目名称:subversion,代码行数:33,代码来源:hooks.c


示例8: do_prepare

static void
do_prepare (int argc, char **argv)
{
  temp_fd = create_temp_file ("tst-fallocate.", &temp_filename);
  if (temp_fd == -1)
    FAIL_EXIT1 ("cannot create temporary file: %m");
}
开发者ID:riscv,项目名称:riscv-glibc,代码行数:7,代码来源:tst-fallocate-common.c


示例9: system

/* Creates a list of global tags. Ideally, this should be created once during
 installations so that all users can use the same file. This is because a full
 scale global tag list can occupy several megabytes of disk space.
 @param pre_process The pre-processing command. This is executed via system(),
 so you can pass stuff like 'gcc -E -dD -P `gnome-config --cflags gnome`'.
 @param includes Include files to process. Wildcards such as '/usr/include/a*.h'
 are allowed.
 @param tags_file The file where the tags will be stored.
 @param lang The language to use for the tags file.
 @return TRUE on success, FALSE on failure.
*/
gboolean tm_workspace_create_global_tags(const char *pre_process, const char **includes,
	int includes_count, const char *tags_file, TMParserType lang)
{
	gboolean ret = FALSE;
	TMSourceFile *source_file;
	GList *includes_files;
	gchar *temp_file = create_temp_file("tmp_XXXXXX.cpp");

	if (!temp_file)
		return FALSE;

	includes_files = lookup_includes(includes, includes_count);

#ifdef TM_DEBUG
	g_message ("writing out files to %s\n", temp_file);
#endif
	if (pre_process)
		ret = write_includes_file(temp_file, includes_files);
	else
		ret = combine_include_files(temp_file, includes_files);

	g_list_free_full(includes_files, g_free);
	if (!ret)
		goto cleanup;
	ret = FALSE;

	if (pre_process)
	{
		gchar *temp_file2 = pre_process_file(pre_process, temp_file);

		if (temp_file2)
		{
			g_unlink(temp_file);
			g_free(temp_file);
			temp_file = temp_file2;
		}
		else
			goto cleanup;
	}

	source_file = tm_source_file_new(temp_file, tm_source_file_get_lang_name(lang));
	if (!source_file)
		goto cleanup;
	update_source_file(source_file, NULL, 0, FALSE, FALSE);
	if (source_file->tags_array->len == 0)
	{
		tm_source_file_free(source_file);
		goto cleanup;
	}

	tm_tags_sort(source_file->tags_array, global_tags_sort_attrs, TRUE, FALSE);
	ret = tm_source_file_write_tags_file(tags_file, source_file->tags_array);
	tm_source_file_free(source_file);

cleanup:
	g_unlink(temp_file);
	g_free(temp_file);
	return ret;
}
开发者ID:Fordi,项目名称:geany,代码行数:70,代码来源:tm_workspace.c


示例10: do_prepare

static void
do_prepare (void)
{
  int fd = create_temp_file ("testscript", &fname);
  dprintf (fd, "echo foo\n");
  fchmod (fd, 0700);
  close (fd);
}
开发者ID:Akheon23,项目名称:chromecast-mirrored-source.toolchain,代码行数:8,代码来源:tst-execvp3.c


示例11: do_prepare

static void
do_prepare (void)
{
  char *temp_file;
  temp_fd = create_temp_file ("tst-ttyname_r.", &temp_file);
  if (temp_fd == -1)
    error (1, errno, "cannot create temporary file");
}
开发者ID:AdvancedC,项目名称:glibc,代码行数:8,代码来源:tst-ttyname_r.c


示例12: test_log_ts

void test_log_ts(CuTest* tc) {
    pthread_t t1, t2;
    FILE *f1, *f2;
    char *fn1, *fn2;
    sl* lst;

    log_init(LOG_VERB);
    logmsg("Logging initialized.\n");

    log_set_thread_specific();
    logmsg("Logging set thread specific.\n");

    fn1 = create_temp_file("log", "/tmp");
    fn2 = create_temp_file("log", "/tmp");

    logmsg("File 1 is %s\n", fn1);
    logmsg("File 2 is %s\n", fn2);

    f1 = fopen(fn1, "w");
    f2 = fopen(fn2, "w");

    CuAssertIntEquals(tc, 0, pthread_create(&t1, NULL, thread1, f1));
    CuAssertIntEquals(tc, 0, pthread_create(&t2, NULL, thread2, f2));

    CuAssertIntEquals(tc, 0, pthread_join(t1, NULL));
    CuAssertIntEquals(tc, 0, pthread_join(t2, NULL));

    fclose(f1);
    fclose(f2);

    lst = file_get_lines(fn1, FALSE);
    CuAssertIntEquals(tc, 0, strcmp(sl_get(lst, 0), STRING1A));
    CuAssertIntEquals(tc, 1, sl_size(lst));
    sl_free2(lst);

    lst = file_get_lines(fn2, FALSE);
    CuAssertIntEquals(tc, 0, strcmp(sl_get(lst, 0), STRING2A));
    CuAssertIntEquals(tc, 0, strcmp(sl_get(lst, 1), STRING2B));
    CuAssertIntEquals(tc, 2, sl_size(lst));
    sl_free2(lst);

    unlink(fn1);
    unlink(fn2);
    free(fn1);
    free(fn2);
}
开发者ID:dstndstn,项目名称:astrometry.net,代码行数:46,代码来源:test_log.c


示例13: run_query

static int run_query(const char *query, DYNAMIC_STRING *ds_res,
                     my_bool force)
{
  int ret;
  File fd;
  char query_file_path[FN_REFLEN];
  const uchar sql_log_bin[]= "SET SQL_LOG_BIN=0;";

  DBUG_ENTER("run_query");
  DBUG_PRINT("enter", ("query: %s", query));
  if ((fd= create_temp_file(query_file_path, 
                            opt_tmpdir[0] ? opt_tmpdir : NULL,
                            "sql", O_CREAT | O_SHARE | O_RDWR,
                            MYF(MY_WME))) < 0)
    die("Failed to create temporary file for defaults");

  /*
    Master and slave should be upgraded separately. All statements executed
    by mysql_upgrade will not be binlogged.
    'SET SQL_LOG_BIN=0' is executed before any other statements.
   */
  if (!opt_write_binlog)
  {
    if (my_write(fd, sql_log_bin, sizeof(sql_log_bin)-1,
                 MYF(MY_FNABP | MY_WME)))
    {
      my_close(fd, MYF(0));
      my_delete(query_file_path, MYF(0));
      die("Failed to write to '%s'", query_file_path);
    }
  }

  if (my_write(fd, (uchar*) query, strlen(query),
               MYF(MY_FNABP | MY_WME)))
  {
    my_close(fd, MYF(0));
    my_delete(query_file_path, MYF(0));
    die("Failed to write to '%s'", query_file_path);
  }

  ret= run_tool(mysql_path,
                ds_res,
                "--no-defaults",
                ds_args.str,
                "--database=mysql",
                "--batch", /* Turns off pager etc. */
                force ? "--force": "--skip-force",
                ds_res || opt_silent ? "--silent": "",
                "<",
                query_file_path,
                "2>&1",
                NULL);

  my_close(fd, MYF(0));
  my_delete(query_file_path, MYF(0));

  DBUG_RETURN(ret);
}
开发者ID:janlindstrom,项目名称:mariadb-10.0,代码行数:58,代码来源:mysql_upgrade.c


示例14: do_prepare

static void
do_prepare (void)
{
  if (create_temp_file ("tst-getopt_long1", &fname) < 0)
    {
      printf ("cannot create temp file: %m\n");
      exit (1);
    }
}
开发者ID:bminor,项目名称:glibc,代码行数:9,代码来源:tst-getopt_long1.c


示例15: do_test

static int
do_test (void)
{
  if (setlocale (LC_ALL, "ja_JP.UTF-8") == NULL)
    {
      printf ("Cannot set ja_JP.UTF-8 locale.\n");
      exit (1);
    }

  /* Retain messages in English.  */
  if (setlocale (LC_MESSAGES, "en_US.ISO-8859-1") == NULL)
    {
      printf ("Cannot set LC_MESSAGES to en_US.ISO-8859-1 locale.\n");
      exit (1);
    }

  int ret = 0;
  char *filename;
  int fd = create_temp_file ("tst-fseek.out", &filename);

  if (fd == -1)
    return 1;

  FILE *fp = fdopen (fd, "w+");
  if (fp == NULL)
    {
      printf ("seek_set: fopen: %s\n", strerror (errno));
      close (fd);
      return 1;
    }

  if (do_seek_set (fp))
    {
      printf ("SEEK_SET test failed\n");
      ret = 1;
    }

  /* Reopen the file.  */
  fclose (fp);
  fp = fopen (filename, "w+");
  if (fp == NULL)
    {
      printf ("seek_end: fopen: %s\n", strerror (errno));
      return 1;
    }

  if (do_seek_end (fp))
    {
      printf ("SEEK_END test failed\n");
      ret = 1;
    }

  fclose (fp);

  return ret;
}
开发者ID:bminor,项目名称:glibc,代码行数:56,代码来源:tst-fseek.c


示例16: do_prepare

static void
do_prepare (void)
{
  fd = create_temp_file ("tst-unlockedio.", NULL);
  if (fd == -1)
    {
      printf ("cannot create temporary file: %m\n");
      exit (1);
    }
}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:10,代码来源:tst-unlockedio.c


示例17: do_prepare

static void
do_prepare (void)
{
  temp_fd = create_temp_file ("tst-trucate.", &temp_filename);
  if (temp_fd == -1)
    {
      printf ("cannot create temporary file: %m\n");
      exit (1);
    }
}
开发者ID:bminor,项目名称:glibc,代码行数:10,代码来源:tst-truncate-common.c


示例18: ext_array_create

/* Creates and returns a new external array. */
struct ext_array *
ext_array_create (void)
{
  struct ext_array *ea = xmalloc (sizeof *ea);
  ea->file = create_temp_file ();
  if (ea->file == NULL)
    error (0, errno, _("failed to create temporary file"));
  ea->position = 0;
  return ea;
}
开发者ID:RobertDash,项目名称:pspp,代码行数:11,代码来源:ext-array.c


示例19: create_temp_file

static gchar *pre_process_file(const gchar *cmd, const gchar *inf)
{
	gint ret;
	gchar *outf = create_temp_file("tmp_XXXXXX.cpp");
	gchar *tmp_errfile;
	gchar *errors = NULL;
	gchar *command;

	if (!outf)
		return NULL;

	tmp_errfile = create_temp_file("tmp_XXXXXX");
	if (!tmp_errfile)
	{
		g_unlink(outf);
		g_free(outf);
		return NULL;
	}

	command = g_strdup_printf("%s %s >%s 2>%s",
		cmd, inf, outf, tmp_errfile);
#ifdef TM_DEBUG
	g_message("Executing: %s", command);
#endif
	ret = system(command);
	g_free(command);

	g_file_get_contents(tmp_errfile, &errors, NULL, NULL);
	if (errors && *errors)
		g_printerr("%s", errors);
	g_free(errors);
	g_unlink(tmp_errfile);
	g_free(tmp_errfile);

	if (ret == -1)
	{
		g_unlink(outf);
		g_free(outf);
		return NULL;
	}

	return outf;
}
开发者ID:Fordi,项目名称:geany,代码行数:43,代码来源:tm_workspace.c


示例20: prepare

static void
prepare (void)
{
  fd = create_temp_file ("tst-fwrite.", NULL);
  if (fd == -1)
    {
      puts ("cannot create temporary file");
      exit (1);
    }
}
开发者ID:Akheon23,项目名称:chromecast-mirrored-source.toolchain,代码行数:10,代码来源:tst-fwrite.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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