All Functions Modules Pages
files

Functions

BOOLEAN files.exists (STRING path)
 Allows to find if a file or folder exists. More...
 
STRING files.cdir ()
 Allows to know the actual work path. More...
 
NIL files.cdir (STRING path)
 Change the work path to the specified path. More...
 
STRING files.nofile (STRING path)
 Remove the file from a specified path. More...
 
STRING files.nopath (STRING path)
 Remove the folder from a specified path. More...
 
NUMBER files.rename (STRING name, STRING new)
 Allows to rename a file or folder. More...
 
NUMBER files.copy (STRING src, STRING dst)
 Copy a file or folder recursively and overwrite the files in the destination folder. More...
 
NUMBER files.move (STRING src, STRING dst)
 Move a file or folder recursively and overwrite the files in the destination folder. More...
 
BOOLEAN files.delete (STRING path)
 Delete a file or folder recursively. More...
 
NIL files.mkdir (STRING path)
 Create a folder. More...
 
NUMBER files.size (STRING path)
 File/Folder Size (Bytes). More...
 
STRING files.ext (STRING path)
 Allows to know the extension of a file. More...
 
TABLE files.list (STRING path)
 List a directory including folders and files. More...
 
TABLE files.listfiles (STRING path)
 List a directory including only files. More...
 
TABLE files.listdirs (STRING path)
 List a directory including only folders. More...
 
TABLE files.scan (STRING src)
 Gets a content list of a compressed file (zip or rar). More...
 
NUMBER files.extractfile (STRING src, STRING filename, STRING dst)
 Extracts an specific file inside a compressed file (zip or rar). More...
 
NUMBER files.extractfile (STRING src, STRING filename, STRING dst, STRING pass)
 Extracts an specific file inside a compressed file (zip or rar). More...
 
NUMBER files.threadextractfile (STRING src, STRING filename, STRING dst)
 Extracts an specific file inside a compressed file (zip or rar) in mode THREAD. More...
 
NUMBER files.threadextractfile (STRING src, STRING filename, STRING dst, STRING pass)
 Extracts an specific file inside a compressed file (zip or rar) in mode THREAD. More...
 
NUMBER files.extract (STRING src, STRING dst)
 Function for extracting files in .zip and .rar. More...
 
NUMBER files.extract (STRING src, STRING dst, STRING pass)
 Function for extracting files in .zip and .rar. More...
 
NUMBER files.threadextract (STRING src, STRING dst)
 Function for extracting files in .zip and .rar in mode THREAD. More...
 
NUMBER files.threadextract (STRING src, STRING dst, STRING pass)
 Function for extracting files in .zip and .rar in mode THREAD. More...
 

Detailed Description

File managing.

Function Documentation

BOOLEAN files.exists ( STRING  path)

Allows to find if a file or folder exists.

Parameters
pathPath of the file or folder.
Returns
true/false Depending on whether the file / folder exists.
STRING files.cdir ( )

Allows to know the actual work path.

Returns
The path of our actual directory.
NIL files.cdir ( STRING  path)

Change the work path to the specified path.

Parameters
pathThe new work path.
Returns
Nothing.
STRING files.nofile ( STRING  path)

Remove the file from a specified path.

Parameters
pathThe path of the file / folder.
Returns
The path name without file.
STRING files.nopath ( STRING  path)

Remove the folder from a specified path.

Parameters
pathThe path of the file / folder.
Returns
The file name.
NUMBER files.rename ( STRING  name,
STRING  new 
)

Allows to rename a file or folder.

Parameters
nameThe path of the file / folder.
newThe new name of the file / folder.
Returns
1 if success, 0 otherwise.
NUMBER files.copy ( STRING  src,
STRING  dst 
)

Copy a file or folder recursively and overwrite the files in the destination folder.

Parameters
srcThe path of the file / folder to copy.
dstThe path of the folder destination.
Note
This function can use the onCopyFiles() callback, more info here .
Returns
1 if success, 0 otherwise.
NUMBER files.move ( STRING  src,
STRING  dst 
)

Move a file or folder recursively and overwrite the files in the destination folder.

Parameters
srcThe path of the file / folder to move.
dstThe path of the folder destination.
Note
If the destination file or path does not exist, the directory will be created.
Returns
1 if success, 0 otherwise.
BOOLEAN files.delete ( STRING  path)

Delete a file or folder recursively.

