Posix.ProcEnv.uname() will give you various strings which will help
distinguish between Unix-like systems. The only problem is that the
Posix structure is not present on Windows so the code will not compile
there.
OS.Path.joinDirFile will effectively tell you the directory separator.
e.g on Linux:
OS.Path.joinDirFile{dir="a", file="b"};
val it = "a/b": string
on Windows:
> OS.Path.joinDirFile{dir="a", file="b"};
val it = "a\\b": string
This is off the top of my head. There may be other ways of doing what
you want depending on exactly what you're trying to do.
David
On 13/11/2021 14:51, zacque wrote:
Hi,
How to detect the current running OS in Poly/ML?
I'm looking for something like:
datatype Platform = Linux | Windows | macOS | BSD | ...
val getPlatform : unit -> Platform
If not, how can I implement something like this, if possible?
I'm asking because it's useful for writing OS specific library,
e.g. path library to print Unix/Windows-style path. I've tried searching
around the web and looking into the Basis Library manual, but still couldn't
find anything useful.
Any pointer will be much appreciated. Thanks!
_______________________________________________
polyml mailing list
polyml@inf.ed.ac.uk
http://lists.inf.ed.ac.uk/mailman/listinfo/polyml