Patch #2025 2007-05-29 22:47

dmoore

relative paths fix for findinfiles
Download
2025-relative_paths.patch (1.3 KB)
Category
Application::Refinement
Status
Accepted
Close date
2007-06-01 16:43
Assigned to
biplab
Index: src/sdk/editormanager.cpp
===================================================================
--- src/sdk/editormanager.cpp    (revision 4010)
+++ src/sdk/editormanager.cpp    (working copy)
@@ -2304,11 +2304,11 @@
 
         // make the filename relative
         wxString filename = filesList[i];
-        if (filename.StartsWith(data->searchPath))
+        if(data->scope==2) //for "search path" produce relative paths
         {
             wxFileName fname(filename);
-            fname.MakeRelativeTo(data->searchPath);
-            filename = fname.GetFullPath();
+            if(fname.MakeRelativeTo(data->searchPath))
+                filename=fname.GetFullPath();
         }
 
         // log it
Index: src/sdk/searchresultslog.cpp
===================================================================
--- src/sdk/searchresultslog.cpp    (revision 4010)
+++ src/sdk/searchresultslog.cpp    (working copy)
@@ -57,9 +57,8 @@
     wxFileName filename(m_pList->GetItemText(selIndex));
     wxString file;
     if (!filename.IsAbsolute())
-        file = m_Base + wxFILE_SEP_PATH + filename.GetFullPath();
-    else
-        file = filename.GetFullPath();
+        filename.MakeRelativeTo(m_Base);
+    file = filename.GetFullPath();
 
     wxListItem li;
     li.m_itemId = selIndex;
dmoore 2007-05-29 22:50

this revises patch 2021 to avoid any platform dependency in converting to/from relative paths

biplab 2007-06-01 16:43

I didn't apply the portion of patch to make filenames relative only when a particular search path is being used. It creates a situation where for search in Project files also shows their full path.

If you still feel it's needed, please feel free to discuss.

Thanks for your patch.

dmoore 2007-06-01 19:29

I could be wrong about this, but I didn't think the searchPath was well defined for search in projects/workspaces. i.e. it simply takes whatever value is in the search path field.

Ideally searchPath should be the location of the project file and/or workspace file? At present, I don't think this is guaranteed to be true, but one of us could fix that.