Replace several hard-coded paths with find_directory calls

This commit is contained in:
Philippe Saint-Pierre 2012-06-25 21:09:55 -04:00
parent d6f3ff4030
commit b78760b964
3 changed files with 24 additions and 6 deletions

View File

@ -15,6 +15,7 @@
#include <Menu.h> #include <Menu.h>
#include <MenuBar.h> #include <MenuBar.h>
#include <MenuItem.h> #include <MenuItem.h>
#include <Path.h>
#include <PopUpMenu.h> #include <PopUpMenu.h>
#include <scheduler.h> #include <scheduler.h>
#include <TabView.h> #include <TabView.h>
@ -22,6 +23,7 @@
#include <TimeSource.h> #include <TimeSource.h>
#include <TranslationKit.h> #include <TranslationKit.h>
#include <storage/FindDirectory.h>
#undef B_TRANSLATION_CONTEXT #undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "CodyCam" #define B_TRANSLATION_CONTEXT "CodyCam"
@ -169,7 +171,11 @@ CodyCam::CodyCam()
kUploadClients[index++] = B_TRANSLATE("SFTP"); kUploadClients[index++] = B_TRANSLATE("SFTP");
kUploadClients[index++] = B_TRANSLATE("Local"); kUploadClients[index++] = B_TRANSLATE("Local");
chdir("/boot/home"); BPath homeDir;
if (find_directory(B_USER_DIRECTORY, &homeDir) != B_OK)
homeDir.SetTo("/boot/home");
chdir(homeDir.Path());
} }

View File

@ -17,6 +17,8 @@
#include <Locale.h> #include <Locale.h>
#include <Message.h> #include <Message.h>
#include <Mime.h> #include <Mime.h>
#include <Path.h>
#include <storage/FindDirectory.h>
#include "support_settings.h" #include "support_settings.h"
@ -329,8 +331,14 @@ IconEditorApp::_LastFilePath(path_kind which)
path = fLastOpenPath.String(); path = fLastOpenPath.String();
break; break;
} }
if (!path) if (!path) {
path = "/boot/home";
BPath homePath;
if (find_directory(B_USER_DIRECTORY, &homePath) == B_OK)
path = homePath.Path();
else
path = "/boot/home";
}
return path; return path;
} }

View File

@ -31,6 +31,8 @@
#include <StringView.h> #include <StringView.h>
#include <TextControl.h> #include <TextControl.h>
#include <storage/FindDirectory.h>
#include "MediaFileInfoView.h" #include "MediaFileInfoView.h"
#include "MediaFileListView.h" #include "MediaFileListView.h"
#include "MessageConstants.h" #include "MessageConstants.h"
@ -122,8 +124,10 @@ MediaConverterWindow::MediaConverterWindow(BRect frame)
fConverting(false), fConverting(false),
fCancelling(false) fCancelling(false)
{ {
const char* defaultDirectory = "/boot/home"; BPath outputDir;
fOutputDir.SetTo(defaultDirectory); if (find_directory(B_USER_DIRECTORY, &outputDir) != B_OK)
outputDir.SetTo("/boot/home");
fOutputDir.SetTo(outputDir.Path());
fMenuBar = new BMenuBar("menubar"); fMenuBar = new BMenuBar("menubar");
_CreateMenu(); _CreateMenu();
@ -165,7 +169,7 @@ MediaConverterWindow::MediaConverterWindow(BRect frame)
fDestButton = new BButton(B_TRANSLATE("Output folder"), fDestButton = new BButton(B_TRANSLATE("Output folder"),
new BMessage(OUTPUT_FOLDER_MESSAGE)); new BMessage(OUTPUT_FOLDER_MESSAGE));
BAlignment labelAlignment(be_control_look->DefaultLabelAlignment()); BAlignment labelAlignment(be_control_look->DefaultLabelAlignment());
fOutputFolder = new BStringView(NULL, defaultDirectory); fOutputFolder = new BStringView(NULL, outputDir.Path());
fOutputFolder->SetExplicitAlignment(labelAlignment); fOutputFolder->SetExplicitAlignment(labelAlignment);
// start/end duration // start/end duration