IO

Library for handling io operations with the file system.


Source: pkg/lua/lib/io.go | Import: io

Functions


decode

decode(path, model?) -> int<collection.IMAGE>

Arguments

  • path string - The path to grab the image from.
  • model int<image.ColorModel> - Used only to specify default when there is an unsupported color model.
Return Values

  • int<collection.IMAGE>
decode_string

decode_string(name, encoding, data, model?) -> int<collection.IMAGE>

Arguments

  • name string
  • encoding int<image.Encoding>
  • data string
  • model int<image.ColorModel> - Used only to specify default when there is an unsupported color model.
Return Values

  • int<collection.IMAGE>
decode_config

decode_config(path) -> int, int, bool

Arguments

  • path string - The path to grab the image from.
Return Values

  • int - The width of the image.
  • int - The height of the image.
  • bool - If the image can be decoded.
decode_config_string

decode_config_string(encoding, data) -> int, int, bool

Arguments

  • encoding int<image.Encoding>
  • data string
Return Values

  • int - The width of the image.
  • int - The height of the image.
  • bool - If the image can be decoded.
decode_into

decode_into(path, id, model?)

Arguments

  • path string - The path to grab the image from.
  • id int<collection.INT> - Image ID to overwrite with decoded image.
  • model int<image.ColorModel> - Used only to specify default when there is an unsupported color model.
decode_into_string

decode_into_string(name, encoding, data, id, model?)

Arguments

  • name string
  • encoding int<image.Encoding>
  • data string
  • id int<collection.INT> - Image ID to overwrite with decoded image.
  • model int<image.ColorModel> - Used only to specify default when there is an unsupported color model.
decode_cached

decode_cached(path, model?) -> int<collection.CRATE_CACHEDIMAGE>

Arguments

  • path string - The path to grab the image from.
  • model int<image.ColorModel> - Used only to specify default when there is an unsupported color model.
Return Values

  • int<collection.CRATE_CACHEDIMAGE>
decode_cached_string

decode_cached_string(encoding, data, model?) -> int<collection.CRATE_CACHEDIMAGE>

Arguments

  • encoding int<image.Encoding>
  • data string
  • model int<image.ColorModel> - Used only to specify default when there is an unsupported color model.
Return Values

  • int<collection.CRATE_CACHEDIMAGE>
decode_png_data

decode_png_data(path, model?) -> int<collection.IMAGE>, []struct<image.PNGDataChunk>

Arguments

  • path string - The path to grab the image from.
  • model int<image.ColorModel> - Used only to specify default when there is an unsupported color model.
Return Values

  • int<collection.IMAGE>
  • []struct<image.PNGDataChunk>
decode_png_data_string

decode_png_data_string(name, data, model?) -> int<collection.IMAGE>, []struct<image.PNGDataChunk>

Arguments

  • name string
  • data string
  • model int<image.ColorModel> - Used only to specify default when there is an unsupported color model.
Return Values

  • int<collection.IMAGE>
  • []struct<image.PNGDataChunk>
decode_favicon

decode_favicon(path, encoding, model?) -> []int<collection.IMAGE>

Decodes an ICO type favicon file into an array of images.

Arguments

  • path string - The path to grab the image from.
  • encoding int<image.Encoding> - The encoding to use for the extracted images.
  • model int<image.ColorModel> - Used only to specify default when there is an unsupported color model.
Return Values

  • []int<collection.IMAGE>
decode_favicon_string

decode_favicon_string(name, data, encoding, model?) -> []int<collection.IMAGE>

Decodes an ICO type favicon into an array of images.

Arguments

  • name string
  • data string
  • encoding int<image.Encoding> - The encoding to use for the extracted images.
  • model int<image.ColorModel> - Used only to specify default when there is an unsupported color model.
Return Values

  • []int<collection.IMAGE>
decode_favicon_cursor

decode_favicon_cursor(path, encoding, model?) -> []int<collection.IMAGE>, []int

Decodes a CUR type favicon file into an array of images and hotspots.

Arguments

  • path string - The path to grab the image from.
  • encoding int<image.Encoding> - The encoding to use for the extracted images.
  • model int<image.ColorModel> - Used only to specify default when there is an unsupported color model.
