This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Mads's profile picture

[1.21+][API]Extended file API

Started by Mads, 01 April 2012 - 08:35 AM
Mads #1
Posted 01 April 2012 - 10:35 AM
This is a new API I made, and I think it's pretty useful. It allows you to manipulate files easily.

Function List
Spoiler


exists(path) --Returns true if the file exists
getTable(path) --Returns a table with all the lines
getLine(path, n) --Returns the nth line
getText(path) --Returns the text
fappend(path, text) --Appends to a file
fwrite(path, text) --Writes to a file
fwriteAtStart(path, text) --Writes at the start of the file
fwriteFromTable(path, t) --Writes a file with each field in t as a line
fappendFromTable(path, t) --Appends to a file with each field in t as a line
fwriteAtStartFromTable(path, t) --Writes at the start of a file with each field in t as a line
replaceLine(path, n, text) --Will replace the nth line in file with text
getName(path) --Returns the filename of the file(Without the path)
getPath(path) --Returns the path only(Not the filename)
fremove(path) --Removes a file/dir



Installation
Spoiler

Unzip the zip file that comes with this topic.
Put the rom folder in mods/Computercraft/lua/rom
Put the bios.lua in mods/Computercraft/lua



Downloads
Spoiler

Flib v1.2
Flib v1.0
Zudo #2
Posted 01 October 2012 - 05:46 PM
Looks good, not tried.
Mailmanq! #3
Posted 21 November 2012 - 05:49 AM
Looks like a good idea for non-advanced users, I have been coding in CC for a while and the fs API still confuses me.