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

C++ delete_file函数代码示例

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

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



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

示例1: next_valid

flist *
next_valid(Window *win, flist *file, int c)
{
    flist *ftmp = file;
    int fix_selected = 0;
    if (!file)
        return file;
    if (file->flags & F_SELECTED)
        fix_selected = 1;
    switch (c) {
    case KEY_HOME:
    case KEY_DOWN:
    case KEY_NPAGE:
        while (!check_file(file))
            file = delete_file(win, file);
        break;
    case KEY_END:
    case KEY_UP:
    case KEY_PPAGE:
        while (!check_file(file)) {
            ftmp = file->prev;
            delete_file(win, file);
            file = ftmp;
        }
        break;
    }
    if (fix_selected) {
        win->contents.list->selected = file;
        file->flags |= F_SELECTED;
    }
    return file;
}
开发者ID:stefanlenselink,项目名称:mms,代码行数:32,代码来源:files.c


示例2: TEST

TEST(LogFileOutput, startup_truncation) {
  const char* filename = "start-truncate-test";
  const char* archived_filename = "start-truncate-test.0";

  delete_file(filename);
  delete_file(archived_filename);

  // Use the same log file twice and expect it to be overwritten/truncated
  init_log_file(filename, "filecount=0");
  ASSERT_TRUE(file_exists(filename))
    << "configured logging to file '" << filename << "' but file was not found";

  init_log_file(filename, "filecount=0");
  ASSERT_TRUE(file_exists(filename))
    << "configured logging to file '" << filename << "' but file was not found";
  EXPECT_FALSE(file_exists(archived_filename))
    << "existing log file was not properly truncated when filecount was 0";

  // Verify that the file was really truncated and not just appended
  EXPECT_TRUE(file_contains_substring(filename, LOG_TEST_STRING_LITERAL));
  const char* repeated[] = { LOG_TEST_STRING_LITERAL, LOG_TEST_STRING_LITERAL };
  EXPECT_FALSE(file_contains_substrings_in_order(filename, repeated))
    << "log file " << filename << " appended rather than truncated";

  delete_file(filename);
  delete_file(archived_filename);
}
开发者ID:netroby,项目名称:jdk9-dev,代码行数:27,代码来源:test_logFileOutput.cpp


示例3: deletefiles_in_dir

static void deletefiles_in_dir( const char* dirpath, dev_t device, time_t timestamp )
{
  DIR *dirp = opendir(dirpath);
  struct dirent *dp;

  if (dirp==NULL) {
    rotter_fatal( "Failed to open directory: %s.", dirpath );
    return;
  }

  // Check we are on the same device
  if (get_file_device(dirpath) != device) {
    rotter_debug( "Warning: %s isn't on same device as root dir.", dirpath );
    closedir( dirp );
    return;
  }

  // Check each item in the directory
  while( (dp = readdir( dirp )) != NULL ) {
    int newpath_len;
    char* newpath;

    if (strcmp( ".", dp->d_name )==0) continue;
    if (strcmp( "..", dp->d_name )==0) continue;


    newpath_len = strlen(dirpath) + strlen(dp->d_name) + 2;
    newpath = malloc( newpath_len );
    snprintf( newpath, newpath_len, "%s/%s", dirpath, dp->d_name );

    if (dp->d_type == DT_DIR) {

      // Process sub directory
      deletefiles_in_dir( newpath, device, timestamp );
      delete_file( newpath, device, timestamp );

    } else if (dp->d_type == DT_REG) {

      delete_file( newpath, device, timestamp );

    } else {
      rotter_error( "Warning: not a file or a directory: %s" );
    }
    free( newpath );

  }

  closedir( dirp );
}
开发者ID:ian-llewellyn,项目名称:rotter,代码行数:49,代码来源:deletefiles.c


示例4: do_rm

static int
do_rm(void)
{
    int ret = -1;
    char name[MAX_FILE_NAME_LENGTH + 1];
    char *path;
    struct file *file;

    if (read_all(STDIN, name, MAX_FILE_NAME_LENGTH) != MAX_FILE_NAME_LENGTH)
        return -1;
    name[MAX_FILE_NAME_LENGTH] = '\0';

    if ((path = get_path_from_dir(&vfs, pwd)) == NULL)
        return -1;

    if ((path = append_to_path(path, name)) == NULL)
        goto free_path;

    if ((file = lookup_file(&vfs, path, 1)) == NULL)
        goto free_path;

    if (delete_file(&vfs, USER_UID, file) != 0)
        goto free_path;

    ret = 0;

free_path:
    free(path);
    return ret;
}
开发者ID:trailofbits,项目名称:cb-multios,代码行数:30,代码来源:service.c


