PDA

View Full Version : questions about UNiX path and LW version



papou
01-09-2011, 07:56 PM
Hi,
I'm trying to detect if a script is running under lightwave 32bits or 64bits?
Actually, i have a hack with the Install dir. I'm looking for the (x86) into the Programs Files folder to detect the 32bits version but i'm not happy with that....
Who can help on this one?

Second question, i'd like to get some info about a file.
i must use filestat
(a,c,m,s,l,u,g) = filestat("install_dir");
But it return numerous "nil" if i don't provide UNIX path.
So how to convert \ to / ??

thank you for your help

papou
01-12-2011, 06:00 PM
well, i'm still stuck with 32/64bits detection... so any idea is welcome.

About replacing a file path by an unix file path, i'm trying to use that:

searchAndReplace: oName, search, replace
{
exp = regexp(search, replace);
oName ~= exp;
return(oName);
}

but i'm still stuck with the way to replace \ by / with this annoying ""

install_dir = getdir(INSTALLDIR);
unix_install_dir = searchAndReplace(install_dir, "\", "/"); // ERROR HERE
unix_install_dir = searchAndReplace(install_dir, "\\", "/"); // NOTHING HERE
...
pathseparator = (getsep());
unix_install_dir = searchAndReplace(install_dir, pathseparator, "/"); // CHANGE LETTER 'e' with '/' HUH?

any idea about that too?

papou
01-13-2011, 09:15 AM
Alexx is helping me on the replacing by unix path. cool.

I'm still looking for a well way to detect 64bits...
Maybe check the exe weight. 64 bits is more heavy than 32bits...

eben
01-19-2011, 03:33 AM
About x64 detection, did you see in SDK doc, 9.3 changes ?

Three new platform() codes have been added to LScript: WIN32, WIN64, and MAC64. The Windows codes break down as follows:
INTEL (32-bit Windows)
WIN32 (32-bit Windows)
WIN64 (64-bit Windows)
The Macintosh codes are a bit more diverse:
MACINTOSH (32-bit non-MACH)
MACUB (32-bit MACH)
MAC64 (64-bit MACH)

vfxdomain
01-20-2011, 02:03 PM
About x64 detection, did you see in SDK doc, 9.3 changes ?

Three new platform() codes have been added to LScript: WIN32, WIN64, and MAC64. The Windows codes break down as follows:
INTEL (32-bit Windows)
WIN32 (32-bit Windows)
WIN64 (64-bit Windows)
The Macintosh codes are a bit more diverse:
MACINTOSH (32-bit non-MACH)
MACUB (32-bit MACH)
MAC64 (64-bit MACH)

Honestly i have not succeed using platform() in lscript (LW10), @if platform == INTEL (or WIN32/WIN64 etc.) in pre-processor does not works for me at all, and platform() inside generic returns lightwave version, "10" in my case.

papou, you want to take into account the possibility of running LW x86 on x64 system, correct? Because if you want to check if the OS itself is x86 or x64, you can use environment variables, such as

osProg = getenv("ProgramFiles");
osProg86 = getenv("ProgramFiles(x86)");
osProg64 = getenv("ProgramW6432");

Actually, i think osProg = getenv("ProgramFiles") may be used in your case, because it should return value depending on whether the process requesting the environment variable is itself 32-bit or 64-bit (C:\Program Files (x86) or C:\Program Files)

eben
01-20-2011, 03:12 PM
sorry, i didn't have time to test, just finding these lines searching something else...

papou
01-20-2011, 06:39 PM
thank you Eben!
like vfxdomain, my previous tests return wrong results, in my case 1 for INTEL.

But my final attempt works! (in Lightwave10 too)

if (platform() == WIN64)

thank you again.

Both my problem are resolved! :D
i'm a happy lscripter who can continue to script.

vfxdomain
01-21-2011, 04:47 AM
thank you Eben!
like vfxdomain, my previous tests return wrong results, in my case 1 for INTEL.

But my final attempt works! (in Lightwave10 too)

if (platform() == WIN64)

thank you again.

Both my problem are resolved! :D
i'm a happy lscripter who can continue to script.

Yep, it's working this way! Thanks! :thumbsup: