Reputation: 13632
Is it possible to get the operating system in maxima? I have some code that needs the unix /
or windows \
for path names. How can I find out which operating system the code is running in?
To give some context, I have the following code:
windows: false$
divider: "/"$
if (windows) then divider: "\\"$
initfile: concat(maxima_userdir, divider, "maxima-init.mac");
load(operatingsystem)$
dir: getcurrentdirectory();
if (substring(dir, slength(dir)) # divider) then dir: concat(dir, divider)$
repo: concat(dir, "$$$.mac")$
live: concat(dir, "live_packages", divider, "$$$.mac")$
with_stdout(initfile, printf(true, ""))$
with_stdout(initfile, printf(true, concat("file_search_maxima: append (file_search_maxima, [
~s,
~s
]);"), repo, live))$
Upvotes: 2
Views: 90
Reputation: 17595
If you're not adverse to writing a little bit of Lisp code, another approach is to use the file and directory functions in Common Lisp, which are more extensive than in Maxima. See the section on filenames in the Common Lisp Hyperspec. I think maybe MERGE-PATHNAMES and/or MAKE-PATHNAME might be relevant.
Upvotes: 1
Reputation: 17595
Take a look at the output of build_info
, specifically the field host
(i.e. foo@host
where foo : build_info()
). See ? build_info
for more information.
On my (Linux) system I get: x86_64-unknown-linux-gnu
I think on MS Windows you'll get a string containing windows
or at least win
or maybe win32
.
There may be other ways to figure out the system type so let me know if that doesn't work for you. Also it is possible that there is a global variable floating around which tells the path separator; I would have to look for that.
Upvotes: 2