示例5: list_files_in_directory

void IPC::clear()
{
	vector<string> file_name_vec = list_files_in_directory(ipc_path);
	for (string file_name_current : file_name_vec)
	{
		string file_name_everyone = "";
		if (file_name_current.size() >= 8)
			file_name_everyone = file_name_current.substr(0, 8);

		if (file_name_current.size() > self_name.size() || file_name_everyone == "everyone")
		{
			string file_name = "";
			string file_name_id_str = "";
			if (file_name_everyone != "everyone")
			{
				file_name = file_name_current.substr(0, self_name.size());
				file_name_id_str = file_name_current.substr(self_name.size(), file_name_current.size());
			}
			else
				continue;

			if (file_name == self_name || file_name_everyone == "everyone")
				delete_file(ipc_path + slash + file_name_current);
		}
	}
}
开发者ID:bstramsek,项目名称:touch_plus_source_code,代码行数:26,代码来源:ipc.cpp


示例6: main

int main (int argc, char ** argv)
{
  
  open_FS();
  
  printf ("\nREPETOIRE AVANT :\n");
  list_dir ();
  printf ("FAT AVANT : ");
  list_fat ();
  
  printf ("\nEFFACER %s \n", argv[1]);
  if (delete_file (argv[1]) )
    printf ("%s n'existe pas \n", argv[1]);
  else
    { 
      printf ("\nREPETOIRE APRES :\n");
      list_dir ();
      printf ("FAT APRES : ");
      list_fat ();
    }
  
  close_FS ();

  return EXIT_SUCCESS;  
}
开发者ID:Masshat,项目名称:Systeme-LI324,代码行数:25,代码来源:test_del_file.c


示例7: replay_create_files

void replay_create_files(exe_file_system_t *exe_fs) {
  char tmpdir[PATH_MAX];
  unsigned k;

  if (!getcwd(tmpdir, PATH_MAX)) {
    perror("getcwd");
    exit(1);
  }

  strcat(tmpdir, ".temps");
  delete_file(tmpdir, 1);
  mkdir(tmpdir, 0755);  
  
  umask(0);
  for (k=0; k < exe_fs->n_sym_files; k++) {
    char name[2];
    sprintf(name, "%c", 'A' + k);
    create_file(-1, name, &exe_fs->sym_files[k], tmpdir);
  }

  if (exe_fs->sym_stdin)
    create_file(0, NULL, exe_fs->sym_stdin, tmpdir);

  if (exe_fs->sym_stdout)
    create_file(1, NULL, exe_fs->sym_stdout, tmpdir);

  if (exe_fs->sym_stdin)
    check_file(__STDIN, exe_fs->sym_stdin);

  if (exe_fs->sym_stdout)
    check_file(__STDOUT, exe_fs->sym_stdout);
  
  for (k=0; k<exe_fs->n_sym_files; ++k)
    check_file(k, &exe_fs->sym_files[k]);
}
开发者ID:Icefroge,项目名称:cloud9,代码行数:35,代码来源:file-creator.c


示例8: delete_file

void FeRomList::delete_emulator( const std::string & emu )
{
	//
	// Delete file
	//
	std::string path = m_config_path;
	path += FE_EMULATOR_SUBDIR;
	path += emu;
	path += FE_EMULATOR_FILE_EXTENSION;

	delete_file( path );

	//
	// Delete from our list if it has been loaded
	//
	for ( std::vector<FeEmulatorInfo>::iterator ite=m_emulators.begin();
			ite != m_emulators.end(); ++ite )
	{
		if ( emu.compare( (*ite).get_info( FeEmulatorInfo::Name ) ) == 0 )
		{
			m_emulators.erase( ite );
			break;
		}
	}
}
开发者ID:Cucurbitace,项目名称:attract,代码行数:25,代码来源:fe_romlist.cpp


示例9: delete_status_bucket

