Mentions légales du service

Skip to content

Fix #14: some functions for file manipulation

Thierry Martinez requested to merge fix.14.file_manipulation into main

This commit introduces the following functions:

  • rename("source/file/path", "target/file/path") renames a file and returns unit (void); the command fails if the source and target are not in the same file system.

  • source_directory() returns the path to the directory of the current source file.

  • path(["path_1", .., "path_n"]) concatenates the given paths.

Moreover, the behavior of include, read and write is changed so that they now consider paths relative to the current working directory (which is somehow more usual and therefore less surprising, at least for read and write).

To recover the former (and good!) behavior of include to include files relatively to the directory of the current source file, we can use the following pattern, documented in README.md:

- include path([source_directory(), "file.inc"])

The same pattern can be used of course with read, write and rename, letting the user choose whether she wants to consider the current working directory or the directory of the current source file.

Edited by Thierry Martinez

Merge request reports