Can I save into a specific folder?
Asked Answered
D

1

7

While learning how to create Lua file output code with the support of LÖVE, I've always hated that LÖVE filesystem handler always saved the specific file somewhere in C:/Documents and Settings/...

How can I create a code that saves a file into a specific folder that I'd like to define (and maybe to change while running the application)?

Deliadelian answered 3/11, 2013 at 22:58 Comment(0)
C
6

The love.filesystem library doesn't let you do anything outside the sandbox. However, LÖVE doesn't disable Lua's built in io library, so you can use io.open to open files outside the sandbox and read/write them as normal, as well as other Lua functions like require and loadfile.

It also doesn't restrict loading of external modules, so you can (for example) require "lfs" to load LuaFileSystem and use that, if it is installed.

Circumlocution answered 4/11, 2013 at 0:55 Comment(2)
I don't want to install lfs, but anyway, thanks for answering!Milden
You don't need to install lfs for basic file io, just use the io library. If you want to do something like list directory contents, though, you'll need it.Circumlocution

© 2022 - 2024 — McMap. All rights reserved.