static void delete_status_bucket(struct cloudmig_ctx *ctx)
{
    dpl_status_t    dplret;
    dpl_vec_t       *objects = NULL;

    cloudmig_log(DEBUG_LVL, "[Deleting files]: Deleting status bucket...\n");

    dplret = dpl_list_bucket(ctx->src_ctx, ctx->status.bucket_name,
                             NULL, NULL, &objects, NULL);
    if (dplret != DPL_SUCCESS)
    {
        PRINTERR("%s: Could not list bucket %s for deletion : %s\n",
                 __FUNCTION__, ctx->status.bucket_name, dpl_status_str(dplret));
        goto deletebucket;
    }

    dpl_object_t** cur_object = (dpl_object_t**)objects->array;
    for (int i = 0; i < objects->n_items; ++i, ++cur_object)
        delete_file(ctx, ctx->status.bucket_name, (*cur_object)->key);

deletebucket:
    dpl_deletebucket(ctx->src_ctx, ctx->status.bucket_name);
    if (dplret != DPL_SUCCESS)
    {
        PRINTERR("%s: Could not delete bucket %s : %s.\n",
                 __FUNCTION__, ctx->status.bucket_name, dpl_status_str(dplret));
        return ;
    }
    cloudmig_log(DEBUG_LVL, "[Deleting Source] Bucket %s deleted.\n",
                 ctx->status.bucket_name);
}
开发者ID:hojo,项目名称:Scality-Cloud-Migration-Tool,代码行数:31,代码来源:delete_files.c


示例10: simple_concurrency

TEST simple_concurrency() {
	delete_file();
	rliteContext *context1 = rliteConnect(FILEPATH, 0);
	rliteContext *context2 = rliteConnect(FILEPATH, 0);

	rliteReply* reply;
	size_t argvlen[100];

	{
		char* argv[100] = {"GET", "key", NULL};
		reply = rliteCommandArgv(context1, populateArgvlen(argv, argvlen), argv, argvlen);
		EXPECT_REPLY_NIL(reply);
		rliteFreeReplyObject(reply);
	}

	{
		char* argv[100] = {"set", "key", "value", NULL};
		reply = rliteCommandArgv(context2, populateArgvlen(argv, argvlen), argv, argvlen);
		EXPECT_REPLY_STATUS(reply, "OK", 2);
		rliteFreeReplyObject(reply);
	}
	{
		char* argv[100] = {"GET", "key", NULL};
		reply = rliteCommandArgv(context1, populateArgvlen(argv, argvlen), argv, argvlen);
		EXPECT_REPLY_STR(reply, "value", 5);
		rliteFreeReplyObject(reply);
	}

	rliteFree(context1);
	rliteFree(context2);
	unlink(FILEPATH);
	PASS();
}
开发者ID:jplevyak,项目名称:rlite,代码行数:33,代码来源:concurrency-test.c


示例11: test_oss_media_hls_ossfile_handler_succeeded

void test_oss_media_hls_ossfile_handler_succeeded(CuTest *tc) {
    int ret;
    int64_t length;
    oss_media_hls_file_t *file;
    char *key = "test.txt";
    char *content = "hangzhou";

    file = oss_media_hls_open(TEST_BUCKET_NAME, key, auth_func);
    CuAssertTrue(tc, file != NULL);
    
    memcpy(&file->buffer->buf[file->buffer->pos], content, strlen(content));
    file->buffer->pos += strlen(content);

    CuAssertTrue(tc, file->buffer->pos != file->buffer->start);

    ret = oss_media_hls_ossfile_handler(file);
    CuAssertIntEquals(tc, 0, ret);

    CuAssertTrue(tc, file->buffer->pos == file->buffer->start);

    oss_media_hls_close(file);

    oss_media_file_t* read_file = oss_media_file_open(TEST_BUCKET_NAME, 
            key, "r", auth_func);
    CuAssertTrue(tc, read_file != NULL);

    uint8_t *buffer = (uint8_t*)malloc(strlen(content));
    length = oss_media_file_read(read_file, buffer, strlen(content));
    CuAssertIntEquals(tc, strlen(content), length);
    CuAssertStrnEquals(tc, content, strlen(content), (char*)buffer);

    free(buffer);
    delete_file(read_file);
    oss_media_file_close(read_file);
}
开发者ID:HansonLu,项目名称:aliyun-media-c-sdk,代码行数:35,代码来源:test_hls.c


示例12: tagfs_getattr

/*
 * Get file attributes.
 *
 * Similar to stat(). The 'st_dev' and 'st_blksize' fields are ignored. The
 * 'st_ino' field is ignored except if the 'use_ino' mount option is given.
 */
int tagfs_getattr(const char *path, struct stat *statbuf) {
	char *file_location = NULL;
	int file_id = 0;
	int retstat = 0;

	DEBUG(ENTRY);
	INFO("Retrieving attributes for %s", path);

	if (valid_path_to_file(path)) {
		file_id = file_id_from_path(path);
		file_location = get_file_location(file_id);

		/* read information from actual file */
		retstat = stat(file_location, statbuf);

		if(retstat < 0) {
			WARN("Reading information from file %s failed", file_location);
			delete_file(file_id);
		}

		free_single_ptr((void **)&file_location);
	}
	else if(valid_path_to_folder(path)) {
		statbuf->st_mode = S_IFDIR | 0755; /* TODO: Set hard links, etc. */
	}
	else {
		retstat = -ENOENT;
	}

	DEBUG(EXIT);
	return retstat;
} /* tagfs_getattr */
开发者ID:williamwoelke,项目名称:TagFS,代码行数:38,代码来源:tagfs.c


