|
Post by Shawn Dao on Mar 5, 2020 10:45:48 GMT
Hi, i'm looking for a way that allow me to remove files, directories.
|
|
|
Post by Shawn Dao on Mar 5, 2020 16:30:03 GMT
|
|
|
Post by Exilereven on Mar 7, 2020 3:05:48 GMT
|
|
|
Post by Exilereven on Mar 7, 2020 3:08:02 GMT
Here's a simple example of usage in scandir
function scandir(directory)
local listFile = scriptPath() .. "__list" local command = "ls " .. directory .. " > " .. listFile os.execute(command)
local lines = {} local i = 1 for line in io.lines(listFile) do lines[#lines + 1] = line end
os.execute("rm " .. listFile) return lines end
|
|
|
Post by Exilereven on Mar 7, 2020 3:12:28 GMT
Example of write to file
DIR_MAPS is predefined path to file
default.lua is name of file to create
Always use io.close, I even git it a one second wait(1) to make sure it has time to write to file and finish.
local fPointer = io.open(DIR_MAPS .. "default.lua", "w+") fPointer:write("-- Default Map\n") fPointer:write("----------------------------------------\n") fPointer:write("random stuff ") io.close(fPointer) -- safe way to close
|
|
|
Post by Shawn Dao on Mar 7, 2020 13:04:22 GMT
Thank you.
|
|