I collect here small programs I wrote in order to get familiar with specific technical problems. These code snippets are normally very short - they concentrate on the essence of the problems. They may contain code that I found elsewhere on the internet. Note that my snippets do not answer all questions related with the given problem: if you look into the code you will see that very often open questions still exist!

Directory traversal(Linux and Windows)

I often need functions to traverse directories under Linux and Windows. Strange enough - there is no common API that works for both operation systems (if you use WxWidgets or PHP or similar frameworks then you have a common API). Here is the basic C++ code for Windows 32 Bit. A similar basic source code for Linux is here. I didn't consider seriously the method system("dir ...") under Windows or system("ls ...") (Linux).

Simple backup to a remote server (Windows)

I find the usual backup programs difficult to configure. I wrote therefor this simple backup program based on the directory traversal program described above. It is designed to help people like me - i.e. typically software engineers changing every day source code, configuration files or documentation. A Windows executable (32 Bit) is here. This simple program (only ca. 400 lines of C++ code) is based on the the following ideas: It is essential that FTP supports the option "-s:controlFile" (not all FTP versions support this option). A typical control file (named "ftpcmd.pat") looks like this:

     cd myTopDirectory
     cd private
     cd Backup
     cd 20160827

You may change or enhance this control file pattern in order to reflect your needs. Please test it then in a "black window" before it is used by backupEH. Note that the line "put " (the space after "put" is important) is modified by this program: the program appends there the respective backup candidate file. The FTP command is executed for each single file that meets the date requirements.

A typical parameterized call of the program:

     backupEH .\mySources 2016-08-26

The first parameter is the directory from which the backup starts. The second parameter is the date from which on files are considered. Note that the given date must always be in format "YYYY-MM-DD". I think the source code is well documented. Compile it with the Digital Mars C++ compiler( modify the include path in option -I):

     DMC -mn -DDMC -DWIN32 -Ic:\huckert\dm\stlport backupEH.cpp

The program filters out some file types like .map files or .obj files. You may change that in the source code. This program uses no special libraries except STL (and even STL is not absolutely needed). It should also be compilable with Microsoft C++ oder GNU g++.

Note that I didn't write this for UNIX/Linux though it should run there with a few changes. I didn't test it neither under other versions of Windows except Windows 7. As mentioned above this solution depends heavenly on the command line program FTP - several incompatible versions may exist in the Windows world.


If you want to contact me: this is my
mail address