示例13: pending_operation_apply

void pending_operation_apply (struct pending_operation *P) {
  char full_oldpath[PATH_MAX], full_newpath[PATH_MAX];
  full_oldpath[0] = full_newpath[0] = 0;
  if (P->oldpath) {
    assert (snprintf (full_oldpath, PATH_MAX, "%s/%s", po_olddir, P->oldpath) < PATH_MAX);
  }
  if (P->newpath) {
    assert (snprintf (full_newpath, PATH_MAX, "%s/%s", po_newdir, P->newpath) < PATH_MAX);
  }
  switch (P->type) {
    case pot_null:
      kprintf ("pending_operation_apply (P.type == pot_null)\n");
      exit (1);
      break;
    case pot_mkdir:
      PO_ASSERT (mkdir (full_newpath, P->st.st_mode));
      PO_ASSERT (lcopy_attrs (full_newpath, &P->st));
      break;
    case pot_symlink:
      PO_ASSERT (symlink (P->oldpath, full_newpath));
      PO_ASSERT (lcopy_attrs (full_newpath, &P->st));
      break;
    case pot_rename:
      PO_ASSERT (rename (full_oldpath, full_newpath));
      PO_ASSERT (lcopy_attrs (full_newpath, &P->st));
      break;
    case pot_remove:
      PO_ASSERT (delete_file (full_newpath));
      break;
    case pot_copy_attrs:
      PO_ASSERT (lcopy_attrs (full_newpath, &P->st));
      break;
  }
}
开发者ID:AbramovVitaliy,项目名称:kphp-kdb,代码行数:34,代码来源:filesys-pending-operations.c


示例14: START_TEST

} END_TEST

START_TEST(test_read_str) {
  // It should be ok
  char normal[] = "ab";
  wzfile file;
  create_file(&file, normal, strlen(normal));
  wzstr buffer;
  wz_init_str(&buffer);
  ck_assert_int_eq(wz_read_str(&buffer, strlen(normal), &file), 0);
  ck_assert_int_eq(memcmp(buffer.bytes, normal, strlen(normal)), 0);
  ck_assert(buffer.len == strlen(normal));
  ck_assert(memused() == sizeof(normal));

  // It should not change data if position + len > size
  wzstr copy = buffer;
  ck_assert_int_eq(wz_read_str(&buffer, strlen(normal), &file), 1);
  ck_assert(buffer.bytes == copy.bytes);
  ck_assert(buffer.len == copy.len);

  // It should not allocate memory if position + len > size
  ck_assert(memused() == sizeof(normal));
  wz_free_str(&buffer);
  delete_file(&file);
} END_TEST
开发者ID:xsoameix,项目名称:wz,代码行数:25,代码来源:file.c


示例15: main

int
main(int argc, char **argv)
{
    /*int i;*/
    char db_dir[256];           /* the directory where the db file is */
    char dbfilename[256];       /* the database filename */
    char *filenames[1000];      /* the files to be added */
    char **fnames = filenames;
    short flag;                 /* flag for deleting or adding */

    parse_args(argv, db_dir, filenames, &flag);

    if (!filenames[0]) {
        fprintf(stderr, "%s\n", usage);
        return -1;
    }

    parser_init();

    build_db_filename(flag, db_dir, dbfilename);

    if (fresh)
        unlink(dbfilename);

    if (flag & Delete)
        while (*fnames)
            delete_file(dbfilename, *fnames++);
    else
        while (*fnames)
            add_file(dbfilename, *fnames++, fresh);
    return 0;
}
开发者ID:acralfs,项目名称:fricas,代码行数:32,代码来源:htadd.c


示例16: main

int main () {
  contenu txt;
    fifo * pf = creer_fifo () ;
    for (; ; ) {
          printf (" Ajouter un texte a la file (! pour retirer , * pour finir ) : ") ;
          saisir_contenu (& txt ) ;
          if ( comparer_chaine (& txt , "*") == 0)
               break ;
          if ( comparer_chaine (& txt , "!") == 0) {
               if ( est_vide_file ( pf ) ) {
                  printf (" Retrait imposible . File vide ") ;
               }
             else {
                 defiler_file ( pf , & txt ) ;
               }
               afficher_file ( pf ) ;
               printf ("\n ") ;
        }
          else {
            enfiler_file ( pf , & txt ) ;
               afficher_file ( pf ) ;
               printf ("\n ") ;
          }
    }

    delete_file ( pf ) ;
    getchar () ;
    return 0;
}
开发者ID:tiregram,项目名称:esiee_e3_c_structure,代码行数:29,代码来源:exo2.c


