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


C++ delete_file函数代码示例

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


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

示例5: 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

示例6: 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

示例7: 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

示例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


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