Return Values

  • []int<collection.IMAGE>
  • []int - Pairs of ints representing the hotspot of each cursor. e.g. [x1, y1, x2, y2, ...]
decode_favicon_cursor_string

decode_favicon_cursor_string(name, data, encoding, model?) -> []int<collection.IMAGE>, []int

Decodes a CUR type favicon into an array of images and hotspots.

Arguments

  • name string
  • data string
  • encoding int<image.Encoding> - The encoding to use for the extracted images.
  • model int<image.ColorModel> - Used only to specify default when there is an unsupported color model.
Return Values

  • []int<collection.IMAGE>
  • []int - Pairs of ints representing the hotspot of each cursor. e.g. [x1, y1, x2, y2, ...]
decode_favicon_config

decode_favicon_config(path) -> struct<io.FaviconConfig>

Arguments

  • path string - The path to grab the image from.
Return Values

  • struct<io.FaviconConfig>
decode_favicon_config_string

decode_favicon_config_string(data) -> struct<io.FaviconConfig>

Arguments

  • data string
Return Values

  • struct<io.FaviconConfig>
decode_gif

decode_gif(path, name, encoding, model?) -> struct<image.GIF>

Arguments

  • path string
  • name string
  • encoding int<image.Encoding>
  • model int<image.Model>
Return Values

  • struct<image.GIF>
decode_gif_string

decode_gif_string(data, name, encoding, model?) -> struct<image.GIF>

Arguments

  • data string
  • name string
  • encoding int<image.Encoding>
  • model int<image.Model>
Return Values

  • struct<image.GIF>
load_embedded

load_embedded(embedded, model?) -> int<collection.IMAGE>

Arguments

  • embedded int<io.Embedded>
  • model int<image.ColorModel> - Used only to specify default of unsupported color models.
Return Values

  • int<collection.IMAGE>
encode

encode(id, path)

Arguments

  • id int<collection.IMAGE> - The image id to encode and save to file.
  • path string - The directory path to save the file to.
encode_string

encode_string(id) -> string

@blocking
Arguments

  • id int<collection.IMAGE> - The image id to encode and save to file.
Return Values

  • string
encode_png_data

encode_png_data(id, chunks, path)

Arguments

  • id int<collection.IMAGE> - The image id to encode and save to file.
  • chunks []struct<image.PNGDataChunk> - The PNG data chunks to encode with the image.
  • path string - The directory path to save the file to.
encode_png_data_string

encode_png_data_string(id, chunks) -> string

@blocking
Arguments

  • id int<collection.IMAGE> - The image id to encode and save to file.
  • chunks []struct<image.PNGDataChunk> - The PNG data chunks to encode with the image.
Return Values

  • string
encode_favicon

encode_favicon(name, ids, path)

@blocking
Arguments

  • name string - The name of the favicon file, without the extension.
  • ids []int<collection.IMAGE> - List of image ids to encode and save into a favicon.
  • path string - The directory path to save the file to.
encode_favicon_string

encode_favicon_string(ids) -> string

@blocking
Arguments

  • ids []int<collection.IMAGE> - List of image ids to encode and save into a favicon.
Return Values

  • string
encode_favicon_cursor

encode_favicon_cursor(name, ids, hotspots, path)

@blocking
Arguments

  • name string - The name of the favicon file, without the extension.
  • ids []int<collection.IMAGE> - List of image ids to encode and save into a favicon.
  • hotspots []int - Pairs of ints representing the hotspot of each cursor.
  • path string - The directory path to save the file to.
encode_favicon_cursor_string

encode_favicon_cursor_string(ids, hotspots) -> string

@blocking
Arguments

  • ids []int<collection.IMAGE> - List of image ids to encode and save into a favicon.
  • hotspots []int - Pairs of ints representing the hotspot of each cursor.
Return Values

  • string
encode_gif

encode_gif(name, gif, path)

@blocking
Arguments

  • name string - Excluding the extension.
  • gif struct<image.GIF>
  • path string - The directory path to save the file to.
encode_gif_string

encode_gif_string(gif) -> string

@blocking
Arguments

  • name string - Excluding the extension.
  • gif struct<image.GIF>
Return Values

  • string
encode_webp

encode_webp(id, path, preset, lossy, level)

Arguments

  • id int<collection.IMAGE> - The image id to encode and save to file.
  • path string - The directory path to save the file to.
  • preset int<image.WebPPreset>
  • lossy bool
  • level float
