/* SPDX-License-Identifier: GPL-2.0-or-later */

load("operatingsystem.lisp");

/* maxima-getenv() is an existing lisp-function. Just assign a consistent name
   for a maxima function for it (callable without a leading '?' and the need to
   quote the "-" by "\-". */
   
getenv(s) := ?maxima\-getenv(s) $


setenv(s, t) := ?getenv(s, t) $

putenv(s, t) := setenv(s, t) $

getcurrentdirectory() := ?os\-getcurrentdirectory() $

delete_file(s) := ?delete\-file(s)$

chdir(s) := ?os\-chdir(os_endwithslash(s)) $

mkdir(s) := ?os\-mkdir(os_endwithslash(s)) $

rmdir(s) := ?os\-rmdir(os_endwithslash(s)) $

/* currently works only with files; TODO: allow directories too.
(CLISP: (ext:rename-directory "testdir1/" "testdir2/") (with trailing slashes) */
rename_file(f, t) := ?rename\-file(f, t)$

copy_file(f, t) := ?os\-copy\-file(f, t)$

/* ensure that the directoryname ends with an slash */
os_endwithslash(s) := if charat(s, slength(s)) = "/" then s else concat (s, "/")$
