I see there is a “-cd” option which FreeFem++ command takes.
I think it means that FreeFem first cd into that directory and then runs. But I couldn’t figure out how to use it.
E.g. I have these files in /home/ar/code:
main.edp, mesh.idp
where main.edp includes mesh.idp
Now I want to run from say /home/ar/dir/. I tried:
FreeFem++ -cd …/main.edp
But didn’t work. Also tried other variants, no success.
What is the correct way to use -cd?
Well looked in the source and I think there is a bug in the file src/Graphics/getprog-unix.hpp , function:
int getprog(char* fn,int argc, char **argv)
It doesn’t handle the file name variable fn correctly. For example we call FreeFem++ -cd ../t.edp , then it cds to .. but doesn’t chop-off the directory and keeps the files name as ../t.edp which should be t.edp. So I added one line and it fixed the problem:
if(i>0) {
char *dir= new char [l+1];
strcpy(dir,edpfilenamearg);
strcyp(fn,edpfilenamearg+i+1); // Add this line to fix
dir[i]=0;
int err=0;
if(verbosity>1)
cout << " chdir '" << dir <<"'"<< endl;
// FFCS: mingw64 API change
err=chdir(dir);