4/08/2013

Specifying a file path at runtime

1. In c/c++ source code, specify the file with an environment variable:

std::string fileName = getenv("package_SRCDIR");
fileName = fileName+"<file.name>";
doSomething(fileName.c_str());

2. Ask bash users to prepare a run.sh which reads

export package_SRCDIR=/users/share/package_dir
$package_SRCDIR/source_cxx

where source_cxx is an executable of the source code.

Environment: Mac OS X 10.6, bash


No comments:

Post a Comment