Function to return the current directory
|
Author |
Message |
JohnMurga
Administrator
      
Posts: 381
Group: Administrators
Joined: Apr 2007
Status:
Offline
Reputation: 2
|
RE: Function to return the current directory
If I remember rightly Windows has a "USERPROFILE" variable or something ...
You can use the murgaLua.getHostOsName() to decide whether to use it ...
Cheers
JohnM
|
|
07-23-2007 06:09 PM |
|
 |
mikshaw
Senior Member
   
Posts: 522
Group: Registered
Joined: Apr 2007
Status:
Offline
Reputation: 5
|
RE: Function to return the current directory
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.
This post was last modified: 07-24-2007 02:15 AM by mikshaw.
|
|
07-24-2007 02:11 AM |
|
 |
mikshaw
Senior Member
   
Posts: 522
Group: Registered
Joined: Apr 2007
Status:
Offline
Reputation: 5
|
RE: Function to return the current directory
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
OS=Windows_NT
USERNAME=mik
USERPROFILE=C:\Documents and Settings\mik
No idea why HOMEPATH and USERPROFILE are both used
|
|
07-24-2007 09:36 AM |
|
 |
JohnMurga
Administrator
      
Posts: 381
Group: Administrators
Joined: Apr 2007
Status:
Offline
Reputation: 2
|
RE: Function to return the current directory
Hey,
HOMEPATH isn't reliable, USERPROFILE is ... On my machine for instance HOMEPATH isn't set.
Cheers
JohnM
|
|
07-24-2007 05:03 PM |
|
 |
mikshaw
Senior Member
   
Posts: 522
Group: Registered
Joined: Apr 2007
Status:
Offline
Reputation: 5
|
RE: Function to return the current directory
Thanks. That will definitely help.
|
|
07-24-2007 11:38 PM |
|
 |
JohnMurga
Administrator
      
Posts: 381
Group: Administrators
Joined: Apr 2007
Status:
Offline
Reputation: 2
|
RE: Function to return the current directory
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 ...
Cheers
JohnM
|
|
07-25-2007 12:58 AM |
|
 |
mikshaw
Senior Member
   
Posts: 522
Group: Registered
Joined: Apr 2007
Status:
Offline
Reputation: 5
|
RE: Function to return the current directory
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)
|
|
07-25-2007 01:20 AM |
|
 |
JohnMurga
Administrator
      
Posts: 381
Group: Administrators
Joined: Apr 2007
Status:
Offline
Reputation: 2
|
RE: Function to return the current directory
|
|
07-27-2007 06:49 PM |
|
 |
mikshaw
Senior Member
   
Posts: 522
Group: Registered
Joined: Apr 2007
Status:
Offline
Reputation: 5
|
RE: Function to return the current directory
O_O
Sweet!
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.
|
|
07-27-2007 10:50 PM |
|
 |
JohnMurga
Administrator
      
Posts: 381
Group: Administrators
Joined: Apr 2007
Status:
Offline
Reputation: 2
|
RE: Function to return the current directory
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.
Cheers
JohnM
|
|
07-28-2007 12:09 AM |
|
 |
|