←  General

ComputerCraft | Programmable Computers for Minecraft

»

Sending Whole Directories trough recent

laica10's Photo laica10 30 Jan 2016

Hey, i'm writing an updater for my program but my program has more
than just 1 file it uses other files in other directories, so i can't figure out
how i'm going to send a whole dir. trough rednet. Keeping i mind, other
files might be added in the future so i can't send it manually 1 by 1.
Edited by laica10, 30 January 2016 - 10:43 AM.
Quote

Admicos's Photo Admicos 30 Jan 2016

  • First, you can send a index of files & directories as two files thru rednet.
  • Then, you use a for loop to read the directory file line by line and create the directories from the file.

  • After creating the directories, read the file index line by line using a for loop and use rednet.receive to get a file.
  • Once you get the file, you create a file with the name of the contents in the current line in the file index. And write it there.
  • Continue the loop until the end of the file.
You may need to modify the update sender to send files in the correct order.
Quote

laica10's Photo laica10 30 Jan 2016

yeah, here is the problem , i'm struggling with remembering dirs. in dirs. in dirs. ,....
how could i solve this?

Edited by laica10, 30 January 2016 - 10:58 AM.
Quote

Admicos's Photo Admicos 30 Jan 2016

View Postlaica10, on 30 January 2016 - 10:57 AM, said:

yeah, here is the problem , i'm struggling with remembering dirs. in dirs. in dirs. ,....
how could i solve this?
  • Don't nest too much
  • Don't remember. Just write them in a file and send the file thrugh rednet.

Edited by Admicos, 30 January 2016 - 11:02 AM.
Quote

laica10's Photo laica10 30 Jan 2016

View PostAdmicos, on 30 January 2016 - 11:02 AM, said:

View Postlaica10, on 30 January 2016 - 10:57 AM, said:

yeah, here is the problem , i'm struggling with remembering dirs. in dirs. in dirs. ,....
how could i solve this?
  • Don't nest too much
  • Don't remember. Just write them in a file and send the file thrugh rednet.

But how does the program then known wich dirs. still need to be done DIR -> dir1 -> sending
-> dir2 -> needs to be send
Quote

Admicos's Photo Admicos 30 Jan 2016

View Postlaica10, on 30 January 2016 - 11:08 AM, said:

View PostAdmicos, on 30 January 2016 - 11:02 AM, said:

View Postlaica10, on 30 January 2016 - 10:57 AM, said:

yeah, here is the problem , i'm struggling with remembering dirs. in dirs. in dirs. ,....
how could i solve this?
  • Don't nest too much
  • Don't remember. Just write them in a file and send the file thrugh rednet.

But how does the program then known wich dirs. still need to be done DIR -> dir1 -> sending
-> dir2 -> needs to be send
You create the directories before you send files.
Quote

laica10's Photo laica10 30 Jan 2016

I'll let you know if i failed at it or if i succeeded, ok i'm going to test thisa bit
Quote

H4X0RZ's Photo H4X0RZ 30 Jan 2016

It would be much easier to use some compression API/program, and send the archive over rednet.
Quote

laica10's Photo laica10 30 Jan 2016

Yeah, thanks i did it
Quote