gchar *libravatar_cache_init(const char *dirs[], gint start, gint end) { gchar *subdir, *rootdir; int i; rootdir = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, LIBRAVATAR_CACHE_DIR, G_DIR_SEPARATOR_S, NULL); if (!is_dir_exist(rootdir)) { if (make_dir(rootdir) < 0) { g_warning("cannot create root directory '%s'", rootdir); g_free(rootdir); return NULL; } } for (i = start; i <= end; ++i) { subdir = g_strconcat(rootdir, dirs[i], NULL); if (!is_dir_exist(subdir)) { if (make_dir(subdir) < 0) { g_warning("cannot create directory '%s'", subdir); g_free(subdir); g_free(rootdir); return NULL; } } g_free(subdir); } return rootdir; }
/** * Write a single attachment to file * \param filename Filename with path * \param partinfo Attachment to save */ static gboolean mimeview_write_part(const gchar *filename, MimeInfo *partinfo) { gchar *dir; dir= g_dirname(filename); if (!is_dir_exist(dir)) make_dir_hier(dir); g_free(dir); if (is_file_exist(filename)) { AlertValue aval; gchar *res; res = g_strdup_printf(_("Overwrite existing file '%s'?"), filename); aval = alertpanel(_("Overwrite"), res, _("OK"), _("Cancel"), NULL); g_free(res); if (G_ALERTDEFAULT != aval) return FALSE; } if (procmime_get_part(filename, partinfo) < 0) { alertpanel_error (_("Can't save the part of multipart message.")); return FALSE; } return TRUE; }
static void cache_items_deep_first(const gchar *dir, GSList **items, guint *failed) { const gchar *d; GDir *dp; GError *error = NULL; cm_return_if_fail(dir != NULL); if ((dp = g_dir_open(dir, 0, &error)) == NULL) { g_warning("cannot open directory '%s': %s (%d)\n", dir, error->message, error->code); g_error_free(error); (*failed)++; return; } while ((d = g_dir_read_name(dp)) != NULL) { if (strcmp(d, ".") == 0 || strcmp(d, "..") == 0) { continue; } else { const gchar *fname = g_strconcat(dir, G_DIR_SEPARATOR_S, d, NULL); if (is_dir_exist(fname)) cache_items_deep_first(fname, items, failed); *items = g_slist_append(*items, (gpointer) fname); } } g_dir_close(dp); }
bool make_dir(const std::string& para_path) { if (is_dir_exist(para_path)) { return true; } if (is_file_exist(para_path)) { ERROR_LOG("Exist file '%s' is not a dir.", para_path.c_str()); return false; } std::string path = para_path; size_t found = path.rfind("/"); if (found == path.size() - 1) { path = path.substr(0, path.size() - 1); found = path.rfind("/"); } if (found != std::string::npos) { std::string base_dir = path.substr(0, found); if (make_dir(base_dir)) { //mode is 0755 return mkdir(path.c_str(), S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) == 0; } } else { return mkdir(path.c_str(), S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) == 0; } return false; }
static void foldersel_cb(GtkWidget *widget, gpointer data) { struct ArchiverPrefsPage *page = (struct ArchiverPrefsPage *) data; gchar *startdir = NULL; gchar *dirname; gchar *tmp; if (archiver_prefs.save_folder && *archiver_prefs.save_folder) startdir = g_strconcat(archiver_prefs.save_folder, G_DIR_SEPARATOR_S, NULL); else startdir = g_strdup(get_home_dir()); dirname = filesel_select_file_save_folder(_("Select destination folder"), startdir); if (!dirname) { g_free(startdir); return; } if (!is_dir_exist(dirname)) { alertpanel_error(_("'%s' is not a directory."),dirname); g_free(dirname); g_free(startdir); return; } if (dirname[strlen(dirname)-1] == G_DIR_SEPARATOR) dirname[strlen(dirname)-1] = '\0'; g_free(startdir); tmp = g_filename_to_utf8(dirname,-1, NULL, NULL, NULL); gtk_entry_set_text(GTK_ENTRY(page->save_folder), tmp); g_free(dirname); g_free(tmp); }
/** * para: database name * return: 1 drop successful; 0 database not exists;-1 other error */ int SysManager::dropDatabase(string dbName) { string path = "DataBase/" + dbName; if (is_dir_exist(path.data()) != 0) { return 0; } DIR *dir; struct dirent *ptr; dir = opendir(path.data()); while((ptr = readdir(dir)) != NULL) { if (ptr->d_type == 8) { string filepath = path + "/" + string(ptr->d_name); bool ret = dataManager->deleteFile(filepath.data()); if (!ret) { return -1; } } } closedir(dir); if ( rmdir(path.data()) == 0) { if (dbName == dataManager->getCurrentDBName()) { dataManager->setDatabase(""); } readDatabases(); return 1; } return -1; }
static gchar *mh_get_new_msg_filename(FolderItem *dest) { gchar *destfile; gchar *destpath; destpath = folder_item_get_path(dest); cm_return_val_if_fail(destpath != NULL, NULL); if (!is_dir_exist(destpath)) make_dir_hier(destpath); for (;;) { destfile = g_strdup_printf("%s%c%d", destpath, G_DIR_SEPARATOR, dest->last_num + 1); if (is_file_entry_exist(destfile)) { dest->last_num++; g_free(destfile); } else break; } g_free(destpath); return destfile; }
void plugin_load(void) { debug_print("autoenc plug-in loaded!\n"); syl_init_gettext(GETTEXT_PACKAGE, LOCALEDIR); syl_plugin_add_menuitem("/Configuration", NULL, NULL, NULL); syl_plugin_add_menuitem("/Configuration", _("Configure automatic attachment encryption"), autoenc_setting, NULL); g_signal_connect_after(syl_app_get(), "init-done", G_CALLBACK(init_done_cb), NULL); autoenc_app_exit_handler_id = g_signal_connect(syl_app_get(), "app-exit", G_CALLBACK(app_exit_cb), NULL); syl_plugin_signal_connect("compose-created", G_CALLBACK(compose_created_cb), NULL); syl_plugin_signal_connect("compose-destroy", G_CALLBACK(compose_destroy_cb), NULL); syl_plugin_signal_connect("compose-send", G_CALLBACK(compose_send_cb), NULL); syl_plugin_signal_connect("compose-toolbar-changed", G_CALLBACK(compose_toolbar_changed_cb), NULL); syl_plugin_signal_connect("compose-attach-changed", G_CALLBACK(compose_attach_changed_cb), NULL); /* load config */ read_config(); if (is_dir_exist(get_autoenc_tmp_dir())) { remove_all_files(get_autoenc_tmp_dir()); } debug_print("autoenc plug-in loading done\n"); }
static void ssl_certificate_save(SSLCertificate *cert) { char *file, *port; FILE *fp; file = g_strconcat(config_dir, G_DIR_SEPARATOR_S, "certs", G_DIR_SEPARATOR_S, NULL); if (!is_dir_exist(file)) mkdir(file, S_IRWXU); g_free(file); port = g_strdup_printf("%d", cert->port); file = g_strconcat(config_dir, G_DIR_SEPARATOR_S, "certs", G_DIR_SEPARATOR_S, cert->host, ".", port, ".cert", NULL); g_free(port); fp = fopen(file, "wb"); if (fp == NULL) { g_free(file); eb_debug(DBG_CORE, "Can't save certificate !\n"); return; } i2d_X509_fp(fp, cert->x509_cert); g_free(file); fclose(fp); }
static void prefs_themes_file_install(const gchar *filename, gpointer data) { CopyInfo *ci = (CopyInfo *)data; gchar *base; if (ci->status != NULL) return; base = g_path_get_basename(filename); if (TRUE == is_dir_exist(filename)) { if (strcmp(base, ".") != 0 && strcmp(base, "..") !=0 ) g_warning("prefs_themes_file_install(): subdir in theme dir skipped: '%s'.", base); } else { gchar *fulldest; fulldest = g_strconcat(ci->dest, G_DIR_SEPARATOR_S, base, NULL); if (0 != copy_file(filename, fulldest, FALSE)) { ci->status = g_strdup(filename); } g_free(fulldest); } g_free(base); }
static void app_exit_cb(GObject *obj, gpointer data) { debug_print("autoenc: app_exit_cb: removing all temporary files\n"); if (is_dir_exist(get_autoenc_tmp_dir())) { remove_all_files(get_autoenc_tmp_dir()); } }
void template_write_config(GSList *tmpl_list) { const gchar *path; GSList *cur; Template *tmpl; FILE *fp; debug_print("%s:%d writing templates\n", __FILE__, __LINE__); path = get_template_dir(); if (!is_dir_exist(path)) { if (is_file_exist(path)) { g_warning(_("file %s already exists\n"), path); return; } if (make_dir(path) < 0) return; } remove_all_files(path); for (cur = tmpl_list; cur != NULL; cur = cur->next) { gchar *filename; tmpl = cur->data; filename = g_strconcat(path, G_DIR_SEPARATOR_S, itos(tmpl->tmplid), NULL); if ((fp = g_fopen(filename, "wb")) == NULL) { FILE_OP_ERROR(filename, "fopen"); g_free(filename); return; } fprintf(fp, "Name: %s\n", tmpl->name); if (tmpl->to && *tmpl->to != '\0') fprintf(fp, "To: %s\n", tmpl->to); if (tmpl->cc && *tmpl->cc != '\0') fprintf(fp, "Cc: %s\n", tmpl->cc); if (tmpl->bcc && *tmpl->bcc != '\0') fprintf(fp, "Bcc: %s\n", tmpl->bcc); if (tmpl->replyto && *tmpl->replyto != '\0') fprintf(fp, "Reply-To: %s\n", tmpl->replyto); if (tmpl->subject && *tmpl->subject != '\0') fprintf(fp, "Subject: %s\n", tmpl->subject); fputs("\n", fp); fwrite(tmpl->value, sizeof(gchar) * strlen(tmpl->value), 1, fp); fclose(fp); g_free(filename); } }
static gchar *get_local_path_with_locale(gchar *rootpath) { gchar *lang_str, *dir; lang_str = get_language(); dir = g_strconcat(rootpath, G_DIR_SEPARATOR_S, lang_str, NULL); g_free(lang_str); if(!is_dir_exist(dir)) { g_free(dir); dir = g_strconcat(rootpath, G_DIR_SEPARATOR_S, "en", NULL); if(!is_dir_exist(dir)) { g_free(dir); dir = NULL; } } return dir; }
GSList *template_read_config(void) { const gchar *path; gchar *filename; GDir *dir; const gchar *dir_name; struct stat s; Template *tmpl; guint tmplid; GSList *tmpl_list = NULL; path = get_template_dir(); debug_print("%s:%d reading templates dir %s\n", __FILE__, __LINE__, path); if (!is_dir_exist(path)) { if (make_dir(path) < 0) return NULL; } if ((dir = g_dir_open(path, 0, NULL)) == NULL) { g_warning("failed to open directory: %s\n", path); return NULL; } while ((dir_name = g_dir_read_name(dir)) != NULL) { tmplid = atoi(dir_name); if (tmplid <= 0) { continue; } filename = g_strconcat(path, G_DIR_SEPARATOR_S, dir_name, NULL); if (g_stat(filename, &s) != 0 || !S_ISREG(s.st_mode) ) { debug_print("%s:%d %s is not an ordinary file\n", __FILE__, __LINE__, filename); g_free(filename); continue; } tmpl = template_load(filename, tmplid); if (tmpl) tmpl_list = g_slist_insert_sorted(tmpl_list, tmpl, template_compare_id); g_free(filename); } g_dir_close(dir); return tmpl_list; }
static gint mh_rename_folder(Folder *folder, FolderItem *item, const gchar *name) { gchar *real_name; gchar *oldpath; gchar *dirname; gchar *newpath, *utf8newpath; gchar *paths[2]; cm_return_val_if_fail(folder != NULL, -1); cm_return_val_if_fail(item != NULL, -1); cm_return_val_if_fail(item->path != NULL, -1); cm_return_val_if_fail(name != NULL, -1); oldpath = folder_item_get_path(item); if (!is_dir_exist(oldpath)) make_dir_hier(oldpath); dirname = g_path_get_dirname(oldpath); real_name = mh_filename_from_utf8(name); newpath = g_strconcat(dirname, G_DIR_SEPARATOR_S, real_name, NULL); g_free(real_name); if (g_rename(oldpath, newpath) < 0) { FILE_OP_ERROR(oldpath, "rename"); g_free(oldpath); g_free(newpath); return -1; } g_free(oldpath); g_free(newpath); if (strchr(item->path, G_DIR_SEPARATOR) != NULL) { dirname = g_path_get_dirname(item->path); utf8newpath = g_strconcat(dirname, G_DIR_SEPARATOR_S, name, NULL); g_free(dirname); } else utf8newpath = g_strdup(name); g_free(item->name); item->name = g_strdup(name); paths[0] = g_strdup(item->path); paths[1] = utf8newpath; g_node_traverse(item->node, G_PRE_ORDER, G_TRAVERSE_ALL, -1, mh_rename_folder_func, paths); g_free(paths[0]); g_free(paths[1]); return 0; }
static gchar *mh_item_get_path(Folder *folder, FolderItem *item) { gchar *folder_path, *path; gchar *real_path; cm_return_val_if_fail(folder != NULL, NULL); cm_return_val_if_fail(item != NULL, NULL); folder_path = g_strdup(LOCAL_FOLDER(folder)->rootpath); cm_return_val_if_fail(folder_path != NULL, NULL); /* FIXME: [W32] The code below does not correctly merge relative filenames; there should be a function to handle this. */ if ( !is_relative_filename (folder_path) ) { if (item->path) path = g_strconcat(folder_path, G_DIR_SEPARATOR_S, item->path, NULL); else path = g_strdup(folder_path); } else { if (item->path) path = g_strconcat(get_home_dir(), G_DIR_SEPARATOR_S, folder_path, G_DIR_SEPARATOR_S, item->path, NULL); else path = g_strconcat(get_home_dir(), G_DIR_SEPARATOR_S, folder_path, NULL); } g_free(folder_path); real_path = mh_filename_from_utf8(path); if (!is_dir_exist(real_path) && is_dir_exist(path)) { /* mmh, older version did put utf8 filenames instead of * the correct encoding */ if (g_rename(path, real_path) == 0) folder_item_scan(item); } g_free(path); return real_path; }
static FolderItem *mh_create_folder(Folder *folder, FolderItem *parent, const gchar *name) { gchar *path, *real_name; gchar *fullpath; FolderItem *new_item; gchar *mh_sequences_filename; FILE *mh_sequences_file; cm_return_val_if_fail(folder != NULL, NULL); cm_return_val_if_fail(parent != NULL, NULL); cm_return_val_if_fail(name != NULL, NULL); path = folder_item_get_path(parent); if (!is_dir_exist(path)) if (make_dir_hier(path) != 0) return NULL; real_name = mh_filename_from_utf8(name); fullpath = g_strconcat(path, G_DIR_SEPARATOR_S, real_name, NULL); g_free(real_name); g_free(path); if (make_dir(fullpath) < 0) { g_free(fullpath); return NULL; } g_free(fullpath); if (parent->path) path = g_strconcat(parent->path, G_DIR_SEPARATOR_S, name, NULL); else path = g_strdup(name); new_item = folder_item_new(folder, name, path); folder_item_append(parent, new_item); g_free(path); path = folder_item_get_path(new_item); mh_sequences_filename = g_strconcat(path, G_DIR_SEPARATOR_S, ".mh_sequences", NULL); if ((mh_sequences_file = g_fopen(mh_sequences_filename, "a+b")) != NULL) { fclose(mh_sequences_file); } g_free(mh_sequences_filename); g_free(path); return new_item; }
static gchar *news_fetch_msg(Folder *folder, FolderItem *item, gint num) { gchar *path, *filename; NewsSession *session; gint ok; cm_return_val_if_fail(folder != NULL, NULL); cm_return_val_if_fail(item != NULL, NULL); path = folder_item_get_path(item); if (!is_dir_exist(path)) make_dir_hier(path); filename = g_strconcat(path, G_DIR_SEPARATOR_S, itos(num), NULL); g_free(path); if (is_file_exist(filename)) { debug_print("article %d has been already cached.\n", num); return filename; } session = news_session_get(folder); if (!session) { g_free(filename); return NULL; } ok = news_select_group(folder, item->path, NULL, NULL, NULL); if (ok != NEWSNNTP_NO_ERROR) { if (ok == NEWSNNTP_ERROR_STREAM) { session_destroy(SESSION(session)); REMOTE_FOLDER(folder)->session = NULL; } g_free(filename); return NULL; } debug_print("getting article %d...\n", num); ok = news_get_article(folder, num, filename); if (ok != NEWSNNTP_NO_ERROR) { g_warning("can't read article %d", num); if (ok == NEWSNNTP_ERROR_STREAM) { session_destroy(SESSION(session)); REMOTE_FOLDER(folder)->session = NULL; } g_free(filename); return NULL; } GTK_EVENTS_FLUSH(); return filename; }
static void news_folder_destroy(Folder *folder) { gchar *dir; while (nntp_folder_get_refcnt(folder) > 0) gtk_main_iteration(); dir = news_folder_get_path(folder); if (is_dir_exist(dir)) remove_dir_recursive(dir); g_free(dir); nntp_done(folder); folder_remote_folder_destroy(REMOTE_FOLDER(folder)); }
static void cache_delete_item(gpointer filename, gpointer errors) { const gchar *fname = (const gchar *) filename; AvatarCleanupResult *acr = (AvatarCleanupResult *) errors; if (!is_dir_exist(fname)) { if (claws_unlink(fname) < 0) { g_warning("couldn't delete file %s\n", fname); (acr->e_unlink)++; } else { (acr->removed)++; } } }
/** * para: database name * return: 1 create successful; 0 database exists;-1 other error */ int SysManager::createDatabase(string dbName) { if (dataBaseDic.find(dbName) != dataBaseDic.end()) { return 0; } string path = "DataBase/" + dbName; if (is_dir_exist(path.data()) == 0) { return 0; } int ret = mkdir(path.data(), S_IRWXU|S_IRWXG); if (ret == 0) { readDatabases(); return 1; } return -1; }
static void prefs_themes_file_remove(const gchar *filename, gpointer data) { gchar **status = (gchar **)data; gchar *base; if ((*status) != NULL) return; base = g_path_get_basename(filename); if (TRUE == is_dir_exist(filename)) { if (strcmp(base, ".") != 0 && strcmp(base, "..") != 0) g_warning("prefs_themes_file_remove(): subdir in theme dir skipped: '%s'.", base); } else if (0 != claws_unlink(filename)) { (*status) = g_strdup(filename); } g_free(base); }
static gint news_rename_folder(Folder *folder, FolderItem *item, const gchar *name) { gchar *path; cm_return_val_if_fail(folder != NULL, -1); cm_return_val_if_fail(item != NULL, -1); cm_return_val_if_fail(item->path != NULL, -1); cm_return_val_if_fail(name != NULL, -1); path = folder_item_get_path(item); if (!is_dir_exist(path)) make_dir_hier(path); g_free(item->name); item->name = g_strdup(name); return 0; }
static int news_remove_msg (Folder *folder, FolderItem *item, gint msgnum) { gchar *path, *filename; cm_return_val_if_fail(folder != NULL, -1); cm_return_val_if_fail(item != NULL, -1); path = folder_item_get_path(item); if (!is_dir_exist(path)) make_dir_hier(path); filename = g_strconcat(path, G_DIR_SEPARATOR_S, itos(msgnum), NULL); g_free(path); claws_unlink(filename); g_free(filename); return 0; }
static void news_remove_cached_msg(Folder *folder, FolderItem *item, MsgInfo *msginfo) { gchar *path, *filename; path = folder_item_get_path(item); if (!is_dir_exist(path)) { g_free(path); return; } filename = g_strconcat(path, G_DIR_SEPARATOR_S, itos(msginfo->msgnum), NULL); g_free(path); if (is_file_exist(filename)) { claws_unlink(filename); } g_free(filename); }
static gboolean mh_remove_missing_folder_items_func(GNode *node, gpointer data) { FolderItem *item; gchar *path; cm_return_val_if_fail(node->data != NULL, FALSE); if (G_NODE_IS_ROOT(node)) return FALSE; item = FOLDER_ITEM(node->data); path = folder_item_get_path(item); if (!is_dir_exist(path)) { debug_print("folder '%s' not found. removing...\n", path?path:"(null)"); folder_item_remove(item); } g_free(path); return FALSE; }
static void stock_pixmap_find_themes_in_dir(GList **list, const gchar *dirname) { struct dirent *d; DIR *dp; static const char *extension[]={".png", ".xpm", NULL}; if ((dp = opendir(dirname)) == NULL) { debug_print("dir %s not found, skipping theme scan\n", dirname?dirname:"(null)"); return; } while ((d = readdir(dp)) != NULL) { gchar *entry; gchar *fullentry; entry = d->d_name; fullentry = g_strconcat(dirname, G_DIR_SEPARATOR_S, entry, NULL); if (strcmp(entry, ".") != 0 && strcmp(entry, "..") != 0 && is_dir_exist(fullentry)) { gchar *filetoexist; gboolean found = FALSE; int i; int j; for (i = 0; i < N_STOCK_PIXMAPS && !found; i++) { for (j = 0; extension[j] && !found; j++) { filetoexist = g_strconcat(fullentry, G_DIR_SEPARATOR_S, pixmaps[i].file, extension[j], NULL); if (is_file_exist(filetoexist)) { *list = g_list_append(*list, fullentry); found = TRUE; } g_free(filetoexist); } } if (i == N_STOCK_PIXMAPS) g_free(fullentry); } else g_free(fullentry); } closedir(dp); }
static void stock_pixmap_find_themes_in_dir(GList **list, const gchar *dirname) { const gchar *entry; gchar *fullentry; GDir *dp; GError *error = NULL; static const char *extension[]= {".png", ".xpm", NULL}; if ((dp = g_dir_open(dirname, 0, &error)) == NULL) { debug_print("skipping theme scan, dir %s could not be opened: %s (%d)\n", dirname ? dirname : "(null)", error->message, error->code); g_error_free(error); return; } while ((entry = g_dir_read_name(dp)) != NULL) { fullentry = g_strconcat(dirname, G_DIR_SEPARATOR_S, entry, NULL); if (strcmp(entry, ".") != 0 && strcmp(entry, "..") != 0 && is_dir_exist(fullentry)) { gchar *filetoexist; gboolean found = FALSE; int i; int j; for (i = 0; i < N_STOCK_PIXMAPS && !found; i++) { for (j = 0; extension[j] && !found; j++) { filetoexist = g_strconcat(fullentry, G_DIR_SEPARATOR_S, pixmaps[i].file, extension[j], NULL); if (is_file_exist(filetoexist)) { *list = g_list_append(*list, fullentry); found = TRUE; } g_free(filetoexist); } } if (i == N_STOCK_PIXMAPS) g_free(fullentry); } else g_free(fullentry); } g_dir_close(dp); }
gint syl_setup_rc_dir(void) { if (!is_dir_exist(get_rc_dir())) { if (make_dir_hier(get_rc_dir()) < 0) return -1; } MAKE_DIR_IF_NOT_EXIST(get_mail_base_dir()); CHDIR_RETURN_VAL_IF_FAIL(get_rc_dir(), -1); MAKE_DIR_IF_NOT_EXIST(get_imap_cache_dir()); MAKE_DIR_IF_NOT_EXIST(get_news_cache_dir()); MAKE_DIR_IF_NOT_EXIST(get_mime_tmp_dir()); MAKE_DIR_IF_NOT_EXIST(get_tmp_dir()); MAKE_DIR_IF_NOT_EXIST(UIDL_DIR); MAKE_DIR_IF_NOT_EXIST(PLUGIN_DIR); /* remove temporary files */ remove_all_files(get_tmp_dir()); remove_all_files(get_mime_tmp_dir()); return 0; }
/** * 列出所有表的名字 * return: 当无表时,返回vector 内数据为空 * flag:1 成功 0 当前database中无表 -1 尚未选中任何database -2其他错误 */ vector<string> SysManager::showTables(int& flag) { vector<string> ans; flag = 0; if (dataManager->getCurrentDBName() == "") { flag = -1; return ans; } string path = "DataBase/" + dataManager->getCurrentDBName(); if (is_dir_exist(path.data()) != 0) { flag = -2; return ans; } DIR *dir; struct dirent *ptr; dir = opendir(path.data()); while((ptr = readdir(dir)) != NULL) { if (ptr->d_type == 8) { string name(ptr->d_name); int pos = name.find(".data"); if (pos != string::npos) { string tbname = name.substr(0, pos); //cout << "name: " << tbname << endl; ans.push_back(tbname); } } } closedir(dir); if (ans.empty()) { flag = 0; } else { flag = 1; } return ans; }