~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/my_redel.c

Merge/fix in FAQ.

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
 
12
12
   You should have received a copy of the GNU General Public License
13
13
   along with this program; if not, write to the Free Software
14
 
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
15
 
 
16
 
#include <config.h>
17
 
 
18
 
#include <drizzled/internal/my_sys.h>
19
 
#include <drizzled/internal/m_string.h>
20
 
#include <drizzled/error.h>
 
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
15
 
 
16
#include "mysys_priv.h"
 
17
#include <my_dir.h>
 
18
#include <m_string.h>
 
19
#include "mysys_err.h"
21
20
#if defined(HAVE_UTIME_H)
22
21
#include <utime.h>
23
22
#elif defined(HAVE_SYS_UTIME_H)
28
27
  time_t modtime;
29
28
};
30
29
#endif
31
 
#ifdef HAVE_SYS_STAT_H
32
 
# include <sys/stat.h>
33
 
#endif
34
 
 
35
 
namespace drizzled
36
 
{
37
 
namespace internal
38
 
{
39
30
 
40
31
        /*
41
32
          Rename with copy stat form old file
56
47
    goto end;
57
48
  if (MyFlags & MY_REDEL_MAKE_BACKUP)
58
49
  {
59
 
    char name_buff[FN_REFLEN+20];
 
50
    char name_buff[FN_REFLEN+20];    
60
51
    char ext[20];
61
52
    ext[0]='-';
62
53
    get_date(ext+1,2+4,(time_t) 0);
63
 
    strcpy(strchr(ext, '\0'),REDEL_EXT);
 
54
    strmov(strend(ext),REDEL_EXT);
64
55
    if (my_rename(org_name, fn_format(name_buff, org_name, "", ext, 2),
65
56
                  MyFlags))
66
57
      goto end;
67
58
  }
68
 
  else if (my_delete(org_name, MyFlags))
 
59
  else if (my_delete_allow_opened(org_name, MyFlags))
69
60
      goto end;
70
61
  if (my_rename(tmp_name,org_name,MyFlags))
71
62
    goto end;
85
76
 
86
77
  if (stat((char*) from, &statbuf))
87
78
  {
88
 
    errno=errno;
 
79
    my_errno=errno;
89
80
    if (MyFlags & (MY_FAE+MY_WME))
90
81
      my_error(EE_STAT, MYF(ME_BELL+ME_WAITTANG),from,errno);
91
82
    return -1;                          /* Can't get stat on input file */
92
83
  }
93
84
  if ((statbuf.st_mode & S_IFMT) != S_IFREG)
94
85
    return 1;
95
 
  chmod(to, statbuf.st_mode & 07777);           /* Copy modes */
 
86
  VOID(chmod(to, statbuf.st_mode & 07777));             /* Copy modes */
96
87
 
97
88
  if (statbuf.st_nlink > 1 && MyFlags & MY_LINK_WARNING)
98
89
  {
99
90
    if (MyFlags & MY_LINK_WARNING)
100
91
      my_error(EE_LINK_WARNING,MYF(ME_BELL+ME_WAITTANG),from,statbuf.st_nlink);
101
92
  }
102
 
  if(chown(to, statbuf.st_uid, statbuf.st_gid)!=0)
103
 
    return 1;
 
93
  VOID(chown(to, statbuf.st_uid, statbuf.st_gid));      /* Copy ownership */
104
94
 
105
95
#ifndef __ZTC__
106
96
  if (MyFlags & MY_COPYTIME)
108
98
    struct utimbuf timep;
109
99
    timep.actime  = statbuf.st_atime;
110
100
    timep.modtime = statbuf.st_mtime;
111
 
    utime((char*) to, &timep);/* Update last accessed and modified times */
 
101
    VOID(utime((char*) to, &timep));/* Update last accessed and modified times */
112
102
  }
113
103
#else
114
104
  if (MyFlags & MY_COPYTIME)
116
106
    time_t time[2];
117
107
    time[0]= statbuf.st_atime;
118
108
    time[1]= statbuf.st_mtime;
119
 
    utime((char*) to, time);/* Update last accessed and modified times */
 
109
    VOID(utime((char*) to, time));/* Update last accessed and modified times */
120
110
  }
121
111
#endif
122
112
  return 0;
123
113
} /* my_copystat */
124
 
 
125
 
} /* namespace internal */
126
 
} /* namespace drizzled */