Phonebot developer's reference/Object reference/Using the Phonebot file object
|children||R||Returns array of file objects. Coerces to false if no children exist.|
|cursor_pos||RW||The current position of the access cursor|
|name||R||The name of the file or folder|
|parent||R||The path of the parent file or folder. is_folder will be true. Coerces to false if no parent exists (i.e. this is the root).|
|path||R||The full path of the file object. May not exist or may not be invalid.|
|size||RW||The size of the file in bytes. Setting the value resizes the file.|
Methods (file management)
|boolean = copy_to(path)||Copy the file or folder to the path. The path must not exist.|
|boolean = create_file()||Create the file. The file must not exist.|
|boolean = create_folder()||Create the folder. The folder must not exist.|
|boolean = delete()||Delete the file or folder.|
|boolean = move_to(path)||Move the file or folder to the path. The path must not exist.|
The following table illustrates how the variable value and path parameter value are combined for copy and move calls. The destination will never be deleted. For move calls, the source will be deleted only if it is moved completely.
|Variable value||Path parameter||Description|
|/a/x.txt||/b/y.txt||y.txt is a copy of x.txt|
|/a/x.txt||/a/y.txt||A move can be considered a rename in this situation.|
|/a||/b/c||Any files and folders under "a" will also be created under "c"|
|/a||/b||A move can be considered a rename in this situation.|
Methods (content management)
Data is returned from reads as an array of bytes. Use
array.byte_to_string() to convert to a string.
Data passed in for searching or writing must be an array of bytes. Use
string.to_byte_array() to convert from a string, or create the array using decimal values 0-255.
Writes at positions less than the file size will overwrite existing data (as opposed to inserting).
|data = read(len)||Read a len amount of data from the current cursor position|
|data = read_line()||Read from the current cursor position to the next new line. The new line character is not included.|
|data = read_to(data)||Read from the current cursor position to the next section that matches data. The matched data is not included.|
|pos = write(data)||Write a the data at the current cursor position, return the new cursor position.|
|pos = write_line(data)||Write the data at the current cursor position and append a new line, return the new cursor position.|
- See also module.show_file_dialog()