jcs
/subtext
/amendments
/462
db: If a folder's path doesn't exist, ask to create it
jcs made amendment 462 about 1 year ago
--- db.c Mon Mar 27 21:52:31 2023
+++ db.c Thu Apr 6 15:33:46 2023
@@ -905,9 +905,10 @@ db_cache_folders(struct db *tdb)
{
Str255 db_filename, folder_filename, folder_dir;
size_t n, size;
- unsigned long *ids;
+ unsigned long *ids, id;
struct bile_object *obj;
char *data = NULL;
+ short error;
if (tdb->folders) {
for (n = 0; n < tdb->nfolders; n++) {
@@ -990,9 +991,14 @@ db_cache_folders(struct db *tdb)
/* make sure directory exists */
memcpy(folder_dir, tdb->folders[n].path, sizeof(folder_dir));
CtoPstr(folder_dir);
- if (!FIsDir(folder_dir))
- warn("Folder %ld path \"%s\" does not exist",
- tdb->folders[n].id, tdb->folders[n].path);
+ if (!FIsDir(folder_dir) &&
+ ask("Folder %ld path \"%s\" does not exist, create it?",
+ tdb->folders[n].id, tdb->folders[n].path)) {
+ error = DirCreate(db->bile->vrefnum, 0, folder_dir, &id);
+ if (error)
+ warn("Failed creating %s: %d", tdb->folders[n].path,
+ error);
+ }
}
}