[haiku-commits] haiku: hrev50498 - src/preferences/keymap

  • From: jscipione@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Fri, 19 Aug 2016 20:14:06 +0200 (CEST)

hrev50498 adds 1 changeset to branch 'master'
old head: 3d2f4db565a7b29fdf83bb41e0b80cffd6a88b3d
new head: 23a6a63e832c284467e36a0026c18234759dd1fa
overview: 
http://cgit.haiku-os.org/haiku/log/?qt=range&q=23a6a63e832c+%5E3d2f4db565a7

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

23a6a63e832c: Keymap: Follow symlink
  
  get_ref_for_path() doesn't resolve symlinks.
  
  Construct a BEntry from the path passing 'true' for the traverse
  argument. That BEntry is then be passed to BDirectory's constructor.
  
  The error was hidden by the fact that the code didn't bother to error
  check the result of get_ref_for_path(), which would have indicated that
  the passed in path was a link.
  
  Thanks Rene for your help.
  
  if the entry fails to init, we are probably screwed, but, try to get
  the path using get_ref_for_path in that case. Worst case scenario it
  fails as well and the FilePanel points to your home directory.

                                     [ John Scipione <jscipione@xxxxxxxxx> ]

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

Revision:    hrev50498
Commit:      23a6a63e832c284467e36a0026c18234759dd1fa
URL:         http://cgit.haiku-os.org/haiku/commit/?id=23a6a63e832c
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Fri Aug 19 18:09:02 2016 UTC

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

1 file changed, 6 insertions(+), 4 deletions(-)
src/preferences/keymap/KeymapWindow.cpp | 10 ++++++----

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

diff --git a/src/preferences/keymap/KeymapWindow.cpp 
b/src/preferences/keymap/KeymapWindow.cpp
index 3d6bd9d..b25fa9d 100644
--- a/src/preferences/keymap/KeymapWindow.cpp
+++ b/src/preferences/keymap/KeymapWindow.cpp
@@ -133,14 +133,16 @@ KeymapWindow::KeymapWindow()
        path.Append("Keymap");
 
        entry_ref ref;
-       get_ref_for_path(path.Path(), &ref);
-
-       BDirectory userKeymapsDir(&ref);
+       BEntry entry(path.Path(), true); // follow symlink
+       BDirectory userKeymapsDir(&entry);
        if (userKeymapsDir.InitCheck() != B_OK
                && create_directory(path.Path(), S_IRWXU | S_IRWXG | S_IRWXO)
                        == B_OK) {
                get_ref_for_path(path.Path(), &ref);
-       }
+       } else if (entry.InitCheck() == B_OK)
+               entry.GetRef(&ref);
+       else
+               get_ref_for_path(path.Path(), &ref);
 
        BMessenger messenger(this);
        fOpenPanel = new BFilePanel(B_OPEN_PANEL, &messenger, &ref,


Other related posts:

  • » [haiku-commits] haiku: hrev50498 - src/preferences/keymap - jscipione