MentDB, The digital brain.  About us Home
Back / All functions / File

Like all languages, you have a few data manipulation functions.

file createfile appendfile existfile is_directoryfile loadfile count_line dirfile count_linesfile meta_datafile cur_abs_dirfile cur_canonical_dirfile pwdfile sizefile last_modifiedfile mkdirfile deletefile copy_dirfile copy_filefile copy_formatfile inifile ini_strfile dir_listfile dir_list_regexfile b64_readfile b64_writefile writer_openfile writer_existfile writer_showfile writer_add_linefile writer_add_bytesfile writer_flushfile writer_closefile writer_closeallfile reader_openfile reader_existfile reader_showfile reader_get_linefile reader_get_bytesfile reader_closefile reader_closeall

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 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/Projects/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 meta_data <filePath> <attribute>

Description

    Get meta data of a file

Parameters

    filePath:   The path to the file - String - required
    attribute:   The attribute (creationTime|lastAccessTime|lastModifiedTime|author) - String - required
admin
file meta_data "data/.id" "creationTime"
mentdb
2018-02-25T17:55:17Z

file cur_abs_dir

Description

    Get the current absolute directory path

admin
file cur_abs_dir
mentdb
/Users/jimmitry/Documents/jpayet/Projects/MentDB/MentDB_Server/.

file cur_canonical_dir

Description

    Get the current canonical directory path

admin
file cur_canonical_dir
mentdb
/Users/jimmitry/Documents/jpayet/Projects/MentDB/MentDB_Server

file pwd

Description

    Get the current absolute directory path

admin
file pwd
mentdb
/Users/jimmitry/Documents/jpayet/Projects/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 copy_format <source> <sourceEncoding> <target> <targetEncoding>

Description

    Copy a file to another format

Parameters

    source:   The source file path - String - required
    sourceEncoding:   The source file encoding (ex: 'UTF-8') - String - not required
    target:   The new file path - String - required
    targetEncoding:   The target file encoding (ex: 'UTF-8') - String - not required
admin
file copy_format "read-me.txt" "utf-8" "read-me2.txt" "utf-8"
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
liza

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
liza

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/Projects/MentDB"
mentdb
[
".DS_Store",
".git",
".gitignore",
".metadata",
".recommenders",
"MentDB_Editor",
"MentDB_Server",
"README.md",
"RemoteSystemsTempFiles"
]

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/Projects/MentDB" ".*.*" true true
mentdb
[
".DS_Store",
".git",
".gitignore",
".metadata",
".recommenders",
"MentDB_Editor",
"MentDB_Server",
"README.md",
"RemoteSystemsTempFiles"
]

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
[
"w1",
"w2"
]

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
[
"r2",
"r1"
]

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 - 2018 - Innov-AI.