Пример #1
0
static void
_win_populate_job(void *data)
{
   Win *w = data;
   w->job.populate = NULL;

   if (w->db)
     {
        db_close(w->db);
        w->db = NULL;
     }

   if (access(w->db_path, F_OK|X_OK) == 0)
     w->db = db_open(w->db_path);

   if (!w->db)
     {
        char tmpdir[PATH_MAX];
        lms_t *lms = lms_new(w->db_path);
        if (!lms)
          goto no_lms;
        enjoy_lms_charsets_add(lms);
        if (!enjoy_lms_parsers_add(lms))
          goto no_parsers;

        snprintf(tmpdir, sizeof(tmpdir), "%s/tmpdir-nomusic",
                 enjoy_cache_dir_get());
        ecore_file_mkpath(tmpdir);
        if (lms_process_single_process(lms, tmpdir) != 0)
          CRITICAL("Failed to scan empty directory %s", tmpdir);
        ecore_file_rmdir(tmpdir);
        lms_free(lms);

        w->db = db_open(w->db_path);
        if (!w->db)
          goto no_lms;

        goto populate;

     no_parsers:
        CRITICAL("could not add any lightmediascanner parser!");
        lms_free(lms);
     no_lms:
        CRITICAL("could not create database at %s!", w->db_path);
        exit(-1);
     }

 populate:
   ecore_event_add(ENJOY_EVENT_DB_UNLOCKED, NULL, NULL, NULL);
   list_populate(w->list, w->db);
}
Пример #2
0
/**
 * @brief Delete the given directory and all its contents.
 *
 * @param  dir The name of the directory to delete.
 * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
 *
 * This function delete @p dir and all its contents. If @p dir is a
 * link only the link is removed. It returns @c EINA_TRUE on success,
 * @c EINA_FALSE otherwise.
 */
EAPI Eina_Bool
ecore_file_recursive_rm(const char *dir)
{
   struct stat st;

#ifdef _WIN32
   char buf[PATH_MAX];

   if (readlink(dir, buf, sizeof(buf) - 1) > 0)
     return ecore_file_unlink(dir);
   if (stat(dir, &st) == -1)
     return EINA_FALSE;
#else
   if (lstat(dir, &st) == -1)
     return EINA_FALSE;
#endif

   if (S_ISDIR(st.st_mode))
     {
        Eina_File_Direct_Info *info;
        Eina_Iterator *it;
        int ret;

        ret = 1;
        it = eina_file_direct_ls(dir);
        EINA_ITERATOR_FOREACH(it, info)
          {
             if (!ecore_file_recursive_rm(info->path))
               ret = 0;
          }
        eina_iterator_free(it);

        if (!ecore_file_rmdir(dir)) ret = 0;
        if (ret)
            return EINA_TRUE;
        else
            return EINA_FALSE;
     }