Murga-Projects Forums

Full Version: Function to return the current directory
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
If I remember rightly Windows has a "USERPROFILE" variable or something ...

You can use the murgaLua.getHostOsName() to decide whether to use it ...

I don't know. I recall only seeing "TMP" and "TEMP" as user variables. Maybe the others are there but simply not available for modification by the user (XP Home).
I'll get a chance to look at it again tomorrow or later on today.

It may be a case where I just write a generic function to include with all cross-platform scripts.
The function would check the host os and adjust various parts of the script accordingly.
Those two variables were simply the only two listed under system properties (why, i don't know).
I used the "set" command to display the environment and found a few that will be helpful. I just hope the variable names are the same from one Windows version to another.
Here are some on Windows XP that look like they might be useful:
APPDATA=C:\Documents and Settings\mik\Application Data
HOMEPATH=\Documents and Settings\mik
USERPROFILE=C:\Documents and Settings\mik

No idea why HOMEPATH and USERPROFILE are both used

HOMEPATH isn't reliable, USERPROFILE is ... On my machine for instance HOMEPATH isn't set.

Thanks. That will definitely help.
I did some research, I am thinking that murgaLua probably works on Win98, however on Win98 you wouldn't get things like "APPDATA" or "USERPROFILE" ... And maybe not even "OS".

You will get things like WINDIR, etc ...

Well then, I guess I won't be relying much on os.getenv() for cross-platform apps =op
I was really hoping that this particular function would be a lifesaver when trying to do things like reading/writing configuration files. Unfortunately it seems that the developers of Windows have little concept of consistency.

But at least OS X is Unix-based (and includes the basic GNU utilities?), so I doubt there will be many portability problems to that from Linux =o)
Incidentally, the new build will have THIS :

Which might make your life easier.

I tried unsuccessfully to install this for Lua proper not long ago...I think at the time it was incompatible with Lua 5.1 or something...can't recall...

Some of these functions are things I believe should have been a part of Lua already, or at least would be if it was my project.

mikshaw Wrote:
Some of these functions are things I believe should have been a part of Lua already, or at least would be if it was my project.

This comes up a lot, people don't realize that the Lua core is meant to be as portable as possible, and this means that they don't implement some things considered as basic for many because they cannot guarantee that Lua will compile on all platforms.

I don't have this problem as I am clearly targeting murgaLua at those platforms supported by FLTK and LuaSocket.


Pages: 1 2 3
Reference URL's