Auto-backup : Makefiles (Eclipse and CDT specifically)

This is a discussion on Auto-backup : Makefiles (Eclipse and CDT specifically) within the C++ Programming forums, part of the General Programming Boards category; I dunno if anyone even uses Eclipse, but I'm pretty sure this is applicable to any make-file using environment. My ...

  1. #1
    Registered User
    Join Date
    May 2003
    Posts
    37

    Auto-backup : Makefiles (Eclipse and CDT specifically)

    I dunno if anyone even uses Eclipse, but I'm pretty sure this is applicable to any make-file using environment.

    My friend (with a little help from me) made a C executable that uses winrar to automatically backup files on make, or by a special make using the backup option.

    I've included the exe file, and I'll also post the code. It creates backups in the form:

    Backup-YYYYMMDD-hhmm.rar

    YYYY = 4 digit year (2003)
    MM - 2 digit month (01 - 12)
    DD = day (01 to 31)
    hh = hour (00 to 23)
    mm = minutes (00 to 59)

    It backs up all files in the directory, minus any other .rar files. This can easily be changed one of two ways...by adding more -x*.xxx files to exclude, or by adding a bunch of *.xxx files to include. (see winrar help for more info)

    I found it very handy...thought I'd share.

    You can also add the command to your makefile, by adding (under all: or by adding a backup: section) backup.exe

    Feedback would be appreciated!

    --Ashiq

    Code:
    #include "iostream"
    #include "time.h"
    #include "string.h"
    #include <stdlib.h>
    
    using namespace std;
    
    int main(void)
    {
        char tmpbuf[30];
        time_t ltime;
        struct tm *today;
    	char cmdline[128] = "rar a -r -x*.rar ";
    
        /* Use time structure to build a customized time string. */
    	time( &ltime );
        today = localtime( &ltime );
    
        /* Use strftime to build a customized time string. */
        strftime( tmpbuf, 128,
             "Backup-%Y%m%d-%H%M.rar", today );
    
    	cout << "Backing up files now!\n";
    	cout << "Writing file: ";
    	cout << tmpbuf;
    	strcat( cmdline, tmpbuf);
    	strcat( cmdline, "\"");
    	system(cmdline);
    					
    	return 0;
    
    }
    Attached Files Attached Files

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problems with Boost Regex in Eclipse CDT
    By Hunter0000 in forum C++ Programming
    Replies: 4
    Last Post: 01-13-2010, 12:22 PM
  2. Replies: 6
    Last Post: 07-20-2007, 10:23 AM
  3. Replies: 1
    Last Post: 04-26-2007, 09:04 PM
  4. Replies: 14
    Last Post: 11-22-2006, 07:18 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21