Changed TranslationUtils' manor of handling relative paths to match how Be's TranslationUtils handles them. Before, relative paths had the current directory as the base, now, relative paths use the folder containing the running application as the base. This issue prevented programs like Eden from loading properly with the OpenBeOS Translation Kit.

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5162 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Matthew Wilber 2003-10-25 15:35:54 +00:00
parent cdc2ad89b1
commit 73e65d4da8

View File

@ -31,6 +31,7 @@
// DEALINGS IN THE SOFTWARE.
/*****************************************************************************/
#include <Application.h>
#include <Roster.h>
#include <Bitmap.h>
#include <BitmapStream.h>
#include <File.h>
@ -41,6 +42,8 @@
#include <TranslatorFormats.h>
#include <TranslatorRoster.h>
#include <TranslationUtils.h>
#include <Entry.h>
#include <Path.h>
// ---------------------------------------------------------------
// Constructor
@ -254,7 +257,28 @@ BTranslationUtils::GetBitmap(uint32 type, const char *kName,
BBitmap *
BTranslationUtils::GetBitmapFile(const char *kName, BTranslatorRoster *roster)
{
BFile bitmapFile(kName, B_READ_ONLY);
if (!be_app || !kName || kName[0] == '\0')
return NULL;
BPath path;
if (kName[0] != '/') {
// If kName is a relative path, use the path of the application's
// executable as the base for the relative path
app_info info;
if (be_app->GetAppInfo(&info) != B_OK)
return NULL;
BEntry appRef(&info.ref);
if (path.SetTo(&appRef) != B_OK)
return NULL;
if (path.GetParent(&path) != B_OK)
return NULL;
if (path.Append(kName) != B_OK)
return NULL;
} else if (path.SetTo(kName) != B_OK)
return NULL;
BFile bitmapFile(path.Path(), B_READ_ONLY);
if (bitmapFile.InitCheck() != B_OK)
return NULL;