encode_webp_string

encode_webp_string(id, preset, lossy, lvel) -> string

@blocking
Arguments

  • id int<collection.IMAGE> - The image id to encode and save to file.
  • preset int<image.WebPPreset>
  • lossy bool
  • level float
Return Values

  • string
load_palette

load_palette(path) -> []struct<image.Color>

Use to load a hex color palette file; For example, from lospec.

Arguments

  • path string - Path to a .hex file for the palette.
Return Values

  • []struct<image.Color>
save_palette

save_palette(path, colors)

Discards alpha channels.

Arguments

  • path string - File to save hex data to, filename should end in .hex.
  • colors []struct<image.Color>
remove

remove(path, all?)

Arguments

  • path string
  • all bool - If to remove all directories going to the given path.
exists

exists(path) -> bool, bool

Arguments

  • path string
Return Values

  • bool - If the file exists.
  • bool - If the file is a directory.
dir

dir(path) -> []string

Arguments

  • path string
Return Values

  • []string - Array containing all file paths in the directory.
dir_img

dir_img(path) -> []string

Arguments

  • path string - The directory path to scan for images.
Return Values

  • []string - Array containing paths to each valid image in the directory.
dir_txt

dir_txt(path) -> []string

Arguments

  • path string - The directory path to scan for txt.
Return Values

  • []string - Array containing paths to each valid txt in the directory.
dir_json

dir_json(path) -> []string

Arguments

  • path string - The directory path to scan for json.
Return Values

  • []string - Array containing paths to each valid json in the directory.
dir_dir

dir_dir(path) -> []string

Arguments

  • path string - The directory path to scan for directories.
Return Values

  • []string - Array containing paths to each valid dir in the directory.
dir_filter

dir_filter(path, filter) -> []string

Arguments

  • path string - The directory path to scan.
  • filter []string - Array of file extensions to include.
Return Values

  • []string - Array containing paths to all files that match the filter.
dir_recursive

dir_recursive(path) -> []string

Arguments

  • path string - The directory path to scan for files, within all sub-directories.
Return Values

  • []string - Array containing paths to each valid file in the directory and sub-directories.
dir_recursive_filter

dir_recursive_filter(path, filter) -> []string

Arguments

  • path string - The directory path to scan for files, within all sub-directories.
  • filter []string - Array of file extensions to include.
Return Values

  • []string - Array containing paths to each valid file in the directory and sub-directories.
mkdir

mkdir(path, all?)

Arguments

  • path string
  • all bool - If to create all directories going to the given path.
path_join

path_join(paths...) -> string

Arguments

  • paths string...
Return Values

  • string
wd

wd() -> string

Returns the dir of the currently running workflow.

Return Values

  • string
default_input

default_input() -> string

Returns the default input directory specified in the config file.

Return Values

  • string
default_output

default_output() -> string

Returns the default output directory specified in the config file.

Return Values

  • string
base

base(pth) -> string

Returns the name of the file only, without the extension or trailing path.

Arguments

  • pth string
Return Values

  • string
path_to

path_to(pth) -> string

Returns the path to a file.

Arguments

  • pth string
Return Values

  • string
ext

ext(pth) -> string

Returns the ext of the file only.

Arguments

  • pth string
Return Values

  • string

Constants


Embedded
  • EMBEDDED_ICONCIRCLE_16x16
  • EMBEDDED_ICONCIRCLE_32x32
  • EMBEDDED_ICON_16x16
  • EMBEDDED_ICON_32x32
  • EMBEDDED_ICON_180x180
  • EMBEDDED_ICON_192x192
  • EMBEDDED_ICON_512x512
ICOType
  • ICOTYPE_ICO
  • ICOTYPE_CUR

Structs


FaviconConfig

Properties

  • type int<io.ICOType> - The type of favicon.
  • count int - The number of images in the favicon.
  • largest int - The index of the largest image in the favicon.
  • entries []struct<io.ICOEntry> - The entries of the favicon.
ICOEntry

Properties

  • width int - The width of the image.
  • height int - The height of the image.
  • data1 int - The x hotspot of the cursor; always 0 for icons.
  • data2 int - The y hotspot of the cursor; always 0 for icons.