Author Topic: _RelativeToWorkingDir() function  (Read 1415 times)


  • Senior Community Member
  • Posts: 3983
  • Hero Points: 517
_RelativeToWorkingDir() function
« on: November 20, 2023, 04:42:52 PM »
Just a little utility function to compute a path relative to the project working directory, which I needed in an environment where I was keeping the project files well outside of the source directory.

Used in my Project tool setup as:  %(macro _RelativeToWorkingDir %f)

Not exactly rocket science ... maybe more like wheelbarrow science.

Code: [Select]
#include ""
#import "project.e"

_str _RelativeToWorkingDir(_str Filename,_str ProjectName=_project_name)
   if (ProjectName=='') {
   project_handle := _ProjectHandle(ProjectName);
   project_dir := _strip_filename(ProjectName, 'N');
   working_dir := absolute(_ProjectGet_WorkingDir(project_handle), project_dir);
   return relative(Filename, working_dir);