SlickEdit Product Discussion > SlickEdit User Macros

_RelativeToWorkingDir() function

(1/1)

Dennis:
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: ---#include "slick.sh"
#import "project.e"

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

--- End code ---

Navigation

[0] Message Index

Go to full version