~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/my_redel.c

  • Committer: Stewart Smith
  • Date: 2008-07-13 06:56:15 UTC
  • mto: (210.1.1 drizzle)
  • mto: This revision was merged to the branch mainline in revision 211.
  • Revision ID: stewart@flamingspork.com-20080713065615-vzok75kgnnviokl9
Move MD5() into a UDF

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
15
 
16
16
#include "mysys_priv.h"
17
 
#include <mystrings/m_string.h>
 
17
#include <my_dir.h>
 
18
#include <m_string.h>
18
19
#include "mysys_err.h"
19
20
#if defined(HAVE_UTIME_H)
20
21
#include <utime.h>
41
42
int my_redel(const char *org_name, const char *tmp_name, myf MyFlags)
42
43
{
43
44
  int error=1;
 
45
  DBUG_ENTER("my_redel");
 
46
  DBUG_PRINT("my",("org_name: '%s' tmp_name: '%s'  MyFlags: %d",
 
47
                   org_name,tmp_name,MyFlags));
44
48
 
45
49
  if (my_copystat(org_name,tmp_name,MyFlags) < 0)
46
50
    goto end;
47
51
  if (MyFlags & MY_REDEL_MAKE_BACKUP)
48
52
  {
49
 
    char name_buff[FN_REFLEN+20];
 
53
    char name_buff[FN_REFLEN+20];    
50
54
    char ext[20];
51
55
    ext[0]='-';
52
56
    get_date(ext+1,2+4,(time_t) 0);
53
 
    strcpy(strchr(ext, '\0'),REDEL_EXT);
 
57
    strmov(strend(ext),REDEL_EXT);
54
58
    if (my_rename(org_name, fn_format(name_buff, org_name, "", ext, 2),
55
59
                  MyFlags))
56
60
      goto end;
62
66
 
63
67
  error=0;
64
68
end:
65
 
  return(error);
 
69
  DBUG_RETURN(error);
66
70
} /* my_redel */
67
71
 
68
72
 
82
86
  }
83
87
  if ((statbuf.st_mode & S_IFMT) != S_IFREG)
84
88
    return 1;
85
 
  chmod(to, statbuf.st_mode & 07777);           /* Copy modes */
 
89
  VOID(chmod(to, statbuf.st_mode & 07777));             /* Copy modes */
86
90
 
87
91
  if (statbuf.st_nlink > 1 && MyFlags & MY_LINK_WARNING)
88
92
  {
89
93
    if (MyFlags & MY_LINK_WARNING)
90
94
      my_error(EE_LINK_WARNING,MYF(ME_BELL+ME_WAITTANG),from,statbuf.st_nlink);
91
95
  }
92
 
  if(chown(to, statbuf.st_uid, statbuf.st_gid)!=0)
93
 
    return 1;
 
96
  VOID(chown(to, statbuf.st_uid, statbuf.st_gid));      /* Copy ownership */
94
97
 
95
98
#ifndef __ZTC__
96
99
  if (MyFlags & MY_COPYTIME)
98
101
    struct utimbuf timep;
99
102
    timep.actime  = statbuf.st_atime;
100
103
    timep.modtime = statbuf.st_mtime;
101
 
    utime((char*) to, &timep);/* Update last accessed and modified times */
 
104
    VOID(utime((char*) to, &timep));/* Update last accessed and modified times */
102
105
  }
103
106
#else
104
107
  if (MyFlags & MY_COPYTIME)
106
109
    time_t time[2];
107
110
    time[0]= statbuf.st_atime;
108
111
    time[1]= statbuf.st_mtime;
109
 
    utime((char*) to, time);/* Update last accessed and modified times */
 
112
    VOID(utime((char*) to, time));/* Update last accessed and modified times */
110
113
  }
111
114
#endif
112
115
  return 0;