~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/internal/my_redel.cc

  • Committer: Monty Taylor
  • Date: 2011-02-13 17:26:39 UTC
  • mfrom: (2157.2.2 give-in-to-pkg-config)
  • mto: This revision was merged to the branch mainline in revision 2166.
  • Revision ID: mordred@inaugust.com-20110213172639-nhy7i72sfhoq13ms
Merged in pkg-config fixes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
   along with this program; if not, write to the Free Software
14
14
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
15
15
 
16
 
#include <config.h>
 
16
#include "config.h"
17
17
 
18
 
#include <drizzled/internal/my_sys.h>
19
 
#include <drizzled/internal/m_string.h>
20
 
#include <drizzled/error.h>
 
18
#include "drizzled/internal/my_sys.h"
 
19
#include "drizzled/internal/m_string.h"
 
20
#include "drizzled/error.h"
21
21
#if defined(HAVE_UTIME_H)
22
22
#include <utime.h>
23
23
#elif defined(HAVE_SYS_UTIME_H)
46
46
          is renamed to org_name-'current_time'.BAK
47
47
        */
48
48
 
 
49
#define REDEL_EXT ".BAK"
 
50
 
49
51
int my_redel(const char *org_name, const char *tmp_name, myf MyFlags)
50
52
{
51
53
  int error=1;
52
54
 
53
55
  if (my_copystat(org_name,tmp_name,MyFlags) < 0)
54
56
    goto end;
55
 
  if (my_delete(org_name, MyFlags))
 
57
  if (MyFlags & MY_REDEL_MAKE_BACKUP)
 
58
  {
 
59
    char name_buff[FN_REFLEN+20];
 
60
    char ext[20];
 
61
    ext[0]='-';
 
62
    get_date(ext+1,2+4,(time_t) 0);
 
63
    strcpy(strchr(ext, '\0'),REDEL_EXT);
 
64
    if (my_rename(org_name, fn_format(name_buff, org_name, "", ext, 2),
 
65
                  MyFlags))
 
66
      goto end;
 
67
  }
 
68
  else if (my_delete(org_name, MyFlags))
56
69
      goto end;
57
70
  if (my_rename(tmp_name,org_name,MyFlags))
58
71
    goto end;