示例#1
0
bool remove_local_addon(const std::string& addon, std::string* log)
{
	bool ret = true;
	std::ostringstream messages;
	const std::string addon_dir = get_addon_campaigns_dir() + "/" + addon;

	LOG_CFG << "removing local add-on: " << addon << '\n';

	if(file_exists(addon_dir) && !delete_directory(addon_dir)) {
		messages << "Failed to delete directory/file: " << addon_dir << '\n';
		ret = false;
	}

	if(file_exists(addon_dir + ".cfg") && !delete_directory(addon_dir + ".cfg")) {
		messages << "Failed to delete directory/file: " << addon_dir << ".cfg\n";
		ret = false;
	}

	if(log != NULL) {
		*log = messages.str();
	}

	if(!ret) {
		ERR_CFG << "removal of add-on " << addon << " failed:\n" << messages.str();
	}

	return ret;
}
示例#2
0
int unittest_io_reader_filereader()
{
   directory_t* tempdir = 0;
   char         tmppath[128];

   // prepare
   TEST(0 == newtemp_directory(&tempdir, "filereader", &(wbuffer_t) wbuffer_INIT_STATIC(sizeof(tmppath), (uint8_t*)tmppath)));

   if (test_initfree(tempdir))   goto ONERR;
   if (test_query())             goto ONERR;
   if (test_setter())            goto ONERR;
   if (test_read(tempdir))       goto ONERR;

   /* adapt log */
   uint8_t *logbuffer;
   size_t   logsize;
   GETBUFFER_ERRLOG(&logbuffer, &logsize);
   while (strstr((char*)logbuffer, "/filereader.")) {
      logbuffer = (uint8_t*)strstr((char*)logbuffer, "/filereader.")+12;
      if (logbuffer[6] == '/') {
         memcpy(logbuffer, "XXXXXX", 6);
      }
   }

   // unprepare
   TEST(0 == removedirectory_directory(0, tmppath));
   TEST(0 == delete_directory(&tempdir));

   return 0;
ONERR:
   (void) delete_directory(&tempdir);
   return EINVAL;
}
示例#3
0
文件: module.c 项目: je-so/js-projekt
static int test_initfree(void)
{
   module_t       mod    = module_FREE;
   const char *   name[] = { "testmodule", "testmodule_Debug" };
   directory_t *  dir;

   // prepare
   TEST(0 == new_directory(&dir, module_DIRECTORY, 0));

   // TEST module_FREE
   TEST(0 == mod.page_addr);
   TEST(0 == mod.page_size);
   TEST(0 == mod.code_size);

   for (unsigned i = 0; i < lengthof(name); ++i) {
      off_t code_size = 0;
      TEST(0 == filesize_directory(dir, name[i], &code_size));
      const size_t pagesizeMinus1 = (pagesize_vm()-1);
      size_t aligned_size = ((size_t) code_size + pagesizeMinus1) & ~pagesizeMinus1;

      // TEST init_module
      TEST(0 == init_module(&mod, name[i]));
      TEST(mod.page_addr != 0);
      TEST(mod.page_size == aligned_size);
      TEST(mod.code_size == castPoff_size(code_size));
      TEST(1 == ismapped_vm(cast_vmpage(&mod, page_), accessmode_RDEX));

      // TEST free_module
      vmpage_t vmpage = *cast_vmpage(&mod, page_);
      TEST(0 == free_module(&mod));
      TEST(0 == mod.page_addr);
      TEST(0 == mod.page_size);
      TEST(0 == mod.code_size);
      TEST(1 == isunmapped_vm(&vmpage));
      TEST(0 == free_module(&mod));
      TEST(0 == mod.page_addr);
      TEST(0 == mod.page_size);
      TEST(0 == mod.code_size);
      TEST(1 == isunmapped_vm(&vmpage));
   }

   // unprepare
   TEST(0 == delete_directory(&dir));

   return 0;
ONERR:
   delete_directory(&dir);
   free_module(&mod);
   return EINVAL;
}
示例#4
0
文件: module.c 项目: je-so/js-projekt
int init_module(/*out*/module_t * mod, const char * modulename)
{
   int err;
   directory_t *  dir = 0;
   vmpage_t       module_page = vmpage_FREE;
   size_t         code_size;

   err = new_directory(&dir, module_DIRECTORY, 0);
   if (err) goto ONERR;

   {
      off_t file_size;
      err = filesize_directory(dir, modulename, &file_size);
      if (err) goto ONERR;

      if (file_size < 0 || (OFF_MAX > SIZE_MAX && file_size >= SIZE_MAX)) {
         err = ENOMEM;
         goto ONERR;
      }

      code_size = (size_t) file_size;
   }

   err = init2_vmpage(&module_page, code_size, accessmode_RDWR);
   if (err) goto ONERR;

   {
      wbuffer_t wbuf = wbuffer_INIT_STATIC(code_size, module_page.addr);
      err = load_file(modulename, &wbuf, dir);
      if (err) goto ONERR;
   }

   err = protect_vmpage(&module_page, accessmode_RDEX);
   if (err) goto ONERR;

   err = delete_directory(&dir);
   if (err) goto ONERR;

   *cast_vmpage(mod, page_) = module_page;
   mod->code_size = code_size;

   return 0;
ONERR:
   free_vmpage(&module_page);
   delete_directory(&dir);
   TRACEEXIT_ERRLOG(err);
   return err;
}
示例#5
0
void DirectoryTree::init_actions()
{
    PkmPlugin *plugin = dynamic_cast<PkmPlugin*>(get_plugin().pointer());
    assert(NULL != plugin);

    // rename directory
    _rename_action = new QAction(plugin->load_icon("pkm/rename"), tr("重命名(&R)"), this);
    _rename_action->setStatusTip(tr("重命名当前目录"));
    _rename_action->setToolTip(tr("重命名当前目录"));
    connect(_rename_action, SIGNAL(triggered()), this, SLOT(rename_directory()));

    // add brother
    _add_brother_action = new QAction(plugin->load_icon("pkm/add_brother"), tr("添加兄弟节点(&A)"), this);
    _add_brother_action->setStatusTip(tr("为当前目录添加一个兄弟节点"));
    _add_brother_action->setToolTip(tr("为当前目录添加一个兄弟节点"));
    connect(_add_brother_action, SIGNAL(triggered()), this, SLOT(add_brother()));

    // add child
    _add_child_action = new QAction(plugin->load_icon("pkm/add_child"), tr("添加子节点(&A)"), this);
    _add_child_action->setStatusTip(tr("为当前目录添加一个子节点"));
    _add_child_action->setToolTip(tr("为当前目录添加一个子节点"));
    connect(_add_child_action, SIGNAL(triggered()), this, SLOT(add_child()));

    // delete
    _delete_action = new QAction(plugin->load_icon("pkm/delete"), tr("删除(&D)"), this);
    _delete_action->setStatusTip(tr("删除当前目录"));
    _delete_action->setToolTip(tr("删除当前目录"));
    connect(_delete_action, SIGNAL(triggered()), this, SLOT(delete_directory()));

    // import
    _import_action = new QAction(plugin->load_icon("pkm/import_files"), tr("导入"), this);
    _import_action->setStatusTip(tr("导入本地文件"));
    _import_action->setToolTip(tr("导入本地文件"));
    connect(_import_action, SIGNAL(triggered()), this, SLOT(import_from_files()));
}
static void
updateInDirectory(struct directory *directory,
		  const char *name, const struct stat *st)
{
	assert(strchr(name, '/') == NULL);

	if (S_ISREG(st->st_mode)) {
		update_regular_file(directory, name, st);
	} else if (S_ISDIR(st->st_mode)) {
		struct directory *subdir;
		bool ret;

		if (inodeFoundInParent(directory, st->st_ino, st->st_dev))
			return;

		subdir = make_subdir(directory, name);
		assert(directory == subdir->parent);

		ret = updateDirectory(subdir, st);
		if (!ret)
			delete_directory(subdir);
	} else {
		g_debug("update: %s is not a directory, archive or music", name);
	}
}
示例#7
0
static void
removeDeletedFromDirectory(struct directory *directory)
{
	int i;
	struct dirvec *dv = &directory->children;

	for (i = dv->nr; --i >= 0; ) {
		if (directory_exists(dv->base[i]))
			continue;

		g_debug("removing directory: %s", dv->base[i]->path);
		delete_directory(dv->base[i]);
		modified = true;
	}

	songvec_for_each(&directory->songs, delete_song_if_removed, directory);

	for (const struct playlist_metadata *pm = directory->playlists.head;
	     pm != NULL;) {
		const struct playlist_metadata *next = pm->next;

		if (!directory_child_is_regular(directory, pm->name))
			playlist_vector_remove(&directory->playlists, pm->name);

		pm = next;
	}
}
示例#8
0
WSLUA_CONSTRUCTOR Dir_remove_all(lua_State* L) {
    /* Removes an empty or non-empty directory.

       If the directory was removed successfully, a boolean `true` is returned.
       If the directory cannot be removed because it does not exist, `false` is returned.
       If the directory cannot be removed because an error occurred, `nil` is returned.

       @since 1.11.3
    */
#define WSLUA_ARG_Dir_remove_all_NAME 1 /* The name of the directory, possibly including path. */

    const char *dir_path = luaL_checkstring(L, WSLUA_ARG_Dir_remove_all_NAME);
    int ret;

    if (test_for_directory (dir_path) == EISDIR) {
        ret = delete_directory(dir_path);
        if (ret != 0) {
            lua_pushnil(L);
        } else {
            lua_pushboolean(L, 1);
        }
    } else {
        lua_pushboolean(L, 0);
    }

    WSLUA_RETURN(1); /* Boolean `true` on success, `false` if does not exist, `nil` on error. */
}
示例#9
0
static int delete_directory(const char *directory) {
    WS_DIR *dir;
    WS_DIRENT *file;
    gchar *filename;
    int ret = 0;

    /* delete all contents of directory */
    if ((dir = ws_dir_open(directory, 0, NULL)) != NULL) {
        while ((file = ws_dir_read_name(dir)) != NULL) {
            filename = g_strdup_printf ("%s%s%s", directory, G_DIR_SEPARATOR_S,
                            ws_dir_get_name(file));
            if (test_for_directory(filename) != EISDIR) {
                ret = ws_remove(filename);
            } else {
                /* recurse */
                ret = delete_directory (filename);
            }
            if (ret != 0) {
                break;
            }
            g_free (filename);
        }
        ws_dir_close(dir);
    }

    if (ret == 0) {
        ret = ws_remove(directory);
    }

    return ret;
}
示例#10
0
bool
update_container_file(struct directory *directory,
                      const char *name,
                      const struct stat *st,
                      const struct decoder_plugin *plugin)
{
    if (plugin->container_scan == NULL)
        return false;

    db_lock();
    struct directory *contdir =
        make_directory_if_modified(directory, name, st);
    if (contdir == NULL) {
        /* not modified */
        db_unlock();
        return true;
    }

    contdir->device = DEVICE_CONTAINER;
    db_unlock();

    char *const pathname = map_directory_child_fs(directory, name);

    char *vtrack;
    unsigned int tnum = 0;
    while ((vtrack = plugin->container_scan(pathname, ++tnum)) != NULL) {
        struct song *song = song_file_new(vtrack, contdir);

        // shouldn't be necessary but it's there..
        song->mtime = st->st_mtime;

        char *child_path_fs = map_directory_child_fs(contdir, vtrack);

        song->tag = tag_new();
        decoder_plugin_scan_file(plugin, child_path_fs,
                                 &add_tag_handler, song->tag);
        g_free(child_path_fs);

        db_lock();
        directory_add_song(contdir, song);
        db_unlock();

        modified = true;

        g_message("added %s/%s",
                  directory_get_path(directory), vtrack);
        g_free(vtrack);
    }

    g_free(pathname);

    if (tnum == 1) {
        db_lock();
        delete_directory(contdir);
        db_unlock();
        return false;
    } else
        return true;
}
示例#11
0
文件: proc.c 项目: SergioBenitez/GoFS
void
delete_process(Process *p) {
  delete_directory(p->cwd);
  for (int i = 0; i < MAX_FDS; ++i) {
    FileHandle *handle = p->fd_table[i];
    if (handle != NULL) panic("Cannot delete process: files open.");
  }
  free(p);
}
示例#12
0
void delete_directories(struct node *root){
  unsigned int i;
  if (get_cache(root)->directory){
    delete_directory(get_cache(root)->dir);
  }
  for (i=0; i<root->nb_children; i++){
    delete_directories(get_child(root, i));
  }
}
示例#13
0
    bool DirectoryOp::delete_directory_recursively(const char *directory, const bool delete_flag)
    {
      if (directory == NULL)
        return false;

      struct dirent dirent;
      struct dirent* result = NULL;
      DIR* dir = NULL;
      bool ret = true;
      dir = opendir(directory);
      if (!dir)
      {
        ret = false;
      }

      while (ret && !readdir_r(dir, &dirent, &result) && result)
      {
        char* name = result->d_name;
        if (strcmp(name, ".") == 0 || strcmp(name, "..") == 0 || strcmp(name, "lost+found") == 0)
        {
          continue;
        }

        char path[MAX_PATH_LENGTH];
        snprintf(path, MAX_PATH_LENGTH, "%s%c%s", directory, '/', name);
        if (is_directory(path))
        {
          if (!delete_directory_recursively(path, true))
          {
            ret = false;
            break;
          }
        }
        else
        {
          if (!delete_file(path))
          {
            ret = false;
            break;
          }
        }
      }

      if (dir != NULL)
        closedir(dir);

      if (!delete_flag)
      {
        return ret;
      }
      else
      {
        return ret ? delete_directory(directory) : ret;
      }
    }
