/** * Sync a directory to disk from a pathname. * * @param path The name of the directory to sync. */ void dir_sync_path(const char *path) { DIR *dir; dir = opendir(path); if (!dir) ohshite(_("unable to open directory '%s'"), path); dir_sync(dir, path); closedir(dir); }
/** * Sync to disk the contents and the directory specified. * * @param path The pathname to sync. */ void dir_sync_contents(const char *path) { DIR *dir; struct dirent *dent; dir = opendir(path); if (!dir) ohshite(_("unable to open directory '%s'"), path); while ((dent = readdir(dir)) != NULL) { if (strcmp(dent->d_name, ".") == 0 || strcmp(dent->d_name, "..") == 0) continue; dir_file_sync(path, dent->d_name); } dir_sync(dir, path); closedir(dir); }
static void cache_sync_foreach (Dir *dir, SyncData *sd) { GError* error = NULL; gboolean deleted; deleted = FALSE; /* log errors but don't report the specific ones */ if (!dir_sync (dir, &deleted, &error)) { sd->failed = TRUE; g_return_if_fail (error != NULL); gconf_log (GCL_ERR, "%s", error->message); g_error_free (error); g_return_if_fail (dir_sync_pending (dir)); } else { g_return_if_fail (error == NULL); g_return_if_fail (!dir_sync_pending (dir)); if (deleted) { /* Get rid of this directory */ cache_remove_from_parent (sd->dc, dir); g_hash_table_remove (sd->dc->cache, dir_get_name (dir)); cache_set_nonexistent (sd->dc, dir_get_name (dir), TRUE); dir_destroy (dir); sd->deleted_some = TRUE; } } }