~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/internal/my_redel.cc

  • Committer: Brian Aker
  • Date: 2010-02-07 01:33:54 UTC
  • Revision ID: brian@gaz-20100207013354-d2pg1n68u5c09pgo
Remove giant include header to its own file.

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 <mystrings/m_string.h>
19
 
#include "mysys_err.h"
 
16
#include "config.h"
 
17
 
 
18
#include "drizzled/internal/my_sys.h"
 
19
#include "drizzled/internal/m_string.h"
 
20
#include "drizzled/my_error.h"
20
21
#if defined(HAVE_UTIME_H)
21
22
#include <utime.h>
22
23
#elif defined(HAVE_SYS_UTIME_H)
27
28
  time_t modtime;
28
29
};
29
30
#endif
 
31
#ifdef HAVE_SYS_STAT_H
 
32
# include <sys/stat.h>
 
33
#endif
 
34
 
 
35
namespace drizzled
 
36
{
 
37
namespace internal
 
38
{
30
39
 
31
40
        /*
32
41
          Rename with copy stat form old file
47
56
    goto end;
48
57
  if (MyFlags & MY_REDEL_MAKE_BACKUP)
49
58
  {
50
 
    char name_buff[FN_REFLEN+20];    
 
59
    char name_buff[FN_REFLEN+20];
51
60
    char ext[20];
52
61
    ext[0]='-';
53
62
    get_date(ext+1,2+4,(time_t) 0);
54
 
    stpcpy(strend(ext),REDEL_EXT);
 
63
    strcpy(strchr(ext, '\0'),REDEL_EXT);
55
64
    if (my_rename(org_name, fn_format(name_buff, org_name, "", ext, 2),
56
65
                  MyFlags))
57
66
      goto end;
76
85
 
77
86
  if (stat((char*) from, &statbuf))
78
87
  {
79
 
    my_errno=errno;
 
88
    errno=errno;
80
89
    if (MyFlags & (MY_FAE+MY_WME))
81
90
      my_error(EE_STAT, MYF(ME_BELL+ME_WAITTANG),from,errno);
82
91
    return -1;                          /* Can't get stat on input file */
83
92
  }
84
93
  if ((statbuf.st_mode & S_IFMT) != S_IFREG)
85
94
    return 1;
86
 
  VOID(chmod(to, statbuf.st_mode & 07777));             /* Copy modes */
 
95
  chmod(to, statbuf.st_mode & 07777);           /* Copy modes */
87
96
 
88
97
  if (statbuf.st_nlink > 1 && MyFlags & MY_LINK_WARNING)
89
98
  {
90
99
    if (MyFlags & MY_LINK_WARNING)
91
100
      my_error(EE_LINK_WARNING,MYF(ME_BELL+ME_WAITTANG),from,statbuf.st_nlink);
92
101
  }
93
 
  VOID(chown(to, statbuf.st_uid, statbuf.st_gid));      /* Copy ownership */
 
102
  if(chown(to, statbuf.st_uid, statbuf.st_gid)!=0)
 
103
    return 1;
94
104
 
95
105
#ifndef __ZTC__
96
106
  if (MyFlags & MY_COPYTIME)
98
108
    struct utimbuf timep;
99
109
    timep.actime  = statbuf.st_atime;
100
110
    timep.modtime = statbuf.st_mtime;
101
 
    VOID(utime((char*) to, &timep));/* Update last accessed and modified times */
 
111
    utime((char*) to, &timep);/* Update last accessed and modified times */
102
112
  }
103
113
#else
104
114
  if (MyFlags & MY_COPYTIME)
106
116
    time_t time[2];
107
117
    time[0]= statbuf.st_atime;
108
118
    time[1]= statbuf.st_mtime;
109
 
    VOID(utime((char*) to, time));/* Update last accessed and modified times */
 
119
    utime((char*) to, time);/* Update last accessed and modified times */
110
120
  }
111
121
#endif
112
122
  return 0;
113
123
} /* my_copystat */
 
124
 
 
125
} /* namespace internal */
 
126
} /* namespace drizzled */