Quirrel4.41.0

system.rename

Defined in module "system"
from "system" import rename
rename(old: string, new: string)

Renames the file from old to new path, throws error in case of fail

Parameters

oldstringcurrent path of the file
newstringnew path for the file

Errors

Throws rename() failed if the underlying C rename() call fails, for example because old does not exist or new is on a filesystem the C library refuses to move a file to. The message carries no further detail: no path, no errno, no reason.

Notes

Unlike getenv, setenv and system, rename is built the same way on every target; there is no platform stub.

No example runs here because renaming a file changes the machine, which every example on this site must avoid. Typical use:

from "system" import rename

try {
  rename("old.tmp", "new.tmp")
} catch (e) {
  println(e) // "rename() failed"
}

See also

removeDeletes the file at the given path, throws error in case of fail
systemmodule index