[haiku-commits] haiku: hrev46857 - src/apps/packageinstaller

  • From: superstippi@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Tue, 11 Feb 2014 23:19:22 +0100 (CET)

hrev46857 adds 7 changesets to branch 'master'
old head: 5b10d763d0da84a6f0cb07c610eb25df776273b2
new head: be94359ce4b915a7cd77b2959f462a6eb5d4eec9
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=be94359+%5E5b10d76

----------------------------------------------------------------------------

bdcd6af: PackageInstaller: Cleanup and code simplification

4450737: PackageInstaller: More cleanup and code simplifications

79350dd: PackageInstaller: Yet more cleanup and code simplifications

3421284: PackageImageViewer: Re-use B_QUIT_REQUESTED

6568820: PackageInstaller: Refactoring and cleanup
  
   * Extraced common base class BlockingWindow from PackageTextViewer and
     PackageImagerViewer.
   * Use layouted version of PackageTextViewer.
   * Center ReadMe on screen.
   * Apply margins around the text view.

ad1c3c4: PackageTextViewer: Fix include position

be94359: PackageItem: Fixed rewriting item paths
  
   * The version of BString::Replace() that was used takes the offset at which
     replacing should start, not the number of replacements. So did this ever
     work? Use ReplaceFirst() instead.
   * Address the performance issues which Pawel commented on, plus some more.
   * I've left some debug output in the code (commented out), since I want to
     work on this some more. For example, I noticed that GoBe Productive puts
     files into /boot/beos/...

                                      [ Stephan Aßmus <superstippi@xxxxxx> ]

----------------------------------------------------------------------------

11 files changed, 371 insertions(+), 425 deletions(-)
src/apps/packageinstaller/BlockingWindow.cpp     |  92 ++++++++
src/apps/packageinstaller/BlockingWindow.h       |  32 +++
.../packageinstaller/InstalledPackageInfo.cpp    |  17 +-
src/apps/packageinstaller/InstalledPackageInfo.h |  95 ++++----
src/apps/packageinstaller/Jamfile                |   1 +
src/apps/packageinstaller/PackageImageViewer.cpp | 103 ++-------
src/apps/packageinstaller/PackageImageViewer.h   |  42 ++--
src/apps/packageinstaller/PackageItem.cpp        |  67 +++---
src/apps/packageinstaller/PackageTextViewer.cpp  | 216 +++++--------------
src/apps/packageinstaller/PackageTextViewer.h    |  24 +--
src/apps/packageinstaller/main.cpp               | 107 +++++----

############################################################################

Commit:      bdcd6afc18ab546a2caf12c4bd56ca62555ff954
URL:         http://cgit.haiku-os.org/haiku/commit/?id=bdcd6af
Author:      Stephan Aßmus <superstippi@xxxxxx>
Date:        Tue Feb 11 21:02:29 2014 UTC

PackageInstaller: Cleanup and code simplification

----------------------------------------------------------------------------

diff --git a/src/apps/packageinstaller/main.cpp 
b/src/apps/packageinstaller/main.cpp
index 31ef508..e228f5a 100644
--- a/src/apps/packageinstaller/main.cpp
+++ b/src/apps/packageinstaller/main.cpp
@@ -21,32 +21,37 @@
 
 #include <stdio.h>
 
+
 #undef B_TRANSLATION_CONTEXT
 #define B_TRANSLATION_CONTEXT "Packageinstaller main"
 
+
 class PackageInstaller : public BApplication {
-       public:
-               PackageInstaller();
-               ~PackageInstaller();
+public:
+                                                               
PackageInstaller();
+       virtual                                         ~PackageInstaller();
 
-               void RefsReceived(BMessage *msg);
-               void ArgvReceived(int32 argc, char **argv);
-               void ReadyToRun();
+       virtual void                            RefsReceived(BMessage* message);
+       virtual void                            ArgvReceived(int32 argc, char** 
argv);
+       virtual void                            ReadyToRun();
 
-               void MessageReceived(BMessage *msg);
+       virtual void                            MessageReceived(BMessage* 
message);
 
-       private:
-               BFilePanel      *fOpen;
-               uint32          fWindowCount;
+private:
+                       void                            _NewWindow(const 
entry_ref* ref);
+
+private:
+                       BFilePanel*                     fOpenPanel;
+                       uint32                          fWindowCount;
 };
 
 
 PackageInstaller::PackageInstaller()
-       :       BApplication("application/x-vnd.Haiku-PackageInstaller"),
-       fOpen(NULL),
+       :
+       BApplication("application/x-vnd.Haiku-PackageInstaller"),
+       fOpenPanel(new BFilePanel(B_OPEN_PANEL)),
        fWindowCount(0)
 {
-       fOpen = new BFilePanel(B_OPEN_PANEL);
 }
 
 
@@ -60,84 +65,72 @@ PackageInstaller::ReadyToRun()
 {
        // We're ready to run - if no windows are yet visible, this means that
        // we should show a open panel
-       if (fWindowCount == 0) {
-               fOpen->Show();
-       }
+       if (fWindowCount == 0)
+               fOpenPanel->Show();
 }
 
 
 void
-PackageInstaller::RefsReceived(BMessage *msg)
+PackageInstaller::RefsReceived(BMessage* message)
 {
-       uint32 type;
-       int32 i, count;
-       status_t ret = msg->GetInfo("refs", &type, &count);
-       if (ret != B_OK || type != B_REF_TYPE)
-               return;
-
        entry_ref ref;
-       PackageWindow *iter;
-       for (i = 0; i < count; i++) {
-               if (msg->FindRef("refs", i, &ref) == B_OK) {
-                       iter = new PackageWindow(&ref);
-                       fWindowCount++;
-                       iter->Show();
-               }
-       }
+       for (int32 i = 0; message->FindRef("refs", i, &ref) == B_OK; i++)
+               _NewWindow(&ref);
 }
 
 
 void
