本文整理汇总了C++中remove_file函数的典型用法代码示例。如果您正苦于以下问题:C++ remove_file函数的具体用法?C++ remove_file怎么用?C++ remove_file使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了remove_file函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: wipe_save_dir
static int wipe_save_dir(const char *dir)
{
void **list;
int i, count, ret = 0;
if ((list = list_save_dir(dir, &count)) == NULL)
return 0;
for (i = 0; i < count; i++)
ret |= remove_file(dir, list[i]);
FS_FreeList(list);
return ret;
}
开发者ID:jdolan,项目名称:q2pro,代码行数:14,代码来源:save.c
示例2: it_reload_image
bool it_reload_image(arg_t a) {
if (mode == MODE_IMAGE) {
load_image(fileidx);
} else {
win_set_cursor(&win, CURSOR_WATCH);
if (!tns_load(&tns, tns.sel, &files[tns.sel], true, false)) {
remove_file(tns.sel, false);
tns.dirty = true;
if (tns.sel >= tns.cnt)
tns.sel = tns.cnt - 1;
}
}
return true;
}
开发者ID:kurt-vd,项目名称:sxiv,代码行数:14,代码来源:commands.c
示例3: rm
/**
* @brief 执行rm命令
* @details 删除指定文件
* @param[in] remove_paths 需要删除的文件的路径
* @param[in] recursive 是否递归删除
* @param[in] force 是否强行删除只读文件
* @return 成功返回true,失败返回false
*/
bool rm( const char * const * const remove_paths, bool recursive, bool force )
{
char absolute_path[MAX_PATH];
const char * const * p = NULL;
assert(remove_paths != NULL);
for ( p = remove_paths; (*p) != NULL; ++ p )
{
get_absolute_path(absolute_path, *p);
if ( !remove_file(absolute_path) )
fprintf(stderr, "rm: cannot remove ‘%s’: No such file or directory\n", (*p));
}
return true;
}
开发者ID:freshpassport,项目名称:hnust_2012_operating_system_course_design,代码行数:22,代码来源:deal_command.c
示例4: remove_files
void remove_files() {
remove_file(DATA_IN, 1);
remove_file(DATA_OUT, 1);
remove_file(RE_OUT, 1);
remove_file(CE_OUT, 1);
remove_file(USER_CODE, 1);
remove_file(COMPILED_FILE, 1);
return;
}
开发者ID:guo-shaoge,项目名称:flask_learnC,代码行数:9,代码来源:main.c
示例5: init_remove_files
void init_remove_files() {
remove_file(DATA_IN, 0);
remove_file(DATA_OUT, 0);
remove_file(RE_OUT, 0);
remove_file(CE_OUT, 0);
remove_file(USER_CODE, 0);
remove_file(COMPILED_FILE, 0);
return;
}
开发者ID:guo-shaoge,项目名称:flask_learnC,代码行数:9,代码来源:main.c
示例6: remove_other_catfiles
static void
remove_other_catfiles (const char *catfile) {
char *pathname;
char *t;
char **gf;
int offset;
pathname = my_strdup(catfile);
t = rindex(pathname, '.');
if (t == NULL || strcmp(t, getval("COMPRESS_EXT")))
return;
offset = t - pathname;
strcpy(t, "*");
gf = glob_filename (pathname);
if (gf != (char **) -1 && gf != NULL) {
for ( ; *gf; gf++) {
/*
* Only remove files with a known extension, like .Z
* (otherwise we might kill a lot when called with
* catfile = ".gz" ...)
*/
if (strlen (*gf) <= offset) {
if (strlen (*gf) == offset) /* uncompressed version */
remove_file (*gf);
continue;
}
if (!strcmp (*gf + offset, getval("COMPRESS_EXT")))
continue;
if (get_expander (*gf) != NULL)
remove_file (*gf);
}
}
}
开发者ID:haggaie,项目名称:man,代码行数:36,代码来源:man.c
示例7: remove_device_files
static int remove_device_files(struct super_block *sb,
struct qib_devdata *dd)
{
struct dentry *dir, *root;
char unit[10];
int ret, i;
root = dget(sb->s_root);
mutex_lock(&root->d_inode->i_mutex);
snprintf(unit, sizeof unit, "%u", dd->unit);
dir = lookup_one_len(unit, root, strlen(unit));
if (IS_ERR(dir)) {
ret = PTR_ERR(dir);
printk(KERN_ERR "Lookup of %s failed\n", unit);
goto bail;
}
remove_file(dir, "counters");
remove_file(dir, "counter_names");
remove_file(dir, "portcounter_names");
for (i = 0; i < dd->num_pports; i++) {
char portcntr[24];
sprintf(portcntr, "port%dcounters", i + 1);
remove_file(dir, portcntr);
}
remove_file(dir, "flash");
d_delete(dir);
ret = simple_rmdir(root->d_inode, dir);
bail:
mutex_unlock(&root->d_inode->i_mutex);
dput(root);
return ret;
}
开发者ID:01org,项目名称:qib,代码行数:36,代码来源:qib_fs.c
示例8: remove_directory
ErrnoError remove_directory(const std::string& path, bool is_recursive) {
if (path.empty()) {
return make_error_perror("remove_directory", EINVAL);
}
std::string pr_path = prepare_path(path);
if (pr_path[pr_path.length() - 1] == get_separator<char>()) {
pr_path[pr_path.length() - 1] = 0;
}
const char* pr_path_ptr = pr_path.c_str();
if (is_recursive) {
DIR* dirp = opendir(pr_path_ptr);
if (!dirp) {
return ErrnoError();
}
struct dirent* p;
while ((p = readdir(dirp)) != nullptr) {
/* Skip the names "." and ".." as we don't want to recurse on them. */
if (!strcmp(p->d_name, ".") || !strcmp(p->d_name, "..")) {
continue;
}
char pathBuffer[PATH_MAX] = {0};
SNPrintf(pathBuffer, sizeof(pathBuffer), "%s/%s", path, p->d_name);
struct stat statbuf;
if (!::stat(pathBuffer, &statbuf)) {
if (S_ISDIR(statbuf.st_mode)) {
ErrnoError err = remove_directory(pathBuffer, is_recursive);
if (err) {
closedir(dirp);
return err;
}
} else {
ErrnoError err = remove_file(pathBuffer);
if (err) {
closedir(dirp);
return err;
}
}
}
}
closedir(dirp);
}
return do_rmdir_directory(pr_path_ptr);
}
开发者ID:fastogt,项目名称:common,代码行数:48,代码来源:file_system.cpp
示例9: fileaction_dobackup
void fileaction_dobackup(char *filename, int fileref)
{
struct stat oldfile;
int stat_res;
char *newname;
if (rpm_getint(RPMTAG_FILEFLAGS, fileref) & RPMFILE_CONFIG) { /* Only need to backup config files */
stat_res = lstat (filename, &oldfile);
if (stat_res == 0 && S_ISREG(oldfile.st_mode)) { /* File already exists - really should check MD5's etc to see if different */
newname = bb_xstrdup(filename);
newname = strcat(newname, ".rpmorig");
copy_file(filename, newname, FILEUTILS_RECUR | FILEUTILS_PRESERVE_STATUS);
remove_file(filename, FILEUTILS_RECUR | FILEUTILS_FORCE);
free(newname);
}
}
}
开发者ID:blueprintmrk,项目名称:stablebox,代码行数:16,代码来源:rpm.c
示例10: conflict_rename_rename_2
static void conflict_rename_rename_2(struct rename *ren1,
const char *branch1,
struct rename *ren2,
const char *branch2)
{
char *new_path1 = unique_path(ren1->pair->two->path, branch1);
char *new_path2 = unique_path(ren2->pair->two->path, branch2);
output(1, "Renamed %s to %s and %s to %s instead",
ren1->pair->one->path, new_path1,
ren2->pair->one->path, new_path2);
remove_file(0, ren1->pair->two->path, 0);
update_file(0, ren1->pair->two->sha1, ren1->pair->two->mode, new_path1);
update_file(0, ren2->pair->two->sha1, ren2->pair->two->mode, new_path2);
free(new_path2);
free(new_path1);
}
开发者ID:Pistos,项目名称:git,代码行数:16,代码来源:builtin-merge-recursive.c
示例11: CPPUNIT_ASSERT_MESSAGE
void FilesystemTest::testFile() {
#ifdef _WIN32
const string test_file = test_dir->Path() + "\\test-file.txt";
#else
const string test_file = test_dir->Path() + "/test-file";
#endif
CPPUNIT_ASSERT_MESSAGE(
"inexistant file is file",
!is_file(test_file));
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"mtime of inexistant file should be zero",
time_t(0), file_mtime(test_file));
CPPUNIT_ASSERT_MESSAGE(
"inexistant file is a directory",
!is_dir(test_file));
{ // create file
ofstream file(test_file);
file << "hello" << endl;
}
time_t now = time(nullptr);
CPPUNIT_ASSERT_MESSAGE(
"existing file not a file",
is_file(test_file));
CPPUNIT_ASSERT_MESSAGE(
"mtime of existing file should be somewhere around now",
// let's assume that creating the file takes less than five seconds
abs(now - file_mtime(test_file) < 5));
CPPUNIT_ASSERT_MESSAGE(
"regular file is a directory",
!is_dir(test_file));
CPPUNIT_ASSERT_MESSAGE(
"failed to remove test file",
remove_file(test_file));
CPPUNIT_ASSERT_MESSAGE(
"removed file is still a file",
!is_file(test_file));
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"mtime of removed file should be zero",
time_t(0), file_mtime(test_file));
CPPUNIT_ASSERT_MESSAGE(
"removed file became a directory",
!is_dir(test_file));
}
开发者ID:HolySmoke86,项目名称:blank,代码行数:47,代码来源:FilesystemTest.cpp
示例12: test_remove_middle
void test_remove_middle(void)
{
FILENODE *node[5];
FILENODE *current_node;
GtkTreeIter iter;
int i = 0;
init_file_list();
node[0] = append_file("file1", "schema", "table", "geom_column", "-1", 'c', &iter);
CU_ASSERT_PTR_NOT_NULL(node[0]);
node[1] = append_file("file2", "schema", "table", "geom_column", "-1", 'c', &iter);
CU_ASSERT_PTR_NOT_NULL(node[1]);
node[2] = append_file("file3", "schema", "table", "geom_column", "-1", 'c', &iter);
CU_ASSERT_PTR_NOT_NULL(node[2]);
node[3] = append_file("file4", "schema", "table", "geom_column", "-1", 'c', &iter);
CU_ASSERT_PTR_NOT_NULL(node[3]);
node[4] = append_file("file5", "schema", "table", "geom_column", "-1", 'c', &iter);
CU_ASSERT_PTR_NOT_NULL(node[4]);
current_node = get_next_node(NULL);
CU_ASSERT_PTR_NOT_NULL(current_node);
while (current_node != NULL)
{
CU_ASSERT_NOT_EQUAL(i, 5);
CU_ASSERT_PTR_EQUAL(current_node, node[i]);
current_node = get_next_node(current_node);
i++;
}
remove_file(node[3]);
i = 0;
current_node = get_next_node(NULL);
CU_ASSERT_PTR_NOT_NULL(current_node);
while (current_node != NULL)
{
CU_ASSERT_NOT_EQUAL(i, 5);
CU_ASSERT_PTR_EQUAL(current_node, node[i]);
current_node = get_next_node(current_node);
i++;
if (i == 3)
i++;
}
CU_ASSERT_EQUAL(i, 5);
destroy_file_list();
}
开发者ID:bnordgren,项目名称:postgis,代码行数:47,代码来源:cu_list.c
示例13: it_shell_cmd
bool it_shell_cmd(arg_t a)
{
int n, status;
const char *cmdline = (const char*) a;
pid_t pid;
if (cmdline == NULL || *cmdline == '\0')
return false;
n = mode == MODE_IMAGE ? fileidx : tns.sel;
if (setenv("SXIV_IMG", files[n].path, 1) < 0) {
warn("could not set env.-variable: SXIV_IMG. command line was: %s",
cmdline);
return false;
}
if ((pid = fork()) == 0) {
execl("/bin/sh", "/bin/sh", "-c", cmdline, NULL);
warn("could not exec: /bin/sh. command line was: %s", cmdline);
exit(EXIT_FAILURE);
} else if (pid < 0) {
warn("could not fork. command line was: %s", cmdline);
return false;
}
win_set_cursor(&win, CURSOR_WATCH);
waitpid(pid, &status, 0);
if (WIFEXITED(status) == 0 || WEXITSTATUS(status) != 0)
warn("child exited with non-zero return value: %d. command line was: %s",
WEXITSTATUS(status), cmdline);
if (mode == MODE_IMAGE) {
img_close(&img, true);
load_image(fileidx);
}
if (!tns_load(&tns, n, &files[n], true, mode == MODE_IMAGE) &&
mode == MODE_THUMB)
{
remove_file(tns.sel, false);
tns.dirty = true;
if (tns.sel >= tns.cnt)
tns.sel = tns.cnt - 1;
}
return true;
}
开发者ID:hirkmt,项目名称:sxiv,代码行数:47,代码来源:commands.c
示例14: main
int main(int argc, char* argv[]){
int i=0;
uint8_t* rd;
uint8_t buf[30]="adfasdfasgfaaaaaaaaaaa";
char name[14];
char search_name[14];
rd=ramdisk_init();
int root_block_id=search_file(rd, "/");
int search_file_inodeNO;
int remove_flag;
int a;
printf("root block id is %d\n", root_block_id);
struct inode* root_inode;
if(!(root_inode=(struct inode*)malloc(sizeof(struct inode)))){
printf("No mem space!\n");
exit(-1);
}
//create_dir(rd,0,"ts_dir");
//create a file under root named Jiayi.txt
create_file(rd, 0, "ts_file.txt");
for (i = 0; i<1024 ; i++)
{
a = write_ramdisk(rd,1,i*20,buf,20);
printf("a = %d; i = %d\n", a, i);
// sprintf(name, "ts_%d.txt", i);
// create_file(rd, 1, name);
}
/* for (i = 1; i<=FILE_NUM ; i++)
{
sprintf(search_name, "/ts_%d.txt", i);
search_file_inodeNO = search_file(rd,search_name);
printf("File InodeNO is:%d\n", search_file_inodeNO);
}*/
//remove_flag=remove_file(rd,0,2,"ts_2.txt");
//(remove_flag==(-1))?(printf("Remove fail!\n")):(printf("Remove success!\n"));
//search_file_inodeNO=search_file(rd,"/ts_2.txt");
//printf("File InodeNO is:%d\n", search_file_inodeNO);
remove_flag=remove_file(rd,0,1,"ts_file.txt");
(remove_flag==(-1))?(printf("Remove fail!\n")):(printf("Remove success!\n"));
search_file_inodeNO=search_file(rd,"/ts_file.txt");
printf("File InodeNO is:%d\n", search_file_inodeNO);
return 0;
}
开发者ID:tinsingcheong,项目名称:JY_TS_Ramdisk,代码行数:47,代码来源:Ts_main.c
示例15: get_mods_list_file
void mod_manager::save_mods_list(WORLDPTR world) const
{
if( world == NULL ) {
return;
}
const std::string path = get_mods_list_file(world);
if( world->active_mod_order.empty() ) {
// If we were called from load_mods_list to prune the list,
// and it's empty now, delete the file.
remove_file(path);
return;
}
write_to_file( path, [&]( std::ostream &fout ) {
JsonOut json( fout, true ); // pretty-print
json.write(world->active_mod_order);
}, _( "list of mods" ) );
}
开发者ID:EpicOrange,项目名称:Cataclysm-DDA,代码行数:17,代码来源:mod_manager.cpp
示例16: mutt_fast_close_compressed
/* close a compressed mailbox */
void mutt_fast_close_compressed (CONTEXT * ctx)
{
debug_print (2, ("called on '%s'\n", ctx->path));
if (ctx->compressinfo) {
if (ctx->fp)
fclose (ctx->fp);
ctx->fp = NULL;
/* if the folder was removed, remove the gzipped folder too */
if (access (ctx->path, F_OK) != 0 && !option (OPTSAVEEMPTY))
remove (ctx->realpath);
else
remove_file (ctx);
restore_path (ctx);
mem_free (&ctx->compressinfo);
}
}
开发者ID:BackupTheBerlios,项目名称:mutt-ng-svn,代码行数:19,代码来源:compress.c
示例17: tagfs_unlink
/*
* Remove a file.
*/
int tagfs_unlink(const char *path) {
int retstat = 0;
int file_id = 0;
DEBUG(ENTRY);
INFO("Deleting %s", path);
file_id = file_id_from_path(path);
if(strcmp(dirname(path), "/") == 0) {
remove_file(file_id);
} else {
remove_tags(file_id);
}
DEBUG(EXIT);
return retstat;
}
开发者ID:williamwoelke,项目名称:TagFS,代码行数:21,代码来源:tagfs.c
示例18: return
void update_operation::rollback() {
auto file_manager = config_.file_manager;
auto hasher = config_.hasher;
// did we patch the file? keep in mind that if we did:
//
// - patched_path_ would point to the **original** file
// - basis_path_ would point to the **patched** file
//
// to avoid confusion, we'll gonna rename the references to "original" and
// "patched":
const path_t &original_path(patched_path_);
const string_t &original_checksum(basis_checksum);
const path_t &modified_path(basis_path_);
const string_t &modified_checksum(patched_checksum);
if (!file_manager->is_readable(modified_path)) {
return (void)STAGE_INVALID_STATE;
}
auto checksum = hasher->hex_digest(modified_path);
if (checksum == modified_checksum) {
// make sure the original still exists
if (!file_manager->exists(original_path)) {
error() << "Basis no longer exists in cache, can not rollback!";
return (void)STAGE_INVALID_STATE;
}
else if (hasher->hex_digest(original_path) != original_checksum) {
error() << "Basis file seems to have changed, can not rollback!";
return (void)STAGE_INVALID_STATE;
}
// remove the modified file:
file_manager->remove_file(modified_path);
// and move the original file back in its place:
file_manager->move(original_path, modified_path);
}
}
开发者ID:amireh,项目名称:Karazeh,代码行数:42,代码来源:update.cpp
示例19: remove_directories
void remove_directories(const std::string & dir)
{
std::stack<std::string> directories;
directories.push(dir);
while(!directories.empty())
{
std::string current = directories.top();
if(is_empty(current))
{
remove_directory(current);
directories.pop();
continue;
}
directory_iterator_t iter(current),end;
for(;iter != end; ++ iter)
{
if("." == *iter) continue;
if(".." == *iter) continue;
std::string path = current + "/" + *iter;
if(is_directory(path))
{
if(is_empty(path)) remove_directory(path);
else directories.push(path);
}
else
{
remove_file(path);
}
}
}
}
开发者ID:xubingyue,项目名称:mini-lake,代码行数:42,代码来源:fs.cpp
示例20: remove_block
int remove_block(int number)
{
int result = 0;
int status = get_block_status(number);
switch (status)
{
case BLOCK_STATUS_FREE:
break;
case BLOCK_STATUS_FOLDER:
remove_folder(number);
break;
case BLOCK_STATUS_FILE:
remove_file(number);
break;
default:
result = -1;
break;
}
return result;
}
开发者ID:noullex,项目名称:filesystem,代码行数:20,代码来源:fsactions.c
注:本文中的remove_file函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论