L1VM - file tools
L1VM - file tools
In L1VM 1.9.0 there is a new file tools module. There are the experimental C++ 17 tools:
file_tools_copy, file_tools_dir_create, file_tools_remove, file_tools_rename, file_tools_size, file_tools_exists
Here is the example for file rename: (file-tools.l1com)
// file library module
// test program
//
//
#include <intr.l1h>
(main func)
#include <file-def.l1h>
(set int64 1 zero 0)
(set int64 1 one 1)
(set string s oldfilename "foobar.txt")
(set string s newfilename "hello.txt")
(set int64 1 ret 0)
(zero :file_tools_init !)
// rename file
(oldfilenameaddr newfilenameaddr :file_tools_rename !)
(ret stpop)
exit (zero)
(funcend)
#include <file-tools-lib.l1h>
To build the module you have to “cd” into the directory: “vm/modules/file-tools/”.
And then build it:
$ CC=clang CCPP=clang++ zerobuild force
Now copy the library into the ~/bin directory:
$ cp *.so ~/bin
That’s it! Have some fun!