#include <windows.h>
#include <stdio.h>
#include <conio.h>


int main()
{
   char *fileName = CMAKE_SOURCE_DIR "/ksycoca4";
   
   TCHAR outFile[MAX_PATH];
   strcpy(outFile,fileName);
   strcat(outFile,".old");

   // move out old file
   if ( !MoveFile(fileName,outFile) )
   { 
        if (GetLastError() != ERROR_FILE_NOT_FOUND)
            printf("Error: Could not move file %s to %s error=%d\n",fileName,outFile,GetLastError());
   } 


   // simulating new file creating 
   if ( !CopyFile(outFile,fileName, true) )
   { 
        printf("Error: Could not copy file %s to %s error=%d\n",outFile,fileName,GetLastError());
   } 
   
   return 0;
}

