Hi, colleagues!
Please, could anyone add an option for cbProject::GetFileByFilename to return correct path to the file (with all subdirectories) when only filename is given.
This is needed to support tools/environments that give only filenames, with no path information.
Current C::B behaviour:
if (path is absolute) open as is else open relative to the project root (i.e. "$project_root/$relative_path")
I'd like to extend this with an additional branch:
if there is no such file in the project root, try to find the file in the project tree.
For example, if the file is /tmp/dir1/dir2/file.cpp and project root is /tmp, so:
"/tmp/dir1/dir2/file.cpp" - absolute path, open as is;
"dir1/dir2/file.cpp" - relative path, prepend project root (it will give "/tmp/dir1/dir2/file.cpp") and open;
"dir2/file.cpp" - relative path, prepend project root (it will give "/tmp/dir2/file.cpp") and try to open - failed, try to find this in the project tree (should be very fast, as the project tree is in memory), find in dir1 and open;
"file.cpp" - just a file name, prepend project root (it will give "file.cpp") and try to open - failed, try to find this in the project tree (again, should be very fast), find in dir1/dir2 and open.
Of course, there is a problem with duplicates, but when you have just a file name - you have no better choice.
Of course, various smart techniques can be used to distinguish between different files with the same name, but it's not for the near future. For now it's enough just show the list of possibilities and let user to decide.
What do you think? Is it possible? (I think it should be quite simple as there is already a feature 'Find file' in the project tree.)
This would be a great help to all people who use complicated build procedures and strange development tools and tries to tie them with C::B.
references:
https://developer.berlios.de/bugs/?func=detailbug&group_id=5358&bug_id=11207https://developer.berlios.de/bugs/?func=detailbug&group_id=5358&bug_id=11208I saw a few more tracker items related to this problem, but can't find them now.
Additional/alternative option - to provide a hook for filename processing.
As I understand there are some hard-coded processing rules like 'GDB workaround' - so why not to do it generic and customizable? It should be a C::B macro function, that can contain anything, from the default implementation (do nothing) to regex processing, 'find file' call etc.
This will also help developers who use source code generators - when they receive an error regarding failed compilation of a generated file, they would like to automatically go to the generator/template/whatever file used for generation.
What do you think?
Thanks guys!