示例17: threads_concurrency

TEST threads_concurrency() {
	delete_file();
	rliteContext *context = rliteConnect(FILEPATH, 0);

	pthread_t thread;
	pthread_create(&thread, NULL, increment, NULL);

	rliteReply* reply;
	size_t argvlen[100];
	char* argv[100] = {"GET", "key", NULL};
	int argc = populateArgvlen(argv, argvlen);
	long long val;
	char tmp[40];

	do {
		reply = rliteCommandArgv(context, argc, argv, argvlen);
		if (reply->type == RLITE_REPLY_NIL) {
			val = 0;
		} else  if (reply->type != RLITE_REPLY_STRING) {
			fprintf(stderr, "Expected incremented value to be a string, got %d instead on line %d\n", reply->type, __LINE__);
			rliteFreeReplyObject(reply);
			break;
		} else {
			memcpy(tmp, reply->str, reply->len);
			tmp[reply->len] = 0;
			val = strtoll(tmp, NULL, 10);
		}
		rliteFreeReplyObject(reply);
	} while (val < INCREMENT_LIMIT);

	rliteFree(context);
	pthread_join(thread, NULL);
	PASS();
}
开发者ID:jplevyak,项目名称:rlite,代码行数:34,代码来源:concurrency-test.c


示例18: start_recording

/* Note that we _must_ set the header information before we start recording!! */
void start_recording(
	void)
{
	FileDesc recording_file;
	long count;
	FileError error;
	
	assert(!replay.valid);
	replay.valid= TRUE;
	
	if(get_recording_filedesc(&recording_file))
	{
		delete_file(&recording_file);
	}

	error= create_file(&recording_file, FILM_FILE_TYPE);	
	if(!error)
	{
		/* I debate the validity of fsCurPerm here, but Alain had it, and it has been working */
		replay.recording_file_refnum= open_file_for_writing(&recording_file);
		if(replay.recording_file_refnum != NONE)
		{
			replay.game_is_being_recorded= TRUE;
	
			// save a header containing information about the game.
			count= sizeof(struct recording_header); 
			write_file(replay.recording_file_refnum, count, &replay.header);
		}
	}
}
开发者ID:DrItanium,项目名称:moo,代码行数:31,代码来源:vbl.c


示例19: delete_dir

static int delete_dir(const char *path, int recurse) {
  if (recurse) {
    DIR *d = opendir(path);
    struct dirent *de;

    if (d) {
      while ((de = readdir(d))) {
        if (strcmp(de->d_name, ".")!=0 && strcmp(de->d_name, "..")!=0) {
          char tmp[PATH_MAX];
          sprintf(tmp, "%s/%s", path, de->d_name);
          delete_file(tmp, 0);
        }
      }

      closedir(d);
    }
  }
 
  if (rmdir(path) == -1) {
    fprintf(stderr, "Cannot create file %s (exists, is dir, can't remove)\n", path);
    perror("rmdir");
    return -1;
  }

  return 0;
}
开发者ID:Icefroge,项目名称:cloud9,代码行数:26,代码来源:file-creator.c


示例20: test_read_file_succeeded

void test_read_file_succeeded(CuTest *tc) {
    int64_t write_size = 0;
    oss_media_file_t *file = NULL;
    char *write_content = NULL;
    char *read_content = NULL;
    int ntotal, nread, nbuf = 4;
    char buf[4];
    
    write_content = "hello oss media file\n";
    write_size = write_file(write_content);
    CuAssertTrue(tc, write_size != -1);

    // open file for read
    file = oss_media_file_open(TEST_BUCKET_NAME, "oss_media_file", "r", auth_func);
    CuAssertTrue(tc, NULL != file);

    // read file
    read_content = malloc(write_size + 1);
    ntotal = 0;
    while ((nread = oss_media_file_read(file, buf, nbuf)) > 0) {
        memcpy(read_content + ntotal, buf, nread);
        ntotal += nread;
    }
    read_content[ntotal] = '\0';    

    CuAssertIntEquals(tc, ntotal, strlen(read_content));
    CuAssertStrEquals(tc, write_content, read_content);

    // close file
    free(read_content);
    delete_file(file);
    oss_media_file_close(file);
}
开发者ID:HansonLu,项目名称:aliyun-media-c-sdk,代码行数:33,代码来源:test_client.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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