1

I have been looking for a way to transfer everything in a specific directory (sub directories and files alike) from a server to a client. The transfer is done one file at a time.

hence, my questions are:

  1. Sender side: I am planning on using the link below to list all files and to send them. Is there a faster way to do it (using some functions?) than doing it manually?

How to recursively list directories in C on Linux?

  1. Receiver side: once the files are received, how can I reassemble the files in their respective folders? is there a better way than sending the paths and create the appropriate folders?
  2. How these server/client file transfers like FTP are usually handled in c ? Is it implemented like the way I described earlier?

All in all, what I want to know is how the directory tree are sent & received in file transfer protocols and what libraries are used in c.

Thanks a lot!

CybWay
  • 11
  • 2
  • 1
    1. Use`fts.h` or `ftw.h` and don't look at 9 year old posts about the availability of library functions. For the rest of your questions: it doesn't really look like you want to program in C. – Cheatah Jul 17 '21 at 17:57
  • @Cheatah thank you for your answer. Regarding "fts.h or ftw.h" I am assuming you are refering to the first question. But for the rest, I want to do it in C. – CybWay Jul 17 '21 at 18:07
  • `Is there a better way` what is used to measure "better"? `how can I restructure the files in their respective folders?` "Re-structure"? Don't you want to preserve the structure? `is there a better way than sending the paths and create the appropriate folders?` There is no other way - yo _have to_ send the filenames and _have to_ create directories. `How these server/client transfers are usually handled in c ?` "Usually" is a hard term - everyone uses something else, there is no "usually". There are so many [protocols](https://en.wikipedia.org/wiki/Lists_of_network_protocols) and you can... – KamilCuk Jul 17 '21 at 19:31
  • ... write your own protocol if you want to. `Is it implemented like the way I want to do it ?` You have to look at a particular implementation (of what? that question is unclear.) and find out. `or is there something more efficient that I don't know of?` More efficient as compared to? `FTP example in c` Pro tip: add "github" to google search. My google search for "FTP example in c github" results in https://gist.github.com/AlexFrazer/4040354 and https://github.com/zTrix/simple-ftp/blob/master/server.c. But also curl and vsftpd are written in C - almost all core linux software is in C. – KamilCuk Jul 17 '21 at 19:36
  • Overall - you asked multiple very broad questions. This is a forum for _specific_ programming questions. If you are `looking for a way to transfer everything in a specific directory` there is no point in reinventing the wheel and use `rsync` (and it is also written in C...). Please see [ask] and I recommend [question checklist](https://meta.stackoverflow.com/questions/260648/stack-overflow-question-checklist). – KamilCuk Jul 17 '21 at 19:37
  • @KamilCuk Thank you for your answers/comments i tried to reedit my post to become less broad. – CybWay Jul 17 '21 at 22:24
  • @KamilCuk Thank you for your answers/comments i tried to reedit my post to become less broad. `Is there a better way` I meant a pre-existing library to help in implementing the program. `Usually` I updated to it was regarding FTP implementation. regarding github, i have seen few but they were not suitable. thanks for git hub and rsync tool. Could you put your comments as an answer ? it was what I was looking for. – CybWay Jul 17 '21 at 23:06

0 Answers0