lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


So that works for windows, but is there a POSIX or another OS agnostic
method for doing this?

wes

On 10/7/06, Nick Gammon <nick@gammon.com.au> wrote:

On 07/10/2006, at 7:51 PM, Wesley Smith wrote:

> Is this available?  I still haven't figured out how to do this as
> argv[0] isn't entirely reliable.

Well, it depends on your application. Using argv [0] depends on the
application being launched as a "console" application.

In my case, the scripting is imbedded into a Windows GUI application,
and the OS provides GetModuleFileName, which is the full pathname of
the application that is currently running.

Another string might be the current directory, not necessarily the
path of the application. I use getcwd for that (actually _getcwd in
Windows).

Another string might be the path to the script, assuming the host
application launches a standalone script. In that case, presumably
the application knows the path to the script file, since it read it
in, in the first place. Again, this might be different than the above
two paths.

- Nick