File
Like all languages, you have a few data manipulation functions.
file create <filePath> <data> <encoding>
Description
Create a new text file
Parameters
filePath: The path to the file - String - required
data: String data - String - required
encoding: The file encoding (ex: 'UTF-8') - String - not required
admin
file create "data/.id" (string generate_random_str 12);
mentdb
1
admin
file create "data/.id" (string generate_random_str 12;) "utf-8"
mentdb
1
file append <filePath> <data> <encoding>
Description
Append a text into a file
Parameters
filePath: The path to the file - String - required
data: String data - String - required
encoding: The file encoding (ex: 'UTF-8') - String - not required
admin
file append "data/.id" (string generate_random_str 12);
mentdb
1
admin
file append "data/.id" (string generate_random_str 12;) "utf-8"
mentdb
1
file exist <filePath>
Description
To check if a file already exist
Parameters
filePath: The path to the file - String - required
admin
file exist "data/.id"
mentdb
1
file image_resize <filePath> <width> <height>
Description
To resize an image
Parameters
filePath: The path to the file - String - required
width: The target width - String - required
height: The target height - String - required
admin
file image_resize "data/image.png" 100 80
mentdb
...
file image_rotate_90 <filePath>
Description
To resize an image
Parameters
filePath: The path to the file - String - required
admin
file image_rotate_90 "data/image.png"
mentdb
...
file is_directory <filePath>
Description
To check if a file is a directory
Parameters
filePath: The path to the file - String - required
admin
file is_directory "data/.id"
mentdb
0
file load <filePath> <encoding>
Description
To get text from a file
Parameters
filePath: The path to the file - String - required
encoding: The file encoding (ex: 'UTF-8') - String - not required
admin
file load "data/.id";
mentdb
XdoZMCbr6o7IUElQ8fDGqtVFoDAksJRRpxbk
admin
file load "data/.id" "UTF-8"
mentdb
2pvrPdmfuTrz
file count_line dir <dirPath> <endOfFile>
Description
Count the number of line in a directory
Parameters
dirPath: The directory - String - required
endOfFile: The end of file (ex: '.java') - String - required
admin
file count_line dir "/Users/jimmitry/Documents/jpayet/INNOV-AI/MENTDB" ".java"
mentdb
81354
file count_lines <filePath>
Description
Count the number of line in a file
Parameters
filePath: The path to the file - String - required
admin
file count_lines "data/.id"
mentdb
1
file cur_abs_dir
Description
Get the current absolute directory path
admin
file cur_abs_dir
mentdb
/Users/jimmitry/Documents/jpayet/INNOV-AI/MENTDB/MentDB_Server/.
file cur_canonical_dir
Description
Get the current canonical directory path
admin
file cur_canonical_dir
mentdb
/Users/jimmitry/Documents/jpayet/INNOV-AI/MENTDB/MentDB_Server
file pwd
Description
Get the current absolute directory path
admin
file pwd
mentdb
/Users/jimmitry/Documents/jpayet/INNOV-AI/MENTDB/MentDB_Server/.
file size <filePath>
Description
Get size in bytes of a file or a directory
Parameters
filePath: The path to the file - String - required
admin
file size "data/.id"
mentdb
36
file last_modified <filePath>
Description
Get last modified timestamp of a file or a directory
Parameters
filePath: The path to the file - String - required
admin
file last_modified "data/.id"
mentdb
2018-10-10 10:00:00
file mkdir <dirPath>
Description
Create a new directory
Parameters
dirPath: The path to the directory - String - required
admin
file mkdir "dir";
mentdb
1
file delete <path>
Description
Delete a file or a directory
Parameters
path: The path to the directory or to the file - String - required
admin
file delete "dir";
mentdb
1
file copy_dir <oldDirPath> <newDirPath>
Description
Copy a directory
Parameters
oldDirPath: The old directory path - String - required
newDirPath: The new directory path - String - required
admin
file copy_dir "logs" "logs2";
mentdb
1
admin
file delete "logs2"
mentdb
1
file copy_file <oldFilePath> <newFilePath>
Description
Copy a file
Parameters
oldFilePath: The old file path - String - required
newFilePath: The new file path - String - required
admin
file copy_file "read-me.txt" "read-me2.txt";
mentdb
1
admin
file delete "read-me2.txt"
mentdb
1
file ini <path> <section> <field>
Description
Get a value in a configuration file (.INI file)
Parameters
path: The file path - String - required
section: The section - String - required
field: The field - String - required
admin
file ini "conf/server.conf" "AI" "FIRSTNAME"
mentdb
lisa
file ini_str <str> <section> <field>
Description
Get a value in a configuration string (.INI)
Parameters
str: The string config file - String - required
section: The section - String - required
field: The field - String - required
admin
file ini_str (file load "conf/server.conf") "AI" "FIRSTNAME"
mentdb
lisa
file dir_list <dirPath>
Description
List all files or folders in a directory
Parameters
dirPath: The path to the directory - String - required
admin
file dir_list "/Users/jimmitry/Documents/jpayet/INNOV-AI/MENTDB"
mentdb
[<br> ".DS_Store",<br> ".git",<br> ".gitignore",<br> ".metadata",<br> ".recommenders",<br> "MentDB_Editor",<br> "MentDB_Server",<br> "README.md",<br> "RemoteSystemsTempFiles"<br>]
file dir_list_regex <dirPath> <regexFilter> <getFile> <getDirectory>
Description
List all files or folders in a directory with regex filter
Parameters
dirPath: The path to the directory - String - required
regexFilter: The regex expression - String - required
getFile: Get file or not - String - required
getDirectory: Get directory or not - String - required
admin
file dir_list_regex "/Users/jimmitry/Documents/jpayet/INNOV-AI/MENTDB" ".*.*" true true
mentdb
[<br> ".DS_Store",<br> ".git",<br> ".gitignore",<br> ".metadata",<br> ".recommenders",<br> "MentDB_Editor",<br> "MentDB_Server",<br> "README.md",<br> "RemoteSystemsTempFiles"<br>]
file b64_read <filePath>
Description
This function allow you to get a binary file in base 64 format
Parameters
filePath: The path to the file - String - required
admin
file b64_read "data/.id"
mentdb
dWdmNjJPUlZzMTkyMlk5eGd4R3I3SU5TM0pLSW1leWppeFph
file b64_write <dataB64> <filePath>
Description
This function allow you to write a binary file from a base 64 format
Parameters
dataB64: Data in base 64 - String - required
filePath: The path to the file - String - required
admin
file b64_write "dWdmNjJPUlZzMTkyMlk5eGd4R3I3SU5TM0pLSW1leWppeFph" "data/.id";
mentdb
1
file writer_open <writerId> <filePath> <append> <type> <encoding>
Description
Open a writer
Parameters
writerId: The writer id - String - required
filePath: The file path - String - required
append: A boolean to activate the append mode - String - required
type: The type (TEXT|BINARY) - String - required
encoding: The encoding (ex: 'utf-8') - String - required
admin
file writer_open "w1" "file.txt" true TEXT "utf-8";
mentdb
1
admin
file writer_open "w2" "image.png" true BINARY null;
mentdb
1
file writer_exist <writerId>
Description
Check if a writer is already opened
Parameters
writerId: The writer id - String - required
admin
file writer_exist "w1"
mentdb
1
file writer_show
Description
Show all writers
admin
file writer_show;
mentdb
[<br> "w1",<br> "w2"<br>]
file writer_add_line <writerId> <str>
Description
Add a new line to a writer
Parameters
writerId: The writer id - String - required
str: The string to add - String - required
admin
file writer_add_line "w1" "data";
mentdb
1
file writer_add_bytes <writerId> <bytes>
Description
Add a new bytes to a writer
Parameters
writerId: The writer id - String - required
bytes: The bytes to add - String - required
admin
file writer_add_bytes "w2" "data";
mentdb
1
file writer_flush <writerId>
Description
Flush a writer
Parameters
writerId: The writer id - String - required
admin
file writer_flush "w1";
mentdb
1
file writer_close <writerId>
Description
Close a writer
Parameters
writerId: The writer id - String - required
admin
file writer_close "w1";
mentdb
1
file writer_closeall
Description
Close all writers
admin
file writer_closeall;
mentdb
{}
file reader_open <readerId> <filePath> <type> <encoding>
Description
Open a reader
Parameters
readerId: The reader id - String - required
filePath: The path to the file - String - required
type: The type (TEXT|BINARY) - String - required
encoding: The encoding (ex: 'utf-8') - String - required
admin
file reader_open "r1" "file.txt" TEXT "utf-8";
mentdb
1
admin
file reader_open "r2" "image.png" BINARY null
mentdb
1
file reader_exist <readerId>
Description
Check if a ready is already opened
Parameters
readerId: The reader id - String - required
admin
file reader_exist "r1"
mentdb
1
file reader_show
Description
Show all readers
admin
file reader_show;
mentdb
[<br> "r2",<br> "r1"<br>]
file reader_get_line <readerId>
Description
Get line from a reader (TEXT mode)
Parameters
readerId: The reader id - String - required
admin
file reader_get_line "r1"
mentdb
data
file reader_get_bytes <readerId> <nbBytes>
Description
Get bytes from a reader (BINARY mode)
Parameters
readerId: The reader id - String - required
nbBytes: The number of bytes - String - required
admin
file reader_get_bytes "r2" 1024
mentdb
data
file reader_close <readerId>
Description
Close a reader
Parameters
readerId: The reader id - String - required
admin
file reader_close "r1";
mentdb
1
file reader_closeall
Description
Close all readers
admin
file reader_closeall;
mentdb
{}
admin
file delete "file.txt"
mentdb
1
admin
file delete "image.png"
mentdb
1
© 2012 - 2023