-PackageInstaller::ArgvReceived(int32 argc, char **argv)
+PackageInstaller::ArgvReceived(int32 argc, char** argv)
 {
-       int i;
-       BPath path;
-       entry_ref ref;
-       status_t ret = B_OK;
-       PackageWindow *iter = 0;
-
-       for (i = 1; i < argc; i++) {
+       for (int i = 1; i < argc; i++) {
+               BPath path;
                if (path.SetTo(argv[i]) != B_OK) {
-                       fprintf(stderr,
-                                       B_TRANSLATE("Error! \"%s\" is not a 
valid path.\n"),
-                                       argv[i]);
+                       fprintf(stderr, B_TRANSLATE("Error! \"%s\" is not a 
valid path.\n"),
+                               argv[i]);
                        continue;
                }
 
-               ret = get_ref_for_path(path.Path(), &ref);
+               entry_ref ref;
+               status_t ret = get_ref_for_path(path.Path(), &ref);
                if (ret != B_OK) {
-                       fprintf(stderr,
-                                       B_TRANSLATE("Error (%s)! Could not open 
\"%s\".\n"),
-                                       strerror(ret), argv[i]);
+                       fprintf(stderr, B_TRANSLATE("Error (%s)! Could not open 
\"%s\".\n"),
+                               strerror(ret), argv[i]);
                        continue;
                }
 
-               iter = new PackageWindow(&ref);
-               fWindowCount++;
-               iter->Show();
+               _NewWindow(&ref);
        }
 }
 
 
 void
-PackageInstaller::MessageReceived(BMessage *msg)
+PackageInstaller::MessageReceived(BMessage* message)
 {
-       switch (msg->what) {
+       switch (message->what) {
                case P_WINDOW_QUIT:
                        fWindowCount--;
+                       // fall through
                case B_CANCEL:
-                       if (fWindowCount == 0) {
-                               BAutolock lock(this);
-                               if (lock.IsLocked())
-                                       Quit();
-                       }
+                       if (fWindowCount == 0)
+                               PostMessage(B_QUIT_REQUESTED);
                        break;
+
                default:
-                       BApplication::MessageReceived(msg);
+                       BApplication::MessageReceived(message);
        }
 }
 
 
+void
+PackageInstaller::_NewWindow(const entry_ref* ref)
+{
+       PackageWindow* window = new PackageWindow(ref);
+       window->Show();
+
+       fWindowCount++;
+}
+
+
 int
 main(void)
 {

############################################################################

Commit:      4450737441e20843ab545054d9a2f4accd2242b0
URL:         http://cgit.haiku-os.org/haiku/commit/?id=4450737
Author:      Stephan Aßmus <superstippi@xxxxxx>
Date:        Tue Feb 11 21:14:15 2014 UTC

PackageInstaller: More cleanup and code simplifications

----------------------------------------------------------------------------

diff --git a/src/apps/packageinstaller/InstalledPackageInfo.cpp 
b/src/apps/packageinstaller/InstalledPackageInfo.cpp
index f8f22b3..c99f63a 100644
--- a/src/apps/packageinstaller/InstalledPackageInfo.cpp
+++ b/src/apps/packageinstaller/InstalledPackageInfo.cpp
@@ -105,9 +105,10 @@ InstalledPackageInfo::InitCheck()
 
 status_t
 InstalledPackageInfo::SetTo(const char *packageName, const char *version, 
-               bool create)
+       bool create)
 {
        _ClearItemList();
+
        fCreate = create;
        fStatus = B_NO_INIT;
        fVersion = version;
@@ -179,8 +180,7 @@ InstalledPackageInfo::SetTo(const char *packageName, const 
char *version,
                        fInstalledItems.AddItem(new BString(itemPath)); // Or 
maybe BPath better?
                }
                fIsUpToDate = true;
-       }
-       else if (fStatus == B_ENTRY_NOT_FOUND) {
+       } else if (fStatus == B_ENTRY_NOT_FOUND) {
                if (create) {
                        fStatus = B_OK;
                        fIsUpToDate = false;
@@ -315,13 +315,8 @@ InstalledPackageInfo::Save()
 void
 InstalledPackageInfo::_ClearItemList()
 {
-       // Clear the items list
-       BString *iter;
-       uint32 i, count = fInstalledItems.CountItems();
-       for (i = 0; i < count; i++) {
-               iter = static_cast<BString *>(fInstalledItems.ItemAt(0));
-               fInstalledItems.RemoveItem((int32)0);
-               delete iter;
-       }
+       for (int32 i = fInstalledItems.CountItems() - 1; i >= 0; i--)
+               delete static_cast<BString*>(fInstalledItems.ItemAtFast(i));
+       fInstalledItems.MakeEmpty();
 }
 
diff --git a/src/apps/packageinstaller/InstalledPackageInfo.h 
b/src/apps/packageinstaller/InstalledPackageInfo.h
index e5c37a4..22819c3 100644
--- a/src/apps/packageinstaller/InstalledPackageInfo.h
+++ b/src/apps/packageinstaller/InstalledPackageInfo.h
@@ -5,8 +5,8 @@
  * Author:
  *             Łukasz 'Sil2100' Zemczak <sil2100@xxxxxxxxxxxxx>
  */
-#ifndef INSTALLEDPACKAGEINFO_H
-#define INSTALLEDPACKAGEINFO_H
+#ifndef INSTALLED_PACKAGE_INFO_H
+#define INSTALLED_PACKAGE_INFO_H
 
 #include <File.h>
 #include <String.h>
@@ -25,51 +25,60 @@ extern const char * kPackagesDir;
 
 // Useful function for fetching the package name and version without parsing 
all
 // other data
-status_t info_get_package_name(const char *filename, BString &name);
-status_t info_get_package_version(const char *filename, BString &name);
+status_t info_get_package_name(const char* filename, BString& name);
+status_t info_get_package_version(const char* filename, BString& name);
 
 
 class InstalledPackageInfo {
-       public:
-               InstalledPackageInfo();
-               InstalledPackageInfo(const char *packageName, const char 
*version = NULL, 
-                       bool create = false);
-               ~InstalledPackageInfo();
-
-               status_t InitCheck();
-               status_t SetTo(const char *packageName, const char *version = 
NULL, 
-                       bool create = false);
-
-               void SetName(const char *name) { fName = name; }
-               const char *GetName() { return fName.String(); }
-               void SetDescription(const char *description) { fDescription = 
description; }
-               const char *GetDescription() { return fDescription.String(); }
-               //void SetVersion(const char *version) { fVersion = version; }
-               const char *GetVersion() { return fVersion.String(); }
-               void SetSpaceNeeded(uint64 size) { fSpaceNeeded = size; }
-               uint64 GetSpaceNeeded() { return fSpaceNeeded; }
-
-               status_t AddItem(const char *itemName);
-
-               status_t Uninstall();
-               status_t Save();
-
-       private:
-               void _ClearItemList();
-
-               status_t fStatus;
-               bool fIsUpToDate;
-               bool fCreate;
-
-               BString fName;
-               BString fDescription;
-               BString fVersion;
-               uint64 fSpaceNeeded;
-               BList fInstalledItems;
-
-               BPath fPathToInfo;
+public:
+                                                               
InstalledPackageInfo();
+                                                               
InstalledPackageInfo(const char* packageName,
+                                                                       const 
char* version = NULL, 
+                                                                       bool 
create = false);
+                                                               
~InstalledPackageInfo();
+
+                       status_t                        InitCheck();
+                       status_t                        SetTo(const char* 
packageName,
+                                                                       const 
char* version = NULL, 
+                                                                       bool 
create = false);
+
+                       void                            SetName(const char* 
name)
+                                                                       { fName 
= name; }
+                       const char*                     Name()
+                                                                       { 
return fName.String(); }
+                       void                            SetDescription(const 
char* description)
+                                                                       { 
fDescription = description; }
+                       const char*                     Description()
+                                                                       { 
return fDescription.String(); }
+                       const char*                     Version()
+                                                                       { 
return fVersion.String(); }
+                       void                            SetSpaceNeeded(uint64 
size)
+                                                                       { 
fSpaceNeeded = size; }
+                       uint64                          SpaceNeeded()
+                                                                       { 
return fSpaceNeeded; }
+
+                       status_t                        AddItem(const char* 
itemName);
+
+                       status_t                        Uninstall();
+                       status_t                        Save();
+
+private:
+                       void                            _ClearItemList();
+
+private:
+                       status_t                        fStatus;
+                       bool                            fIsUpToDate;
+                       bool                            fCreate;
+
+                       BString                         fName;
+                       BString                         fDescription;
+                       BString                         fVersion;
+                       uint64                          fSpaceNeeded;
+                       BList                           fInstalledItems;
+
+                       BPath                           fPathToInfo;
 };
 
 
-#endif
+#endif // INSTALLED_PACKAGE_INFO_H
 

############################################################################

Commit:      79350dde31b8053910b2a33772d7095695f548af
URL:         http://cgit.haiku-os.org/haiku/commit/?id=79350dd
Author:      Stephan Aßmus <superstippi@xxxxxx>
Date:        Tue Feb 11 21:25:42 2014 UTC

PackageInstaller: Yet more cleanup and code simplifications

----------------------------------------------------------------------------

diff --git a/src/apps/packageinstaller/PackageImageViewer.cpp 
b/src/apps/packageinstaller/PackageImageViewer.cpp
index ea3e512..e204832 100644
--- a/src/apps/packageinstaller/PackageImageViewer.cpp
+++ b/src/apps/packageinstaller/PackageImageViewer.cpp
@@ -25,21 +25,19 @@ enum {
 };
 
 
-ImageView::ImageView(BPositionIO *image)
+ImageView::ImageView(BPositionIO* imageIO)
        :
        BView(BRect(0, 0, 1, 1), "image_view", B_FOLLOW_NONE, B_WILL_DRAW),
-       fSuccess(true)
+       fImage(NULL)
 {
-       if (!image) {
-               fSuccess = false;
+       if (imageIO == NULL)
                return;
-       }
+
        // Initialize and translate the image
-       BTranslatorRoster *roster = BTranslatorRoster::Default();
+       BTranslatorRoster* roster = BTranslatorRoster::Default();
        BBitmapStream stream;
-       if (roster->Translate(image, NULL, NULL, &stream, B_TRANSLATOR_BITMAP)
-                       < B_OK) {
-               fSuccess = false;
+       if (roster->Translate(imageIO, NULL, NULL, &stream, B_TRANSLATOR_BITMAP)
+                       != B_OK) {
                return;
        }
        stream.DetachBitmap(&fImage);
@@ -48,13 +46,14 @@ ImageView::ImageView(BPositionIO *image)
 
 ImageView::~ImageView()
 {
+       delete fImage;
 }
 
 
 void
 ImageView::AttachedToWindow()
 {
-       if (!fSuccess) {
+       if (fImage == NULL) {
                ResizeTo(75, 75);
                return;
        }
@@ -77,12 +76,12 @@ ImageView::AttachedToWindow()
 void
 ImageView::Draw(BRect updateRect)
 {
-       if (fSuccess)
+       if (fImage != NULL)
                DrawBitmapAsync(fImage, Bounds());
        else {
-               float length = StringWidth(B_TRANSLATE("Image not loaded 
correctly"));
-               DrawString(B_TRANSLATE("Image not loaded correctly"),
-                       BPoint((Bounds().Width() - length) / 2.0f, 30.0f));
+               const char* message = B_TRANSLATE("Image not loaded correctly");
+               float width = StringWidth(message);
+               DrawString(message, BPoint((Bounds().Width() - width) / 2.0f, 
30.0f));
        }
 }
 
@@ -90,7 +89,7 @@ ImageView::Draw(BRect updateRect)
 void
 ImageView::MouseUp(BPoint point)
 {
-       BWindow *parent = Window();
+       BWindow* parent = Window();
        if (parent)
                parent->PostMessage(P_MSG_CLOSE);
 }
@@ -99,12 +98,12 @@ ImageView::MouseUp(BPoint point)
 // #pragma mark -
 
 
-PackageImageViewer::PackageImageViewer(BPositionIO *image)
+PackageImageViewer::PackageImageViewer(BPositionIO* imageIO)
        :
        BWindow(BRect(100, 100, 100, 100), "", B_MODAL_WINDOW,
                B_NOT_ZOOMABLE | B_NOT_RESIZABLE | B_NOT_CLOSABLE)
 {
-       fBackground = new ImageView(image);
+       fBackground = new ImageView(imageIO);
        AddChild(fBackground);
 
        ResizeTo(fBackground->Bounds().Width(), fBackground->Bounds().Height());
@@ -112,7 +111,7 @@ PackageImageViewer::PackageImageViewer(BPositionIO *image)
        BScreen screen(this);
        BRect frame = screen.Frame();
        MoveTo((frame.Width() - Bounds().Width()) / 2.0f,
-                       (frame.Height() - Bounds().Height()) / 2.0f);
+               (frame.Height() - Bounds().Height()) / 2.0f);
 }
 
 
@@ -122,6 +121,19 @@ PackageImageViewer::~PackageImageViewer()
 
 
 void
+PackageImageViewer::MessageReceived(BMessage* message)
+{
+       if (message->what == P_MSG_CLOSE) {
+               if (fSemaphore >= B_OK) {
+                       delete_sem(fSemaphore);
+                       fSemaphore = -1;
+               }
+       } else
+               BWindow::MessageReceived(message);
+}
+
+
+void
 PackageImageViewer::Go()
 {
        // Since this class can be thought of as a modified BAlert window, no 
use
@@ -133,11 +145,14 @@ PackageImageViewer::Go()
                return;
        }
 
-       BWindow *parent =
-               dynamic_cast<BWindow 
*>(BLooper::LooperForThread(find_thread(NULL)));
+       thread_id callingThread = find_thread(NULL);
+       BWindow* window = dynamic_cast<BWindow*>(BLooper::LooperForThread(
+               callingThread));
        Show();
 
-       if (parent) {
+       if (window != NULL) {
+               // Make sure calling window thread, which is blocked here, is 
updating
+               // the window from time to time.
                status_t ret;
                for (;;) {
                        do {
@@ -146,10 +161,9 @@ PackageImageViewer::Go()
 
                        if (ret == B_BAD_SEM_ID)
                                break;
-                       parent->UpdateIfNeeded();
+                       window->UpdateIfNeeded();
                }
-       }
-       else {
+       } else {
                // Since there are no spinlocks, wait until the semaphore is 
free
                while (acquire_sem(fSemaphore) == B_INTERRUPTED) {
                }
@@ -159,16 +173,3 @@ PackageImageViewer::Go()
                Quit();
 }
 
-
-void
-PackageImageViewer::MessageReceived(BMessage *msg)
-{
-       if (msg->what == P_MSG_CLOSE) {
-               if (fSemaphore >= B_OK) {
-                       delete_sem(fSemaphore);
-                       fSemaphore = -1;
-               }
-       } else
-               BWindow::MessageReceived(msg);
-}
-
diff --git a/src/apps/packageinstaller/PackageImageViewer.h 
b/src/apps/packageinstaller/PackageImageViewer.h
index ec6aa69..9230ff9 100644
--- a/src/apps/packageinstaller/PackageImageViewer.h
+++ b/src/apps/packageinstaller/PackageImageViewer.h
@@ -5,8 +5,8 @@
  * Author:
  *             Łukasz 'Sil2100' Zemczak <sil2100@xxxxxxxxxxxxx>
  */
-#ifndef PACKAGEIMAGEVIEWER_H
-#define PACKAGEIMAGEVIEWER_H
+#ifndef PACKAGE_IMAGE_VIEWER_H
+#define PACKAGE_IMAGE_VIEWER_H
 
 #include <Window.h>
 #include <View.h>
@@ -16,35 +16,34 @@
 
 
 class ImageView : public BView {
-       public:
-               ImageView(BPositionIO *image);
-               ~ImageView();
+public:
+                                                               
ImageView(BPositionIO* image);
+       virtual                                         ~ImageView();
 
-               void AttachedToWindow();
-               void Draw(BRect updateRect);
-               void MouseUp(BPoint point);
+       virtual void                            AttachedToWindow();
+       virtual void                            Draw(BRect updateRect);
+       virtual void                            MouseUp(BPoint point);
 
-       private:
-               BBitmap *fImage;
-               bool fSuccess;
+private:
+                       BBitmap*                        fImage;
 };
 
 
 class PackageImageViewer : public BWindow {
-       public:
-               PackageImageViewer(BPositionIO *image);
-               ~PackageImageViewer();
+public:
+                                                               
PackageImageViewer(BPositionIO* image);
+       virtual                                         ~PackageImageViewer();
                
-               void Go();
-
-               void MessageReceived(BMessage *msg);
+       virtual void                            MessageReceived(BMessage* 
message);
                
-       private:
-               ImageView *fBackground;
+                       void                            Go();
+
+private:
+                       ImageView*                      fBackground;
 
-               sem_id fSemaphore;
+                       sem_id                          fSemaphore;
 };
 
 
-#endif
+#endif // PACKAGE_IMAGE_VIEWER_H
 

############################################################################

Commit:      34212840445356ceabcbbef831d35f8563066735
URL:         http://cgit.haiku-os.org/haiku/commit/?id=3421284
Author:      Stephan Aßmus <superstippi@xxxxxx>
Date:        Tue Feb 11 21:29:03 2014 UTC

PackageImageViewer: Re-use B_QUIT_REQUESTED

----------------------------------------------------------------------------

diff --git a/src/apps/packageinstaller/PackageImageViewer.cpp 
b/src/apps/packageinstaller/PackageImageViewer.cpp
index e204832..25a241b 100644
--- a/src/apps/packageinstaller/PackageImageViewer.cpp
+++ b/src/apps/packageinstaller/PackageImageViewer.cpp
@@ -20,10 +20,6 @@
 #undef B_TRANSLATION_CONTEXT
 #define B_TRANSLATION_CONTEXT "PackageImageViewer"
 
-enum {
-       P_MSG_CLOSE = 'pmic'
-};
-
 
 ImageView::ImageView(BPositionIO* imageIO)
        :
@@ -89,9 +85,9 @@ ImageView::Draw(BRect updateRect)
 void
 ImageView::MouseUp(BPoint point)
 {
-       BWindow* parent = Window();
-       if (parent)
-               parent->PostMessage(P_MSG_CLOSE);
+       BWindow* window = Window();
+       if (window != NULL)
+               window->PostMessage(B_QUIT_REQUESTED);
 }
 
 
@@ -120,16 +116,14 @@ PackageImageViewer::~PackageImageViewer()
 }
 
 
-void
-PackageImageViewer::MessageReceived(BMessage* message)
+bool
+PackageImageViewer::QuitRequested()
 {
-       if (message->what == P_MSG_CLOSE) {
-               if (fSemaphore >= B_OK) {
-                       delete_sem(fSemaphore);
-                       fSemaphore = -1;
-               }
-       } else
-               BWindow::MessageReceived(message);
+       if (fSemaphore >= B_OK) {
+               delete_sem(fSemaphore);
+               fSemaphore = -1;
+       }
+       return true;
 }
 
 
diff --git a/src/apps/packageinstaller/PackageImageViewer.h 
b/src/apps/packageinstaller/PackageImageViewer.h
index 9230ff9..196f222 100644
--- a/src/apps/packageinstaller/PackageImageViewer.h
+++ b/src/apps/packageinstaller/PackageImageViewer.h
@@ -34,7 +34,7 @@ public:
                                                                
PackageImageViewer(BPositionIO* image);
        virtual                                         ~PackageImageViewer();
                
-       virtual void                            MessageReceived(BMessage* 
message);
+       virtual bool                            QuitRequested();
                
                        void                            Go();
 

############################################################################

Commit:      65688206345d2a67d38526281db9a0f50941b508
URL:         http://cgit.haiku-os.org/haiku/commit/?id=6568820
Author:      Stephan Aßmus <superstippi@xxxxxx>
Date:        Tue Feb 11 22:06:37 2014 UTC

PackageInstaller: Refactoring and cleanup

 * Extraced common base class BlockingWindow from PackageTextViewer and
   PackageImagerViewer.
 * Use layouted version of PackageTextViewer.
 * Center ReadMe on screen.
 * Apply margins around the text view.

----------------------------------------------------------------------------

diff --git a/src/apps/packageinstaller/BlockingWindow.cpp 
b/src/apps/packageinstaller/BlockingWindow.cpp
new file mode 100644
index 0000000..978d355
--- /dev/null
+++ b/src/apps/packageinstaller/BlockingWindow.cpp
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2007-2014, Haiku, Inc.
+ * Distributed under the terms of the MIT license.
+ *
+ * Author:
+ *             Łukasz 'Sil2100' Zemczak <sil2100@xxxxxxxxxxxxx>
+ *             Stephan Aßmus <superstippi@xxxxxx>
+ */
+
+
+#include "PackageImageViewer.h"
+
+
+BlockingWindow::BlockingWindow(BRect frame, const char* title, uint32 flags)
+       :
+       BWindow(frame, title, B_MODAL_WINDOW,
+               B_NOT_ZOOMABLE | B_NOT_RESIZABLE | B_NOT_CLOSABLE | flags),
+       fSemaphore(-1),
+       fReturnValue(0)
+{
+}
+
+
+BlockingWindow::~BlockingWindow()
+{
+}
+
+
+bool
+BlockingWindow::QuitRequested()
+{
+       ReleaseSem(0);
+       return true;
+}
+
+
+int32
+BlockingWindow::Go()
+{
+       int32 returnValue = 0;
+
+       // Since this class can be thought of as a modified BAlert window, no 
use
+       // to reinvent a well fledged wheel. This concept has been borrowed from
+       // the current BAlert implementation
+       fSemaphore = create_sem(0, "PackageInstaller BlockingWindow");
+       if (fSemaphore < B_OK) {
+               Quit();
+               return returnValue;
+       }
+
+       thread_id callingThread = find_thread(NULL);
+       BWindow* window = dynamic_cast<BWindow*>(BLooper::LooperForThread(
+               callingThread));
+       Show();
+
+       if (window != NULL) {
+               // Make sure calling window thread, which is blocked here, is 
updating
+               // the window from time to time.
+               status_t ret;
+               for (;;) {
+                       do {
+                               ret = acquire_sem_etc(fSemaphore, 1, 
B_RELATIVE_TIMEOUT, 50000);
+                       } while (ret == B_INTERRUPTED);
+
+                       if (ret == B_BAD_SEM_ID)
+                               break;
+                       window->UpdateIfNeeded();
+               }
+       } else {
+               // Since there are no spinlocks, wait until the semaphore is 
free
+               while (acquire_sem(fSemaphore) == B_INTERRUPTED) {
+               }
+       }
+
+       returnValue = fReturnValue;
+
+       if (Lock())
+               Quit();
+
+       return returnValue;
+}
+
+
+void
+BlockingWindow::ReleaseSem(int32 returnValue)
+{
+       if (fSemaphore >= B_OK) {
+               delete_sem(fSemaphore);
+               fSemaphore = -1;
+               fReturnValue = returnValue;
+       }
+}
diff --git a/src/apps/packageinstaller/BlockingWindow.h 
b/src/apps/packageinstaller/BlockingWindow.h
new file mode 100644
index 0000000..717fb76
--- /dev/null
+++ b/src/apps/packageinstaller/BlockingWindow.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2014, Stephan Aßmus <superstippi@xxxxxx>
+ * All rights reserved. Distributed under the terms of the MIT license.
+ */
+#ifndef BLOCKING_WINDOW_H
+#define BLOCKING_WINDOW_H
+
+
+#include <Window.h>
+
+
+class BlockingWindow : public BWindow {
+public:
+                                                               
BlockingWindow(BRect frame,
+                                                                       const 
char* title, uint32 flags = 0);
+       virtual                                         ~BlockingWindow();
+               
+       virtual bool                            QuitRequested();
+               
+       virtual int32                           Go();
+
+protected:
+                       void                            ReleaseSem(int32 
returnValue);
+
+private:
+                       sem_id                          fSemaphore;
+                       int32                           fReturnValue;
+};
+
+
+#endif // BLOCKING_WINDOW_H
+
diff --git a/src/apps/packageinstaller/Jamfile 
b/src/apps/packageinstaller/Jamfile
index 26ddba7..a8b6cdb 100644
--- a/src/apps/packageinstaller/Jamfile
+++ b/src/apps/packageinstaller/Jamfile
@@ -10,6 +10,7 @@ Includes [ FGristFiles PackageItem.cpp ]
 
 Application PackageInstaller :
        main.cpp
+       BlockingWindow.cpp
        PackageWindow.cpp
        PackageView.cpp
        PackageInfo.cpp
diff --git a/src/apps/packageinstaller/PackageImageViewer.cpp 
b/src/apps/packageinstaller/PackageImageViewer.cpp
index 25a241b..c486b51 100644
--- a/src/apps/packageinstaller/PackageImageViewer.cpp
+++ b/src/apps/packageinstaller/PackageImageViewer.cpp
@@ -96,8 +96,7 @@ ImageView::MouseUp(BPoint point)
 
 PackageImageViewer::PackageImageViewer(BPositionIO* imageIO)
        :
-       BWindow(BRect(100, 100, 100, 100), "", B_MODAL_WINDOW,
-               B_NOT_ZOOMABLE | B_NOT_RESIZABLE | B_NOT_CLOSABLE)
+       BlockingWindow(BRect(100, 100, 100, 100), "")
 {
        fBackground = new ImageView(imageIO);
        AddChild(fBackground);
@@ -110,60 +109,3 @@ PackageImageViewer::PackageImageViewer(BPositionIO* 
imageIO)
                (frame.Height() - Bounds().Height()) / 2.0f);
 }
 
-
-PackageImageViewer::~PackageImageViewer()
-{
-}
-
-
-bool
-PackageImageViewer::QuitRequested()
-{
-       if (fSemaphore >= B_OK) {
-               delete_sem(fSemaphore);
-               fSemaphore = -1;
-       }
-       return true;
-}
-
-
-void
-PackageImageViewer::Go()
-{
-       // Since this class can be thought of as a modified BAlert window, no 
use
-       // to reinvent a well fledged wheel. This concept has been borrowed from
-       // the current BAlert implementation
-       fSemaphore = create_sem(0, "ImageViewer");
-       if (fSemaphore < B_OK) {
-               Quit();
-               return;
-       }
-
-       thread_id callingThread = find_thread(NULL);
-       BWindow* window = dynamic_cast<BWindow*>(BLooper::LooperForThread(
-               callingThread));
-       Show();
-
-       if (window != NULL) {
-               // Make sure calling window thread, which is blocked here, is 
updating
-               // the window from time to time.
-               status_t ret;
-               for (;;) {
-                       do {
-                               ret = acquire_sem_etc(fSemaphore, 1, 
B_RELATIVE_TIMEOUT, 50000);
-                       } while (ret == B_INTERRUPTED);
-
-                       if (ret == B_BAD_SEM_ID)
-                               break;
-                       window->UpdateIfNeeded();
-               }
-       } else {
-               // Since there are no spinlocks, wait until the semaphore is 
free
-               while (acquire_sem(fSemaphore) == B_INTERRUPTED) {
-               }
-       }
-
-       if (Lock())
-               Quit();
-}
-
diff --git a/src/apps/packageinstaller/PackageImageViewer.h 
b/src/apps/packageinstaller/PackageImageViewer.h
index 196f222..5f0484c 100644
--- a/src/apps/packageinstaller/PackageImageViewer.h
+++ b/src/apps/packageinstaller/PackageImageViewer.h
@@ -8,11 +8,11 @@
 #ifndef PACKAGE_IMAGE_VIEWER_H
 #define PACKAGE_IMAGE_VIEWER_H
 
-#include <Window.h>
 #include <View.h>
 #include <Bitmap.h>
 #include <DataIO.h>
 
+#include "BlockingWindow.h"
 
 
 class ImageView : public BView {
@@ -29,19 +29,12 @@ private:
 };
 
 
-class PackageImageViewer : public BWindow {
+class PackageImageViewer : public BlockingWindow {
 public:
                                                                
PackageImageViewer(BPositionIO* image);
-       virtual                                         ~PackageImageViewer();
                
-       virtual bool                            QuitRequested();
-               
-                       void                            Go();
-
 private:
                        ImageView*                      fBackground;
-
-                       sem_id                          fSemaphore;
 };
 
 
diff --git a/src/apps/packageinstaller/PackageTextViewer.cpp 
b/src/apps/packageinstaller/PackageTextViewer.cpp
index 482552b..6274aad 100644
--- a/src/apps/packageinstaller/PackageTextViewer.cpp
+++ b/src/apps/packageinstaller/PackageTextViewer.cpp
@@ -1,9 +1,10 @@
 /*
- * Copyright (c) 2007-2010, Haiku, Inc.
+ * Copyright (c) 2007-2014, Haiku, Inc.
  * Distributed under the terms of the MIT license.
  *
  * Author:
  *             Łukasz 'Sil2100' Zemczak <sil2100@xxxxxxxxxxxxx>
+ *             Stephan Aßmus <superstippi@xxxxxx>
  */
 
 
@@ -14,8 +15,7 @@
 #include <Locale.h>
 #include <ScrollView.h>
 
-#include <GroupLayout.h>
-#include <GroupLayoutBuilder.h>
+#include <LayoutBuilder.h>
 
 
 enum {
@@ -29,78 +29,30 @@ enum {
 
 PackageTextViewer::PackageTextViewer(const char *text, bool disclaimer)
        :
-       BWindow(BRect(125, 125, 675, 475), B_TRANSLATE("Disclaimer"),
-               B_MODAL_WINDOW, B_NOT_ZOOMABLE | B_NOT_RESIZABLE | 
B_NOT_CLOSABLE),
-       fValue(0)
+       BlockingWindow(BRect(125, 125, 675, 475), B_TRANSLATE("Disclaimer"),
+               B_AUTO_UPDATE_SIZE_LIMITS)
 {
        _InitView(text, disclaimer);
-}
-
-
-PackageTextViewer::~PackageTextViewer()
-{
-}
-
-
-int32
-PackageTextViewer::Go()
-{
-       // Since this class can be thought of as a modified BAlert window, no 
use
-       // to reinvent a well fledged wheel. This concept has been borrowed from
-       // the current BAlert implementation
-       fSemaphore = create_sem(0, "TextViewer");
-       if (fSemaphore < B_OK) {
-               Quit();
-               return B_ERROR;
-       }
-
-       BWindow *parent =
-               dynamic_cast<BWindow 
*>(BLooper::LooperForThread(find_thread(NULL)));
-       Show();
-
-       if (parent) {
-               status_t ret;
-               for (;;) {
-                       do {
-                               ret = acquire_sem_etc(fSemaphore, 1, 
B_RELATIVE_TIMEOUT, 50000);
-                       } while (ret == B_INTERRUPTED);
-
-                       if (ret == B_BAD_SEM_ID)
-                               break;
-                       parent->UpdateIfNeeded();
-               }
-       }
-       else {
-               // Since there are no spinlocks, wait until the semaphore is 
free
-               while (acquire_sem(fSemaphore) == B_INTERRUPTED) {
-               }
-       }
-
-       int32 value = fValue;
-       if (Lock())
-               Quit();
-
-       return value;
+       CenterOnScreen();
 }
 
 
 void
-PackageTextViewer::MessageReceived(BMessage *msg)
+PackageTextViewer::MessageReceived(BMessage* message)
 {
-       if (msg->what == P_MSG_ACCEPT) {
-               if (fSemaphore >= B_OK) {
-                       fValue = 1;
-                       delete_sem(fSemaphore);
-                       fSemaphore = -1;
-               }
-       } else if (msg->what == P_MSG_DECLINE) {
-               if (fSemaphore >= B_OK) {
-                       fValue = 0;
-                       delete_sem(fSemaphore);
-                       fSemaphore = -1;
-               }
-       } else
-               BWindow::MessageReceived(msg);
+       switch (message->what) {
+               case P_MSG_ACCEPT:
+                       ReleaseSem(1);
+                       break;
+
+               case P_MSG_DECLINE:
+                       ReleaseSem(0);
+                       break;
+
+               default:
+                       BWindow::MessageReceived(message);
+                       break;
+       }
 }
 
 
@@ -108,111 +60,50 @@ PackageTextViewer::MessageReceived(BMessage *msg)
 
 
 void
-PackageTextViewer::_InitView(const char *text, bool disclaimer)
+PackageTextViewer::_InitView(const char* text, bool disclaimer)
 {
-       fBackground = new BView(Bounds(), "background_view", 0, 0);
-       fBackground->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
+       BTextView* textView = new BTextView("text_view");
+       textView->MakeEditable(false);
+       textView->MakeSelectable(true);
+       float margin = ceilf(be_plain_font->Size());
+       textView->SetInsets(margin, margin, margin, margin);
+       BScrollView* scrollView = new BScrollView("scroll_view", textView, 0, 
false,
+               true);
 
-       BRect bounds;
-       BRect rect = Bounds();
-       if (disclaimer) {
-               BButton *button = new BButton(BRect(0, 0, 1, 1), "accept",
-                       B_TRANSLATE("Accept"), new BMessage(P_MSG_ACCEPT));
-               button->ResizeToPreferred();
-
-               bounds = button->Bounds();
-               rect.top = rect.bottom - bounds.bottom - 5.0f;
-               rect.left = rect.right - bounds.right - 5.0f;
-               rect.bottom = bounds.bottom;
-               rect.right = bounds.right;
-               button->MoveTo(rect.LeftTop());
-               button->MakeDefault(true);
-               fBackground->AddChild(button);
-
-               button = new BButton(BRect(0, 0, 1, 1), "decline",
-                       B_TRANSLATE("Decline"), new BMessage(P_MSG_DECLINE));
-               button->ResizeToPreferred();
-
-               bounds = button->Bounds();
-               rect.left -= bounds.right + 7.0f;
-               button->MoveTo(rect.LeftTop());
-               fBackground->AddChild(button);
-       } else {
-               BButton *button = new BButton(BRect(0, 0, 1, 1), "accept",
-                       B_TRANSLATE("Continue"), new BMessage(P_MSG_ACCEPT));
-               button->ResizeToPreferred();
-
-               bounds = button->Bounds();
-               rect.top = rect.bottom - bounds.bottom - 5.0f;
-               rect.left = rect.right - bounds.right - 5.0f;
-               rect.bottom = bounds.bottom;
-               rect.right = bounds.right;
-               button->MoveTo(rect.LeftTop());
-               button->MakeDefault(true);
-               fBackground->AddChild(button);
-       }
-
-       bounds = Bounds().InsetBySelf(5.0f, 5.0f);
-       bounds.bottom = rect.top - 6.0f;
-       bounds.right -= B_V_SCROLL_BAR_WIDTH;
-
-       fText = new BTextView(bounds, "text_view", BRect(0, 0, bounds.Width(),
-               bounds.Height()), B_FOLLOW_NONE, B_WILL_DRAW);
-       fText->MakeEditable(false);
-       fText->MakeSelectable(true);
-       fText->SetText(text);
-
-       BScrollView *scroll = new BScrollView("scroll_view", fText,
-               B_FOLLOW_LEFT | B_FOLLOW_TOP, 0, false, true);
-
-       fBackground->AddChild(scroll);
-
-       AddChild(fBackground);
-}
-
-
-/*void
-PackageTextViewer::_InitView(const char *text, bool disclaimer)
-{
-       SetLayout(new BGroupLayout(B_HORIZONTAL));
-
-       fText = new BTextView(BRect(0, 0, 1, 1), "text_view", BRect(0, 0, 1, 1),
-                       B_FOLLOW_NONE, B_WILL_DRAW | B_SUPPORTS_LAYOUT);
-       fText->MakeEditable(false);
-       fText->MakeSelectable(true);
-       BScrollView *scroll = new BScrollView("scroll_view", fText,
-                       B_FOLLOW_LEFT | B_FOLLOW_TOP, 0, false, true);
+       BButton* defaultButton;
 
        if (disclaimer) {
-               BButton *accept = new BButton("accept", B_TRANSLATE("Accept"),
-                               new BMessage(P_MSG_ACCEPT));
+               defaultButton = new BButton("accept", B_TRANSLATE("Accept"),
+                       new BMessage(P_MSG_ACCEPT));
 
-               BButton *decline = new BButton("decline", 
B_TRANSLATE("Decline"),
-                               new BMessage(P_MSG_DECLINE));
+               BButton* decline = new BButton("decline", 
B_TRANSLATE("Decline"),
+                       new BMessage(P_MSG_DECLINE));
 
-               fBackground = BGroupLayoutBuilder(B_VERTICAL)
-                       .Add(scroll)
-                       .AddGroup(B_HORIZONTAL, 5.0f)
+               BLayoutBuilder::Group<>(this, B_VERTICAL)
+                       .Add(scrollView)
+                       .AddGroup(B_HORIZONTAL)
                                .AddGlue()
-                               .Add(accept)
+                               .Add(defaultButton)
                                .Add(decline)
-                       .End();
-       }
-       else {
-               BButton *button = new BButton("accept", B_TRANSLATE("Continue"),
-                               new BMessage(P_MSG_ACCEPT));
+                       .End()
+                       .SetInsets(B_USE_WINDOW_INSETS)
+               ;
+       } else {
+               defaultButton = new BButton("accept", B_TRANSLATE("Continue"),
+                       new BMessage(P_MSG_ACCEPT));
 
-               fBackground = BGroupLayoutBuilder(B_VERTICAL)
-                       .Add(scroll)
-                       .AddGroup(B_HORIZONTAL, 5.0f)
+               BLayoutBuilder::Group<>(this, B_VERTICAL)
+                       .Add(scrollView)
+                       .AddGroup(B_HORIZONTAL)
                                .AddGlue()
-                               .Add(button)
-                       .End();
+                               .Add(defaultButton)
+                       .End()
+                       .SetInsets(B_USE_WINDOW_INSETS)
+               ;
        }
 
-       AddChild(fBackground);
+       defaultButton->MakeDefault(true);
 
-       fBackground->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
-       fText->SetText(text);
-}*/
+       textView->SetText(text);
+}
 
diff --git a/src/apps/packageinstaller/PackageTextViewer.h 
b/src/apps/packageinstaller/PackageTextViewer.h
index d677fd0..76be440 100644
--- a/src/apps/packageinstaller/PackageTextViewer.h
+++ b/src/apps/packageinstaller/PackageTextViewer.h
@@ -8,28 +8,20 @@
 #ifndef PACKAGETEXTVIEWER_H
 #define PACKAGETEXTVIEWER_H
 
-#include <Window.h>
 #include <View.h>
 #include <TextView.h>
 
+#include "BlockingWindow.h"
 
-class PackageTextViewer : public BWindow {
-       public:
-               PackageTextViewer(const char *text, bool disclaimer = false);
-               ~PackageTextViewer();
+class PackageTextViewer : public BlockingWindow {
+public:
+                                                               
PackageTextViewer(const char* text,
+                                                                       bool 
disclaimer = false);
                
-               int32 Go();
-
-               void MessageReceived(BMessage *msg);
+       virtual void                            MessageReceived(BMessage* 
message);
                
-       private:
-               void _InitView(const char *text, bool disclaimer);
-
-               BView *fBackground;
-               BTextView *fText;
-
-               sem_id fSemaphore;
-               int32 fValue;
+private:
+                       void                            _InitView(const char 
*text, bool disclaimer);
 };
 
 

############################################################################

Commit:      ad1c3c44bfbf518fc8ea09f3fe884aa914d34e50
URL:         http://cgit.haiku-os.org/haiku/commit/?id=ad1c3c4
Author:      Stephan Aßmus <superstippi@xxxxxx>
Date:        Tue Feb 11 22:08:30 2014 UTC

PackageTextViewer: Fix include position

----------------------------------------------------------------------------

diff --git a/src/apps/packageinstaller/PackageTextViewer.cpp 
b/src/apps/packageinstaller/PackageTextViewer.cpp
index 6274aad..6352d81 100644
--- a/src/apps/packageinstaller/PackageTextViewer.cpp
+++ b/src/apps/packageinstaller/PackageTextViewer.cpp
@@ -12,11 +12,10 @@
 
 #include <Button.h>
 #include <Catalog.h>
+#include <LayoutBuilder.h>
 #include <Locale.h>
 #include <ScrollView.h>
 
-#include <LayoutBuilder.h>
-
 
 enum {
        P_MSG_ACCEPT = 'pmac',

############################################################################

Revision:    hrev46857
Commit:      be94359ce4b915a7cd77b2959f462a6eb5d4eec9
URL:         http://cgit.haiku-os.org/haiku/commit/?id=be94359
Author:      Stephan Aßmus <superstippi@xxxxxx>
Date:        Tue Feb 11 22:15:09 2014 UTC

PackageItem: Fixed rewriting item paths

 * The version of BString::Replace() that was used takes the offset at which
   replacing should start, not the number of replacements. So did this ever
   work? Use ReplaceFirst() instead.
 * Address the performance issues which Pawel commented on, plus some more.
 * I've left some debug output in the code (commented out), since I want to
   work on this some more. For example, I noticed that GoBe Productive puts
   files into /boot/beos/...

----------------------------------------------------------------------------

diff --git a/src/apps/packageinstaller/PackageItem.cpp 
b/src/apps/packageinstaller/PackageItem.cpp
index eda8368..d5e9e03 100644
--- a/src/apps/packageinstaller/PackageItem.cpp
+++ b/src/apps/packageinstaller/PackageItem.cpp
@@ -177,53 +177,66 @@ PackageItem::InitPath(const char *path, BPath 
*destination)
        status_t ret = B_OK;
 
        if (fPathType == P_INSTALL_PATH) {
-               if (!path) {
+//             printf("InitPath - relative: %s + %s\n", path, fPath.String());
+               if (path == NULL) {
                        parser_debug("InitPath path is NULL\n");
                        return B_ERROR;
                }
                ret = destination->SetTo(path, fPath.String());
-       }
-       else if (fPathType == P_SYSTEM_PATH)
+       } else if (fPathType == P_SYSTEM_PATH) {
+//             printf("InitPath - absolute: %s\n", fPath.String());
                ret = destination->SetTo(fPath.String());
-       else {
-               if (!path) {
+       } else {
+//             printf("InitPath - volume: %s + %s\n", path, fPath.String());
+               if (path == NULL) {
                        parser_debug("InitPath path is NULL\n");
                        return B_ERROR;
                }
 
                BVolume volume(dev_for_path(path));
                ret = volume.InitCheck();
-               if (ret != B_OK)
-                       return ret;
-
-               BDirectory temp;
-               ret = volume.GetRootDirectory(&temp);
-               if (ret != B_OK)
-                       return ret;
-
-               BPath mountPoint(&temp, NULL);
-               ret = destination->SetTo(mountPoint.Path(), fPath.String());
+               if (ret == B_OK) {
+                       BDirectory temp;
+                       ret = volume.GetRootDirectory(&temp);
+                       if (ret == B_OK) {
+                               BPath mountPoint(&temp, NULL);
+                               ret = destination->SetTo(mountPoint.Path(), 
fPath.String());
+                       }
+               }
        }
 
-       BPath systemNonPackagedDir;
-       find_directory(B_SYSTEM_NONPACKAGED_DIRECTORY, &systemNonPackagedDir);
-
-       BPath userNonPackagedDir;
-       find_directory(B_USER_NONPACKAGED_DIRECTORY, &userNonPackagedDir);
+       if (ret != B_OK) {
+               fprintf(stderr, "InitPath(%s): %s\n", path, strerror(ret));
+               return ret;
+       }
 
        BString pathString(destination->Path());
 
        // Hardcoded paths, the .pkg files hardcode this to the same
-       if (pathString.FindFirst("/boot/system") == 0 && 
pathString.FindFirst("non-packaged") == B_ERROR) {
-               pathString.Replace("/boot/system", systemNonPackagedDir.Path(), 
1);
-       }
+       if (pathString.FindFirst("non-packaged") < 0) {
+               bool wasRewritten = false;
+
+               if (pathString.StartsWith("/boot/system")) {
+                       BPath systemNonPackagedDir;
+                       find_directory(B_SYSTEM_NONPACKAGED_DIRECTORY,
+                               &systemNonPackagedDir);
+                       pathString.ReplaceFirst("/boot/system",
+                               systemNonPackagedDir.Path());
+                       wasRewritten = true;
+               } else if (pathString.StartsWith("/boot/home/config")) {
+                       BPath userNonPackagedDir;
+                       find_directory(B_USER_NONPACKAGED_DIRECTORY, 
&userNonPackagedDir);
+                       pathString.ReplaceFirst("/boot/home/config",
+                               userNonPackagedDir.Path());
+                       wasRewritten = true;
+               }
 
-       if (pathString.FindFirst("/boot/home/config") == 0 && 
pathString.FindFirst("non-packaged") == B_ERROR) {
-               pathString.Replace("/boot/home/config", 
userNonPackagedDir.Path(), 1);
+               if (wasRewritten) {
+//                     printf("rewritten: %s\n", pathString.String());
+                       destination->SetTo(pathString.String());
+               }
        }
 
-       destination->SetTo(pathString.String());
-
        return ret;
 }
 


Other related posts:

  • » [haiku-commits] haiku: hrev46857 - src/apps/packageinstaller - superstippi