Parameters
pathThe path of the file / folder.
Returns
true if success, false otherwise.
Note
All folders and files included will be deleted.
NIL files.mkdir ( STRING  path)

Create a folder.

Parameters
pathPath of the folder to create.
Returns
Nothing.
NUMBER files.size ( STRING  path)

File/Folder Size (Bytes).

Parameters
pathFile/Folder Path.
Returns
The file/folder size in bytes.
STRING files.ext ( STRING  path)

Allows to know the extension of a file.

Parameters
pathFile Path
Returns
file extension.
TABLE files.list ( STRING  path)

List a directory including folders and files.

Parameters
pathDirectory path.
Returns
A table with these fields:
  • name: file or folder name(STRING).
  • path: Full path of the file or folder(STRING).
  • ctime: The date of creation of the file or folder (STRING).
  • atime: The date when last access of the file or folder (STRING).
  • mtime: The date when last modification of the file or folder (STRING).
  • mode: Those Are the access rights in the following order: "R" for Reading, "W" for Writing and "X" for Executable. In case of not having access will be displayed as follows: "---".
  • size: size in bytes, only for files (NUMBER).
  • ext: File extension, if available (STRING).
  • directory: true/false depending on whether the field is a directory or not (BOOLEAN).
Note
If an error occurs will not generate the table, will return nil.
TABLE files.listfiles ( STRING  path)

List a directory including only files.

Parameters
pathDirectory path.
Returns
A table with these fields:
  • name: file name(STRING).
  • path: Full path of the file (STRING).
  • ctime: The date of creation of the file(STRING).
  • atime: The date when last access of the file (STRING).
  • mtime: The date when last modification of the file (STRING).
  • mode: Those Are the access rights in the following order: "R" for Reading, "W" for Writing and "X" for Executable. In case of not having access will be displayed as follows: "---".
  • size: size in bytes (NUMBER).
  • ext: File extension, if available (STRING).
Note
If an error occurs will not generate the table, will return nil.
TABLE files.listdirs ( STRING  path)

List a directory including only folders.

Parameters
pathDirectory path.
Returns
A table with these fields:
  • name: folder name(STRING).
  • path: Full path of the folder(STRING).
  • ctime: The date of creation of the folder (STRING).
  • atime: The date when last access of the folder (STRING).
  • mtime: The date when last modification of the folder (STRING).
  • mode: Those Are the access rights in the following order: "R" for Reading, "W" for Writing and "X" for Executable. In case of not having access will be displayed as follows: "---".
Note
If an error occurs will not generate the table, will return nil.
TABLE files.scan ( STRING  src)

Gets a content list of a compressed file (zip or rar).

Parameters
srcPath to the compressed file.
Returns
A table with these fields:
  • name: Filename (including the folder name if the file is inside it).
  • size: Uncompressed file size in bytes.
Note
In case of error returns nil.
NUMBER files.extractfile ( STRING  src,
STRING  filename,
STRING  dst 
)

Extracts an specific file inside a compressed file (zip or rar).

Parameters
srcPath to the compressed file.
filenameFile to extract (can be easily obtained using files.scan()).
dstPath where the file will be extracted.
Note
  • This function can use the onExtractFiles() callback, more info here .
  • If the destination path doesn't exist, will be automatically created.
Returns
1 if success, 0 otherwise.
NUMBER files.extractfile ( STRING  src,
STRING  filename,
STRING  dst,
STRING  pass 
)

Extracts an specific file inside a compressed file (zip or rar).

Parameters
srcPath to the compressed file.
filenameFile to extract (can be easily obtained using files.scan()).
dstPath where the file will be extracted.
passKey or Password if required.
Note
  • This function can use the onExtractFiles() callback, more info here .
  • If the destination path doesn't exist, will be automatically created.
Returns
1 if success, 0 otherwise.
NUMBER files.threadextractfile ( STRING  src,
STRING  filename,
STRING  dst 
)

Extracts an specific file inside a compressed file (zip or rar) in mode THREAD.

Parameters
srcPath to the compressed file.
filenameFile to extract (can be easily obtained using files.scan()).
dstPath where the file will be extracted. This is a list of all of the available constants and their values:
  • __FILES_THREAD_FILE
    • Allows the name of the current file that is this drawing.
  • __FILES_THREAD_STATE
    • Lets you know the status of the extraction.
    • 0: no extraction or is starting.
    • 1: Extraction completed successfully.
    • 2: Extraction in progress.
    • -1: occurred an error in extracting.
  • __FILES_THREAD_SIZE
    • Allow cononer the number of bytes to extract from the current file.
  • __FILES_THREAD_WRITTEN
    • Allows to know the number of bytes written for the current file.
