If you have even the relative pathname (in this case it appears to be ./
) you can open files relative to your script file(s). I use Perl, but the same general solution can apply: I split the directory into an array of folders, then pop
off the last element (the script), then push
(or for you, append
) on whatever I want, and then join them together again, and BAM! I have a working pathname that points to exactly where I expect it to point, relative or absolute.
Of course, there are better solutions, as posted. I just kind of like mine.