From 73e65d4da8432f40504f9eee71b0f193fa678d77 Mon Sep 17 00:00:00 2001 From: Matthew Wilber Date: Sat, 25 Oct 2003 15:35:54 +0000 Subject: [PATCH] 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 --- src/kits/translation/TranslationUtils.cpp | 26 ++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/kits/translation/TranslationUtils.cpp b/src/kits/translation/TranslationUtils.cpp index 3418c8d5b7..84cd08ec7f 100644 --- a/src/kits/translation/TranslationUtils.cpp +++ b/src/kits/translation/TranslationUtils.cpp @@ -31,6 +31,7 @@ // DEALINGS IN THE SOFTWARE. /*****************************************************************************/ #include +#include #include #include #include @@ -41,6 +42,8 @@ #include #include #include +#include +#include // --------------------------------------------------------------- // 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;