Module dryos
DryOS operating system functions.
TODO: what about Penlight-like API for file I/O (see e.g. pl.path, pl.dir, pl.file, pl.utils)?
Or maybe even porting a subset of Penlight and/or LFS?
Functions
directory(path) | Creates a directory object that is used to get information about a directory
This function does not actually create a directory on the file system, it just creates an object that represents a directory. |
remove(filename) | Deletes a file from the card. |
rename(filename) | Renames/moves a file on the card (or between cards). |
call(function[, arg]) | Calls an eventproc (a function from the camera firmware which can be called by name). |
Fields
clock | Get the number of the seconds since camera startup. |
ms_clock | Get the number of milliseconds since camera startup. |
image_prefix | Get/Set the image filename prefix (e.g. "IMG_"). |
config_dir | Get the ML config directory. |
ml_card | Get the card ML was started from. |
shooting_card | Get the shooting card (the one selected in Canon menu for taking pictures / recording videos). |
cf_card | Get the CF card if your camera has one, otherwise nil |
sd_card | Get the SD card if your camera has one, otherwise nil |
date | Gets a table representing the current date/time. |
Class date
date.sec | Second |
date.min | Minute |
date.hour | Hour |
date.day | Day |
date.month | Month |
date.year | Year |
date.wday | Day of week |
date.yday | Day of year |
date.isdst | Daylight Savings |
Class directory
directory:create() | Creates a directory. |
directory:children() | Get a list of subdirectories, as table of directory objects. |
directory:files() | Get a list of file names (with full path) in this directory, as table of strings. |
directory.path | Get the full path of the directory. |
directory.exists | Get whether or not the directory exists. |
directory.parent | Get a directory object that represents the current directory's parent |
Class card
card.drive_letter | Get the drive letter (A or B). |
card.dcim_dir | Get the DCIM directory for this card. |
card.file_number | Get the current Canon file number (e.g. |
card.folder_number | Get the current Canon folder number (e.g. |
card.free_space | Get the current free space (in MiB). |
card:image_path([file_offset=0[, extension=nil]]) | Get current/previous/future still image path. |
card.type | Get the type of card ("SD" or "CF" ). |
Functions
- directory(path)
-
Creates a directory object that is used to get information about a directory
This function does not actually create a directory on the file system, it just creates an object that represents a directory. To actually create the directory in the file system call
directory:create()
.Parameters:
- path string
Returns:
Usage:
local mydir = dryos.directory("mydir") if mydir.exists == false then mydir:create() end for i,v in ipairs(mydir:files()) do print("filename: "..v) end
- remove(filename)
-
Deletes a file from the card.
Parameters:
- filename string
Returns:
-
bool
success
- rename(filename)
-
Renames/moves a file on the card (or between cards).
Parameters:
- filename string
Returns:
-
bool
success
- call(function[, arg])
-
Calls an eventproc (a function from the camera firmware which can be called by name).
See Eventprocs.
Dangerous - you need to compile Lua yourself in order to enable it.
Parameters:
- function string the name of the function to call
- arg argument to pass to the call (optional)
Fields
- clock
-
Get the number of the seconds since camera startup.
- clock int
- ms_clock
-
Get the number of milliseconds since camera startup.
- ms_clock int
- image_prefix
-
Get/Set the image filename prefix (e.g. "IMG_").
Set to empty string to restore default value.
- image_prefix string
- config_dir
-
Get the ML config directory.
- config_dir directory
- ml_card
-
Get the card ML was started from.
- ml_card card
- shooting_card
-
Get the shooting card (the one selected in Canon menu for taking pictures / recording videos).
- shooting_card card
- cf_card
-
Get the CF card if your camera has one, otherwise nil
- cf_card card or nil
- sd_card
-
Get the SD card if your camera has one, otherwise nil
- sd_card card or nil
- date
-
Gets a table representing the current date/time.
- date date
Class date
Represents a date/time- date.sec
-
Second
- sec int
- date.min
-
Minute
- min int
- date.hour
-
Hour
- hour int
- date.day
-
Day
- day int
- date.month
-
Month
- month int
- date.year
-
Year
- year int
- date.wday
-
Day of week
- wday int
- date.yday
-
Day of year
- yday int
- date.isdst
-
Daylight Savings
- isdst bool
Class directory
Represents a directory- directory:create()
-
Creates a directory.
Returns:
-
bool
whether or not the directory was sucessfully created
- directory:children()
-
Get a list of subdirectories, as table of directory objects.
Returns:
- directory:files()
-
Get a list of file names (with full path) in this directory, as table of strings.
Returns:
- directory.path
-
Get the full path of the directory.
- path string
- directory.exists
-
Get whether or not the directory exists.
- exists bool
- directory.parent
-
Get a directory object that represents the current directory's parent
- parent directory
Class card
Represents a card (storage media). Inherits from directory- card.drive_letter
-
Get the drive letter (A or B).
- drive_letter string
- card.dcim_dir
-
Get the DCIM directory for this card.
- dcim_dir directory
- card.file_number
-
Get the current Canon file number (e.g. IMG_1234.CR2 -> 1234).
- file_number int
- card.folder_number
-
Get the current Canon folder number (e.g. DCIM/101CANON => 101).
- folder_number int
- card.free_space
-
Get the current free space (in MiB).
FIXME: does not update after writing files from ML code.
- free_space int
- card:image_path([file_offset=0[, extension=nil]])
-
Get current/previous/future still image path. Examples:
B:/DCIM/100CANON/IMG1234.CR2
(with extension)B:/DCIM/100CANON/IMG1234
(without extension)
Parameters:
- file_offset int 0 = last saved image, positive = future images, negative = previous images. (default 0)
- extension
string or nil
Suffix to append to the file name:
".CR2"
or".JPG"
or
nil
= autodetect from picture quality setting (CR2 for RAW+JPEG). (default nil)
Returns:
- card.type
-
Get the type of card (
"SD"
or"CF"
).- type string