~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/my_redel.cc

  • Committer: Monty Taylor
  • Date: 2009-04-18 06:25:27 UTC
  • mto: (997.2.1 mordred)
  • mto: This revision was merged to the branch mainline in revision 1003.
  • Revision ID: mordred@inaugust.com-20090418062527-08trhjviktq2svvv
Fixed gnulib updates.

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