Create directories as necessary

This commit is contained in:
Jaidyn Ann 2021-03-20 11:44:39 -05:00
parent 2497569132
commit ef3eec3689
4 changed files with 17 additions and 1 deletions

View File

@ -31,8 +31,13 @@ bool
Entry::Filetize(BDirectory outDir) Entry::Filetize(BDirectory outDir)
{ {
BFile file(title.String(), B_READ_WRITE); BFile file(title.String(), B_READ_WRITE);
BEntry outDirEntry;
time_t tt_date = date.Time_t(); time_t tt_date = date.Time_t();
outDir.GetEntry(&outDirEntry);
if (outDir.InitCheck() == B_ENTRY_NOT_FOUND) {
outDir.CreateDirectory(BPath(&outDirEntry).Path(), &outDir);
}
outDir.CreateFile(title.String(), &file); outDir.CreateFile(title.String(), &file);
BString betype = BString("text/x-feed-entry"); BString betype = BString("text/x-feed-entry");

View File

@ -94,8 +94,11 @@ FeedController::SubscribedFeeds()
find_directory(B_USER_SETTINGS_DIRECTORY, &subPath); find_directory(B_USER_SETTINGS_DIRECTORY, &subPath);
subPath.Append("Pogger"); subPath.Append("Pogger");
subPath.Append("Subscriptions"); subPath.Append("Subscriptions");
BDirectory subDir(subPath.Path()); BDirectory subDir(subPath.Path());
if (subDir.InitCheck() == B_ENTRY_NOT_FOUND) {
subDir.CreateDirectory(subPath.Path(), &subDir);
}
BEntry feedEntry; BEntry feedEntry;
BPath feedPath; BPath feedPath;
BStringList feeds; BStringList feeds;

View File

@ -129,6 +129,10 @@ FeedEditWindow::_SaveFeed()
find_directory(B_USER_SETTINGS_DIRECTORY, &subPath); find_directory(B_USER_SETTINGS_DIRECTORY, &subPath);
subPath.Append("Pogger"); subPath.Append("Pogger");
subPath.Append("Subscriptions"); subPath.Append("Subscriptions");
BDirectory subDir(subPath.Path());
if (subDir.InitCheck() == B_ENTRY_NOT_FOUND) {
subDir.CreateDirectory(subPath.Path(), &subDir);
}
BString title(fFeedNameText->Text()); BString title(fFeedNameText->Text());
const char* urlString = fFeedUrlText->Text(); const char* urlString = fFeedUrlText->Text();

View File

@ -25,6 +25,10 @@ Preferences::Load()
BPath cfgPath; BPath cfgPath;
find_directory(B_USER_SETTINGS_DIRECTORY, &cfgPath); find_directory(B_USER_SETTINGS_DIRECTORY, &cfgPath);
cfgPath.Append("Pogger"); cfgPath.Append("Pogger");
if (BDirectory(cfgPath.Path()).InitCheck() == B_ENTRY_NOT_FOUND) {
BDirectory(cfgPath.Path()).CreateDirectory(cfgPath.Path(), NULL);
}
BString filename = BString(cfgPath.Path()).Append("/Settings"); BString filename = BString(cfgPath.Path()).Append("/Settings");
BFile file = BFile(filename.String(), B_READ_ONLY); BFile file = BFile(filename.String(), B_READ_ONLY);