Reading a file relative to an included file
<p>I need to load some text (shader code) from a file that is placed next to my library file. This way, I can <code>#include TextureBloomer.h</code> in several projects, and TextureBloomer will take care of loading its shader without needing to set paths through configuration or environment variables. The directory hierarchy looks like this:</p>

<pre><code>libs/libName/src/TextureBloomer/TextureBloomer.{h,cpp}
libs/libName/src/TextureBloomer/shaders/shader_name.{frag,vert}
apps/mine/appName/src/[several .h files that #include "TextureBloomer/TextureBloomer.h"]
</code></pre>

<p>I've been looking around for ways to do this, but all I found was posts saying "you can't", or "why would you even want to do that?" I found a (hacky) solution that works for me, but I've seen other posts that say using <code>__FILE__</code> is bad juju (with no justification). So, the question is a) what's so bad about this, and b) is there a way to improve it, eg. so I don't have to have "TextureBloomer.cpp" in the source file in case I change its name.</p>

<pre><code>string filename ("shaders/shader_name.frag");
string currentFile (__FILE__);
currentFile.replace(currentFile.find("TextureBloomer.cpp"), 18, "");
file.open((currentFile + filename).c_str());
</code></pre>

<p>EDIT: </p>

<p>I'm on OSX, compiling with XCode. I only really need it to work there, but other *nixes wouldn't hurt.</p>
