I have a class method (implemented in a shared object in UNIX environment) which needs to access a text data file in runtime (using ifstream). Currently the method assumes that the data file is available for opening without any relative path, i.e something like
ifstream dataFile("data.txt");
The shared object is loaded from python code, and in order for it to be available for loading, it is being copied to the \usr\lib\
folder as a post-build step of the makefile. My question is how to make the text data file available for the shared object. I have considered the following possibilities:
- Use some relative path, but that method is not totally fool-proof (the project is hosted on various instances and I cannot be sure the directory tree will stay the same (e.g) a month from now).
- copy the data file as well to
\usr\lib
, but I feel this is a wrong attitude.
Any suggestions are welcomed.