/** * @return Return 1 on success or 0 on failure * @brief Delete all the files inside the trash. */ EAPI int efreet_trash_empty_trash(void) { char buf[PATH_MAX]; snprintf(buf, sizeof(buf), "%s/info", efreet_trash_dir_get(NULL)); if (!ecore_file_recursive_rm(buf)) return 0; ecore_file_mkdir(buf); snprintf(buf, sizeof(buf), "%s/files", efreet_trash_dir_get(NULL)); if (!ecore_file_recursive_rm(buf)) return 0; ecore_file_mkdir(buf); /* TODO Empty also trash in other filesystems */ return 1; }
EflResources::~EflResources() { // Prevent any cached photos from hanging around. if( 1 == ecore_file_exists( cache_dir.c_str() ) ) { ASSERT( ecore_file_recursive_rm( cache_dir.c_str() ) , "Could not delete cache." ); } for( auto image_it( preloaded_images__.begin() ) , end( preloaded_images__.end() ); image_it != end; ++image_it ) { evas_object_del( image_it->second ); } }
ActivityWidgetsView::ActivityWidgetsView(Evas *_e, Evas_Object *_parent): ActivityView(_e, _parent, "calaos/page/widgets") { clipper = evas_object_rectangle_add(evas); evas_object_color_set(clipper, 0, 0, 0, 0); evas_object_show(clipper); Swallow(clipper, "widgets.swallow", true); //Create a temporary dir for modules if (ecore_file_is_dir("/tmp/calaos_widgets")) ecore_file_recursive_rm("/tmp/calaos_widgets"); ecore_file_mkpath("/tmp/calaos_widgets"); //add search paths for modules ModuleManager::Instance().addPath(PACKAGE_LIB_DIR "/calaos/widgets"); ModuleManager::Instance().addPath("/usr/lib/calaos/widgets"); ModuleManager::Instance().SearchModules(); LoadWidgets(); }
/** * @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; }
/** * @param uri: The local uri to move in the trash * @param force_delete: If you set this to 1 than files on different filesystems * will be deleted permanently * @return Return 1 on success, 0 on failure or -1 in case the uri is not on the * same filesystem and force_delete is not set. * @brief This function try to move the given uri to the trash. Files on * different filesystem can't be moved to trash. If force_delete * is 0 than non-local files will be ignored and -1 is returned, if you set * force_delete to 1 non-local files will be deleted without asking. */ EAPI int efreet_trash_delete_uri(Efreet_Uri *uri, int force_delete) { char dest[PATH_MAX]; char times[64]; const char *fname; const char *escaped; const char *trash_dir; int i = 1; time_t now; FILE *f; if (!uri || !uri->path || !ecore_file_can_write(uri->path)) return 0; fname = ecore_file_file_get(uri->path); trash_dir = efreet_trash_dir_get(uri->path); if (!trash_dir) { ERR("EFREET TRASH ERROR: No trash directory."); return 0; } snprintf(dest, sizeof(dest), "%s/files/%s", trash_dir, fname); /* search for a free filename */ while (ecore_file_exists(dest) && (i < 100)) snprintf(dest, sizeof(dest), "%s/files/%s$%d", trash_dir, fname, i++); fname = ecore_file_file_get(dest); /* move file to trash dir */ if (rename(uri->path, dest)) { if (errno == EXDEV) { if (!force_delete) { eina_stringshare_del(trash_dir); return -1; } if (!ecore_file_recursive_rm(uri->path)) { ERR("EFREET TRASH ERROR: Can't delete file."); eina_stringshare_del(trash_dir); return 0; } } else { ERR("EFREET TRASH ERROR: Can't move file to trash."); eina_stringshare_del(trash_dir); return 0; } } /* create info file */ snprintf(dest, sizeof(dest), "%s/info/%s.trashinfo", trash_dir, fname); if ((f = fopen(dest, "w"))) { fputs("[Trash Info]\n", f); //TODO is '\n' right?? (or \r\c??) fputs("Path=", f); escaped = efreet_uri_encode(uri); fputs(escaped + 7, f); // +7 == don't write 'file://' IF_RELEASE(escaped); time(&now); strftime(times, sizeof(times), "%Y-%m-%dT%H:%M:%S", localtime(&now)); fputs("\nDeletionDate=", f); fputs(times, f); fputs("\n", f); fclose(f); } else { ERR("EFREET TRASH ERROR: Can't create trash info file."); return 0; } return 1; }
static void delete_file_context_action(madshelf_state_t* state, const char* filename) { ecore_file_recursive_rm(filename); (*state->loc->fs_updated)(state); }