Skip to content

Commit

Permalink
Create default saved profiles folder and set as default
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Hill committed Nov 3, 2016
1 parent 8d8377f commit 70d1cdb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
Binary file modified SimpleBackup
Binary file not shown.
2 changes: 1 addition & 1 deletion src/SBSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ void SBSettings::addExclude(BEntry excEntry)
(new BAlert("", alertStr.String(), "Oops"))->Go(NULL);
return; }
}
excludeList->AddItem(new SBListItem(excPath.Path()));
excludeList->AddItem(new SBListItem(pathString.String()));

return;
}
Expand Down
23 changes: 16 additions & 7 deletions src/SBWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ SBWindow::SBWindow(BRect size)
// profilesDir = settingsDir;
settingsPath.Append("settings");
BEntry archiveEntry(settingsPath.Path());
bool foundProfileSetting = false;
if(archiveEntry.Exists())
{ BFile archiveFile(&archiveEntry, B_READ_ONLY);
off_t datasize; archiveFile.GetSize(&datasize);
Expand Down Expand Up @@ -212,13 +213,8 @@ SBWindow::SBWindow(BRect size)
ResizeTo(width, height);
}
}
if(archive.FindRef("profilesRef", &fProfilesDirRef) != B_OK)
{
BPath profilesPath;
find_directory(B_USER_DIRECTORY, &profilesPath);
BEntry profilesEntry(profilesPath.Path());
profilesEntry.GetRef(&fProfilesDirRef);
}
if(archive.FindRef("profilesRef", &fProfilesDirRef) == B_OK)
foundProfileSetting = true;
// archive.FindBool("SB:showSettings", &settingsShown);
// settingsShown = !settingsShown;
// toggleSettings();
Expand All @@ -230,6 +226,17 @@ SBWindow::SBWindow(BRect size)
{ settingsShown = true;
// toggleSettings();
}*/
if(!foundProfileSetting)
{
BDirectory profilesDir;
BPath profilesPath(&fSettingsDir);
profilesPath.Append("saved profiles");
if( profilesDir.SetTo(profilesPath.Path()) == B_ENTRY_NOT_FOUND )
profilesDir.CreateDirectory(profilesPath.Path(), &profilesDir);
BEntry profilesEntry;
profilesDir.GetEntry(&profilesEntry);
profilesEntry.GetRef(&fProfilesDirRef);
}

//Create open and save file panel objects
savePanel = new BFilePanel(B_SAVE_PANEL);//normal save panel
Expand All @@ -240,8 +247,10 @@ SBWindow::SBWindow(BRect size)
// openFileOrDirPanel->SetButtonLabel(B_DEFAULT_BUTTON, "Select");
saveProfilePanel = new SettingsFilePanel(B_SAVE_PANEL, new BMessenger(this), &fProfilesDirRef);//save a setting profile
saveProfilePanel->SetTarget(this);
saveProfilePanel->UpdateSettingsDirectory(&fProfilesDirRef);
openProfilePanel = new SettingsFilePanel(B_OPEN_PANEL, new BMessenger(this), &fProfilesDirRef);//open a setting profile
openProfilePanel->SetTarget(this);
openProfilePanel->UpdateSettingsDirectory(&fProfilesDirRef);
Unlock();
Show();
}
Expand Down

0 comments on commit 70d1cdb

Please sign in to comment.