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

Sfmg - Simple File Manget

Started by willwac, 06 October 2013 - 04:25 PM
willwac #1
Posted 06 October 2013 - 06:25 PM
Simple File ManGet

What is it?

SpoilerThis is a simple API that allows novice programmers to modify, and retrieve files.


How is this better than:


shell.run("pastebin get CODE_HERE FILE_HERE")

That's slower.


Download:

Spoiler

pastebin get 0m5KDuvr file




How to use / Functions in the API:


Get Files

Spoiler

file.get( pastebin_code , file_name )

This will save the pastebin program to the specified file without a GUI.


Get Many Files

Spoiler

file.getMany( {pastebin_code_1, pastebin_code_2, etc.}, {file_name_1, file_name_2, etc.} )

This allows you to get many pastebin programs at once, again, without a GUI.


Get File From Raw URL

Spoiler

file.getRaw( url, file )

This will take the URL provided, and put it's contents into a file.


Append to file

Spoiler

file.append( file_name, text, [no_end_of_line_character] )

This will add text to the end of a file, and if no_end_of_line_character is present, it will NOT put an end of line character (new line)


Read a Book!

Spoiler

file.read( file_name, read_all_of_the_file )

This will return a string containing a line (or all) of the file.

if read_all_of_the_file is present, the string returned will include the entire file WITHOUT end of line characters!, otherwise it will return the next line of the file without end of line characters.


ToDO

Add readMany function that will read, and return a certain amount of lines.


Thanks! Have a great day!
Zudo #2
Posted 07 October 2013 - 02:18 PM
Can we have a function to download from a raw URL?

Anyways, I wouldn't use this over writing my own functions, but good effort :)/>
willwac #3
Posted 07 October 2013 - 06:30 PM
Can we have a function to download from a raw URL?

Anyways, I wouldn't use this over writing my own functions, but good effort :)/>
Sure, I'll just make a function called getRaw( url, file )
Should I make a function caled getManyRaw( urls, files )?
willwac #4
Posted 07 October 2013 - 06:40 PM
EDIT:
Updated pastebin; that was an older version..
Added getRaw( url, file ) function; see OP (Orignal Post).
willwac #5
Posted 07 October 2013 - 07:28 PM
Just realized something:
ManGet looks like "Manget" on the title, and people might think I misspelled "magnet"
Zudo #6
Posted 08 October 2013 - 12:38 PM
Can we have a function to download from a raw URL?

Anyways, I wouldn't use this over writing my own functions, but good effort :)/>
Sure, I'll just make a function called getRaw( url, file )
Should I make a function caled getManyRaw( urls, files )?

Yes, that would probably make it more appealing.