Like the title says, call this version 0.01. This little program I have attached will create an mTCP FTP script that will backup your FAT16 file system tree to your private or perhaps public FTP server. It will also generate the corresponding restore script to be executed in the directory specified as the local root (meaning on a newly formatted disk, you need to manually create directories down to the root of the backup tree). You need to set the following mTCP variables in your MTCPCFG file:
Quite honestly, this is really a hack more than anything. These scripts are prone to error on the server side since the scripts assume that each FTP command executes successfully, and there is limited features/functionality (directories are hardcoded into the scripts). A better, more elegant solution would be one that I didn't code in less than 24 hours XD, and one that sends FTP commands directly to the server rather than piggybacking off of Mike's work. BUT... since his FTP client has a batch mode, I might as well put it to use. It could also potentially be put as a command into the FTP program itself. Additionally, and more importantly, I would've needed to implement nearly all the functionality I have already (directory traversal and name conversion) had I decided to just create my own client from scratch (which I have done and discarded no less than 3 times already), so this is certainly a start to work up to that.
This will probably go through a rewrite; traversing the directory tree and creating the file system data structure was HELL, especially converting path names. I'm not proud of the function that I've created that does it (there HAS to be an easier, more elegant way than my solution, which is attached), the code is a bit difficult to read and littered with commented debug statements- as well as requiring this mess of arguments:
I had to pass a number of variables by address to be modified :/. Of course, the code is also most likely a bit inefficient; there are 11 different error codes and checks for directory traversal alone. In light of Heartbleed, I've been programming more defensively. This uses OpenWatcom's POSIX implementation functions to traverse the directory tree. POSIX opendir() will fail on hardware (not DOSBOX) if the initial opendir() does not have a trailing backslash, for some reason- at least I THINK it does... it acts so weird :/!
I have verified this script (backup) works on my PC AT- it takes 2 to 5 seconds for a 20MB/40ms seek drive with a dozen or so directories to generate a script. MPUTs with a large number of files- 500+- will fail. I haven't decided how to handle this yet, or if there is a way to query how long the FTP STOR strings the server must support at a minimum.
I'm not ready to create a git repo just yet, but I will post the source and the exe (put it into it's own MTCP APP directory in the MTCP tree). However, I hope some people are willing to test on their FAT16 drives if they have Network-Attached Storage (NAS) with FTP.
Enjoy! :D
- NWBACKUP_SERVER- Ip address/name of server. Not used, but must be set.
- NWBACKUP_USERNAME- Username to the server that you wish to send backups.
- NWBACKUP_PASSWORD- Password to said server.
- NWBACKUP_DIR- Directory on the server to hold your backup directories.
- NWBACKUP_FORMAT- Set to "msdos3.3". Not used, but must be set.
- NWTEMP- Not used, and need not be set. Will hold the directory to store temp control files eventually.
Quite honestly, this is really a hack more than anything. These scripts are prone to error on the server side since the scripts assume that each FTP command executes successfully, and there is limited features/functionality (directories are hardcoded into the scripts). A better, more elegant solution would be one that I didn't code in less than 24 hours XD, and one that sends FTP commands directly to the server rather than piggybacking off of Mike's work. BUT... since his FTP client has a batch mode, I might as well put it to use. It could also potentially be put as a command into the FTP program itself. Additionally, and more importantly, I would've needed to implement nearly all the functionality I have already (directory traversal and name conversion) had I decided to just create my own client from scratch (which I have done and discarded no less than 3 times already), so this is certainly a start to work up to that.
This will probably go through a rewrite; traversing the directory tree and creating the file system data structure was HELL, especially converting path names. I'm not proud of the function that I've created that does it (there HAS to be an easier, more elegant way than my solution, which is attached), the code is a bit difficult to read and littered with commented debug statements- as well as requiring this mess of arguments:
Code:
int8_t allocDirs(const char * name, const uint16_t indexMaxSize, \
const uint16_t dirNameMaxSize, char *** dirStr, uint16_t * numDirs, \
uint16_t * dirStrSize, int level)
I have verified this script (backup) works on my PC AT- it takes 2 to 5 seconds for a 20MB/40ms seek drive with a dozen or so directories to generate a script. MPUTs with a large number of files- 500+- will fail. I haven't decided how to handle this yet, or if there is a way to query how long the FTP STOR strings the server must support at a minimum.
I'm not ready to create a git repo just yet, but I will post the source and the exe (put it into it's own MTCP APP directory in the MTCP tree). However, I hope some people are willing to test on their FAT16 drives if they have Network-Attached Storage (NAS) with FTP.
Enjoy! :D