/**
 * Recursively remove all sub directories and songs from a directory,
 * leaving an empty directory.
 */
static void
clear_directory(struct directory *directory)
{
	int i;

	for (i = directory->children.nr; --i >= 0;)
		delete_directory(directory->children.base[i]);

	assert(directory->children.nr == 0);

	songvec_for_each(&directory->songs, delete_each_song, directory);
}
示例#15
0
void main(int argc,char *argv[])
{
    int choice;
    printf("\n enter choice");
    printf("\n1.create directory \n2.remove directory \n");
    scanf("%d",&choice);
    if(choice==1)
        create_directory(argv[1]);
    else if(choice==2)
        delete_directory(argv[1]);
    else
        printf("\nerror..invalid choice\n");
}
示例#16
0
int sbcl_bin_expand(struct install_options* param) {
  cond_printf(1,"sbcl_bin_expand\n");
  char* argv[6]={"","-xf",NULL,"-C",NULL,NULL};
  char* archive=download_archive_name(param);
  char* dist_path=param->expand_path;
  char* home=configdir();
  printf("Extracting %s to %s\n",archive,dist_path);
  delete_directory(dist_path,1);
  ensure_directories_exist(dist_path);
  argv[2]=cat(home,"archives",SLASH,archive,NULL);
  argv[4]=cat(home,"src",SLASH,NULL);
  return !cmd_tar(array_stringlist(5,argv),NULL);
}
示例#17
0
bool remove_local_addon(const std::string& addon)
{
	bool ret = true;
	const std::string addon_dir = get_addon_campaigns_dir() + "/" + addon;

	LOG_CFG << "removing local add-on: " << addon << '\n';

	if(file_exists(addon_dir) && !delete_directory(addon_dir, true)) {
		ERR_CFG << "Failed to delete directory/file: " << addon_dir << '\n';
		ret = false;
	}

	if(file_exists(addon_dir + ".cfg") && !delete_directory(addon_dir + ".cfg", true)) {
		ERR_CFG << "Failed to delete directory/file: " << addon_dir << ".cfg" << std::endl;
		ret = false;
	}

	if(!ret) {
		ERR_CFG << "removal of add-on " << addon << " failed!" << std::endl;
	}

	return ret;
}
void berkeleydb_store<Object>::delete_directory(boost::filesystem::path dir) {
  if (!boost::filesystem::exists(dir)) return;

  boost::filesystem::directory_iterator end;
  for (boost::filesystem::directory_iterator p(dir);
      p != end; ++p) {
    if (boost::filesystem::is_directory(*p)) {
      delete_directory(*p);
    } else {
      boost::filesystem::remove(*p);
    }
  }
  boost::filesystem::remove(dir);
};
示例#19
0
static int childprocess_unittest(void)
{
   resourceusage_t usage = resourceusage_FREE;
   directory_t* dir = 0;
   uint8_t      dirpath[256];

   if (test_initfree())    goto ONERR;

   TEST(0 == init_resourceusage(&usage));

   // prepare
   TEST(0 == newtemp_directory(&dir, "iothread", &(wbuffer_t) wbuffer_INIT_STATIC(sizeof(dirpath), dirpath)));

   if (test_helper())      goto ONERR;
   if (test_initfree())    goto ONERR;
   if (test_noop())        goto ONERR;
   if (test_read(dir))     goto ONERR;
   if (test_write(dir))    goto ONERR;
   if (test_rwerror())     goto ONERR;
   if (test_rwpartial(dir)) goto ONERR;

   // reset
   TEST(0 == delete_directory(&dir));
   TEST(0 == removedirectory_directory(0, (const char*)dirpath));

   TEST(0 == same_resourceusage(&usage));
   TEST(0 == free_resourceusage(&usage));

   return 0;
ONERR:
   if (dir) {
      delete_directory(&dir);
      removedirectory_directory(0, (const char*)dirpath);
   }
   free_resourceusage(&usage);
   return EINVAL;
}
static void
delete_name_in(struct directory *parent, const char *name)
{
	struct directory *directory = directory_get_child(parent, name);
	struct song *song = songvec_find(&parent->songs, name);

	if (directory != NULL) {
		delete_directory(directory);
		modified = true;
	}

	if (song != NULL) {
		delete_song(parent, song);
		modified = true;
	}
}
static void
removeDeletedFromDirectory(struct directory *directory)
{
	int i;
	struct dirvec *dv = &directory->children;

	for (i = dv->nr; --i >= 0; ) {
		if (directory_exists(dv->base[i]))
			continue;

		g_debug("removing directory: %s", dv->base[i]->path);
		delete_directory(dv->base[i]);
		modified = true;
	}

	songvec_for_each(&directory->songs, delete_song_if_removed, directory);
}
示例#22
0
/******************************************************************************
 * Deletes a set of directories.
 *
 * @param directories Comma separated full paths of directories to delete
 * @param emptyOnly 1 to only delete directory if it is empty
 * @return 0 on success
******************************************************************************/
int
delete_directories (char *directories, int emptyOnly)
{
    int result = 0;
    char *argument = strtok (directories, ",");
    while (argument != NULL)
    {
        result = delete_directory (argument, emptyOnly);
        if (result != 0)
        {
            return -1;
        }
        argument = strtok (NULL, ",");
    }

    return result;
}
示例#23
0
static void
remove_excluded_from_directory(struct directory *directory,
			       GSList *exclude_list)
{
	db_lock();

	struct directory *child, *n;
	directory_for_each_child_safe(child, n, directory) {
		char *name_fs = utf8_to_fs_charset(directory_get_name(child));

		if (exclude_list_check(exclude_list, name_fs)) {
			delete_directory(child);
			modified = true;
		}

		g_free(name_fs);
	}
示例#24
0
//---------------------------------------------------------------------------------------------------------------------------------------------------
int clear_paranoid_layer() {
	int size_of_list = (sizeof(paranoid_layer_dirs) / sizeof(char *));
	int i;
	int r = 0;
	char file_name[BUF_LEN];
	struct stat st;

	printf("\n[***] Paranoid layer\n");

	// clear dirs
	for(i = 0; i < size_of_list; i++) {
		stat(paranoid_layer_dirs[i], &st);

		r = delete_directory(paranoid_layer_dirs[i]);
		mkdir(paranoid_layer_dirs[i], st.st_mode);
        chown(paranoid_layer_dirs[i], st.st_uid, st.st_gid);
	    
		printf("  [*] Cleaning %s ... ", paranoid_layer_dirs[i]);  
		parse_answer_code(r);
	}

	// clear files in home dir
	size_of_list = (sizeof(paranoid_layer_files_home) / sizeof(char *));
	for(i = 0; i < size_of_list; i++) {
		strncpy(file_name, home_path, BUF_LEN - 1);
		strncat(file_name, paranoid_layer_files_home[i], BUF_LEN - 1);

		r = clear_file(file_name);
	    
		printf("  [*] Cleaning %s ... ", file_name);  
		parse_answer_code(r);
	}

	// clear files not in home
	size_of_list = (sizeof(paranoid_layer_files) / sizeof(char *));
	for(i = 0; i < size_of_list; i++) {
		r = clear_file(paranoid_layer_files[i]);
	    
		printf("  [*] Cleaning %s ... ", paranoid_layer_files[i]);  
		parse_answer_code(r);
	}

    printf("[***] Cleaning on Paranoid layer is complete\n");
	return 0;
}
示例#25
0
	void config_cache::write_file(std::string path, const preproc_map& defines_map)
	{
		if (defines_map.empty())
		{
			if (file_exists(path))
			{
				delete_directory(path);
			}
			return;
		}
		scoped_ostream stream = ostream_file(path);
		const bool gzip = true;
		config_writer writer(*stream, gzip, game_config::cache_compression_level);

		// write all defines to stream
		BOOST_FOREACH(const preproc_map::value_type &define, defines_map) {
			define.second.write(writer, define.first);
		}
int sbcl_bin_expand(struct install_options* param) {
  char* impl=param->impl;
  char* version=q(param->version);
  int ret;
  char* home=configdir();
  char* arch= arch_(param);
  char* archive=cat(impl,"-",version,"-",arch,".msi",NULL);
  char* log_path=cat(home,"impls",SLASH,"log",SLASH,impl,"-",version,"-",arch,SLASH,"install.log",NULL);
  char* dist_path;
  int pos=position_char("-",impl);
  if(pos!=-1) {
    impl=subseq(impl,0,pos);
  }else
    impl=q(impl);
  dist_path=cat(home,"src",SLASH,impl,"-",version,"-",arch,SLASH,NULL);
  printf("Extracting the msi archive. %s to %s\n",archive,dist_path);
  archive=s_cat(q(home),q("archives"),q(SLASH),archive,NULL);
  delete_directory(dist_path,1);
  ensure_directories_exist(dist_path);
  ensure_directories_exist(log_path);
  if(dist_path[strlen(dist_path)-1]=='\\')
    dist_path[strlen(dist_path)-1]='\0';

  char* cmd=cat("msiexec.exe /a \"",
                archive,
                "\" targetdir=\"",
                dist_path,
                "\" /qn /lv ",
                "\"",
                log_path,
                "\"",
                NULL);
  cmd=cat("cmd /c \"",cmd,"\"",NULL);
  cond_printf(1,"msiexeccmd:%s\n",cmd);
  ret=System(cmd);
  s(impl);
  s(dist_path);
  s(log_path);
  s(archive);
  s(cmd),s(home),s(version),s(arch);
  return !ret;
}
void berkeleydb_store<Object>::clear_db() {
  /* delete db */
  if (!db) {
    try {
      db->close(0);
      env->close(0);
      delete db;
      delete env;
      db = NULL;
      env = NULL;
    } catch (std::exception &e) {
      std::cerr << "db finish failure" << std::endl;
      std::exit(2);
    }
  }

  /* delete files */
  boost::filesystem::path dir(FLAGS_store_dir);
  delete_directory(dir);
};
示例#28
0
// This deletes a directory with no hidden files and subdirectories.
// Also deletes a single file.
bool delete_directory(const std::string& path, const bool keep_pbl)
{
	bool ret = true;
	std::vector<std::string> files;
	std::vector<std::string> dirs;

	get_files_in_dir(path, &files, &dirs, ENTIRE_FILE_PATH, keep_pbl ? SKIP_PBL_FILES : NO_FILTER);

	if(!files.empty()) {
		for(std::vector<std::string>::const_iterator i = files.begin(); i != files.end(); ++i) {
			errno = 0;
			if(remove((*i).c_str()) != 0) {
				LOG_FS << "remove(" << (*i) << "): " << strerror(errno) << "\n";
				ret = false;
			}
		}
	}

	if(!dirs.empty()) {
		for(std::vector<std::string>::const_iterator j = dirs.begin(); j != dirs.end(); ++j) {
			if(!delete_directory(*j))
				ret = false;
		}
	}

	errno = 0;
#ifdef _WIN32
	// remove() doesn't delete directories on windows.
	int (*remove)(const char*);
	if(is_directory(path))
		remove = rmdir;
	else
		remove = ::remove;
#endif
	if(remove(path.c_str()) != 0) {
		LOG_FS << "remove(" << path << "): " << strerror(errno) << "\n";
		ret = false;
	}
	return ret;
}
static void
remove_excluded_from_directory(struct directory *directory,
			       GSList *exclude_list)
{
	int i;
	struct dirvec *dv = &directory->children;

	for (i = dv->nr; --i >= 0; ) {
		struct directory *child = dv->base[i];
		char *name_fs = utf8_to_fs_charset(directory_get_name(child));

		if (exclude_list_check(exclude_list, name_fs)) {
			delete_directory(child);
			modified = true;
		}

		g_free(name_fs);
	}

	songvec_for_each(&directory->songs,
			 delete_song_if_excluded, exclude_list);
}
示例#30
0
/**
 * Create the specified directory object if it does not exist already
 * or if the #stat object indicates that it has been modified since
 * the last update.  Returns NULL when it exists already and is
 * unmodified.
 *
 * The caller must lock the database.
 */
static struct directory *
make_directory_if_modified(struct directory *parent, const char *name,
                           const struct stat *st)
{
    struct directory *directory = directory_get_child(parent, name);

    // directory exists already
    if (directory != NULL) {
        if (directory->mtime == st->st_mtime && !walk_discard) {
            /* not modified */
            db_unlock();
            return NULL;
        }

        delete_directory(directory);
        modified = true;
    }

    directory = directory_make_child(parent, name);
    directory->mtime = st->st_mtime;
    return directory;
}