Giter VIP home page Giter VIP logo

lovefs's Introduction

lovefs

Load and save files outside love.filesystem

with ffi

The ffi code was mostly adapted (with my sincerest gratitude) from

https://github.com/nyfair/fi-luajit (Windows) and https://github.com/Igalia/pflua (Posix).

To start, (look at the demo)

fs = lovefs(dir[string]) -- if no dir is given, start on UserDirectory

---------------------------------------- lovefs.lua -------------------------------------------------

fs.current -- Current Directory [string] (don't change it, use fs:cd(dir))

fs.drives, fs.dirs, fs.files, fs.all -- drives, directories and files [tables] of current dir

fs.selectedFile -- [string] used by fs:loadImage, fs:loadSource, fs:loadFont and fs:saveImage if no source is given

fs.home -- user directory [string]

fs.filter -- [table] with extensions, like {'jpg', 'png'}. Used by fs:ls to filter files. Don't forget to NIL!

fs.showHidden -- Show or hide hidden files and directories. Default: FALSE

function fs:updDrives() -- update drives list

The next functions accept absolute and relative (to current) paths

function fs:ls(dir) -- return dir (absolute path) [string], tDirs, tFiles, tAll [tables]. Return FALSE if dir don't exist. Alias: fs:dir(dir)

function fs:exists(path) -- return exists, isDirectory, isFile [booleans]

function fs:isDirectory(path) -- return TRUE if is directory.

function fs:isFile(path) return TRUE if is file.

function fs:cd(dir) -- Change directory. Populate fs.dirs and fs.files and fs.all with the new directory contents. Return TRUE if successful

function fs:up() -- move to parent directory (using cd())

function fs:setFilter(filter [nil, table or string]) -- sets fs.filter and calls fs:cd(). String can be 'File type | *.ext1 *.ext2'

function fs:switchHidden() -- switch fs.showHidden

function fs:absPath(path) -- return absolute paths

function fs:loadImage(source) -- return image. Use fs.selectedFile if no source is given

function fs:loadSource(source) --return sound. Use fs.selectedFile if no source is given

function fs:loadFont(size, source) --return font. Use fs.selectedFile if no source is given

function fs:saveImage(img, dest) -- Need Canvas support. Return FALSE on failure. Use fs.selectedFile if no source is given

This function only accept absolute paths

function fs:copy(source, dest) -- copy file

---------------------------------------- gspotDialog.lua and loveframesDialog.lua and luigiDialog.lua ------------------------------------------------

fs:loadDialog(gui, label, filters) or fs:loadDialog(gui.Layout, label, filters) for Luigi

fs:saveDialog(gui, label) or fs:saveDialog(gui.Layout, label) for Luigi

filters example: {'All | *.*', 'Image | *.jpg *.png *.bmp', 'Sound | *.mp3 *.wav'}

On close with OK, the path of the chosen file is at fs.selectedFile

lovefs's People

Contributors

linux-man avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.