Note
  • This function allows you to continue with the script, so it runs on a secondary manner, for greater use, refer to the Examples of use of OneLua examples.
  • If the destination path doesn't exist, will be automatically created.
Returns
1 if success, 0 otherwise.
NUMBER files.threadextractfile ( STRING  src,
STRING  filename,
STRING  dst,
STRING  pass 
)

Extracts an specific file inside a compressed file (zip or rar) in mode THREAD.

Parameters
srcPath to the compressed file.
filenameFile to extract (can be easily obtained using files.scan()).
dstPath where the file will be extracted.
passKey or Password if required. This is a list of all of the available constants and their values:
  • __FILES_THREAD_FILE
    • Allows the name of the current file that is this drawing.
  • __FILES_THREAD_STATE
    • Lets you know the status of the extraction.
    • 0: no extraction or is starting.
    • 1: Extraction completed successfully.
    • 2: Extraction in progress.
    • -1: occurred an error in extracting.
  • __FILES_THREAD_SIZE
    • Allow cononer the number of bytes to extract from the current file.
  • __FILES_THREAD_WRITTEN
    • Allows to know the number of bytes written for the current file.
Note
  • This function allows you to continue with the script, so it runs on a secondary manner, for greater use, refer to the Examples of use of OneLua examples.
  • If the destination path doesn't exist, will be automatically created.
Returns
1 if success, 0 otherwise.
NUMBER files.extract ( STRING  src,
STRING  dst 
)

Function for extracting files in .zip and .rar.

Parameters
srcIs the path of the file to extract.
dstIs the path where the files will be extracted.
Note
  • This function can use the onExtractFiles() callback, more info here .
  • If the destination path doesn't exist, will be automatically created.
Returns
1 if success, 0 otherwise.
NUMBER files.extract ( STRING  src,
STRING  dst,
STRING  pass 
)

Function for extracting files in .zip and .rar.

Parameters
srcIs the path of the file to extract.
dstIs the path where the files will be extracted.
passKey or Password if required.
Note
  • This function can use the onExtractFiles() callback, more info here .
  • If the destination path doesn't exist, will be automatically created.
Returns
1 if success, 0 otherwise.
NUMBER files.threadextract ( STRING  src,
STRING  dst 
)

Function for extracting files in .zip and .rar in mode THREAD.

Parameters
srcIs the path of the file to extract.
dstIs the path where the files will be extracted. This is a list of all of the available constants and their values:
  • __FILES_THREAD_FILE
    • Allows the name of the current file that is this drawing.
  • __FILES_THREAD_STATE
    • Lets you know the status of the extraction.
    • 0: no extraction or is starting.
    • 1: Extraction completed successfully.
    • 2: Extraction in progress.
    • -1: occurred an error in extracting.
  • __FILES_THREAD_SIZE
    • Allow cononer the number of bytes to extract from the current file.
  • __FILES_THREAD_WRITTEN
    • Allows to know the number of bytes written for the current file.
Note
  • This function allows you to continue with the script, so it runs on a secondary manner, for greater use, refer to the Examples of use of OneLua examples.
  • If the destination path doesn't exist, will be automatically created.
Returns
1 if success, 0 otherwise.
NUMBER files.threadextract ( STRING  src,
STRING  dst,
STRING  pass 
)

Function for extracting files in .zip and .rar in mode THREAD.

Parameters
srcIs the path of the file to extract.
dstIs the path where the files will be extracted.
passKey or Password if required. This is a list of all of the available constants and their values:
  • __FILES_THREAD_FILE
    • Allows the name of the current file that is this drawing.
  • __FILES_THREAD_STATE
    • Lets you know the status of the extraction.
    • 0: no extraction or is starting.
    • 1: Extraction completed successfully.
    • 2: Extraction in progress.
    • -1: occurred an error in extracting.
  • __FILES_THREAD_SIZE
    • Allow cononer the number of bytes to extract from the current file.
  • __FILES_THREAD_WRITTEN
    • Allows to know the number of bytes written for the current file.
Note
  • This function allows you to continue with the script, so it runs on a secondary manner, for greater use, refer to the Examples of use of OneLua examples.
  • If the destination path doesn't exist, will be automatically created.
Returns
1 if success, 0 otherwise.