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

Get all files from a folder in GitHub and put them inside a computer's folder

Started by Lua.is.the.best, 11 May 2014 - 03:53 PM
Lua.is.the.best #1
Posted 11 May 2014 - 05:53 PM
Hello.
I am creating an installer, for an OS.
The problem is, the method I am using requires me to use a function like:
get(string repoFile, string saveTo)
So, for example, if I wanted to get a file called EpicTest/Test off a repo and put it in EpicTest, I would use:
get("EpicTest/Test","EpicTest/Test")
If it didn't exist, I would add mkdir("EpicTest") before the function. (person-made functions rule!)
How do I get a system that can download a whole folder at a time?
For example, instead of typing

get("epic/Test1","Test1")
get("epic/Test2","Test2")
to get those two files, to get a whole folder, I could type
getFolder("epic","epic")
The first "epic" is the repo folder.
The second one is the saving directory.
CometWolf #2
Posted 11 May 2014 - 06:28 PM
You'd have to scan the whole folder for files obviously. I don't know much about JSON, but i managed to cobble together a functional installer using string.match.
http://pastebin.com/VTZ6CqWY
Seems there is an url that contains the contents of the repo,
https://api.github.com/repos/user/repo/contents
It's been awhile since i did this, and i didn't bother commenting it lol. Anyways have a look through it and see if you can figure out what you're looking for.
Lua.is.the.best #3
Posted 11 May 2014 - 07:16 PM
:D/>
Thank you!
I am definitely using this! *copies*

And wait, how do I add a blacklist?
I understand the api.github and all that, but how do I use it?
I'm confused, especially with the way they describe the stuff.
For example my desktop folder =
EDIT: Maybe I use (self)????
Edited on 11 May 2014 - 05:17 PM