~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/my_copy.c

Moved base64.h to mysys.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 
16
16
#include "mysys_priv.h"
17
17
#include <my_dir.h> /* for stat */
18
 
#include <mystrings/m_string.h>
 
18
#include <m_string.h>
19
19
#if defined(HAVE_UTIME_H)
20
20
#include <utime.h>
21
21
#elif defined(HAVE_SYS_UTIME_H)
50
50
 
51
51
int my_copy(const char *from, const char *to, myf MyFlags)
52
52
{
53
 
  uint32_t Count;
 
53
  uint Count;
54
54
  bool new_file_stat= 0; /* 1 if we could stat "to" */
55
55
  int create_flag;
56
56
  File from_file,to_file;
57
 
  unsigned char buff[IO_SIZE];
 
57
  uchar buff[IO_SIZE];
58
58
  struct stat stat_buff,new_stat_buff;
59
59
 
60
60
  from_file=to_file= -1;
92
92
 
93
93
    if (MyFlags & MY_HOLD_ORIGINAL_MODES && !new_file_stat)
94
94
        return(0);                      /* File copyed but not stat */
95
 
    chmod(to, stat_buff.st_mode & 07777); /* Copy modes */
96
 
    chown(to, stat_buff.st_uid,stat_buff.st_gid); /* Copy ownership */
 
95
    VOID(chmod(to, stat_buff.st_mode & 07777)); /* Copy modes */
 
96
    VOID(chown(to, stat_buff.st_uid,stat_buff.st_gid)); /* Copy ownership */
97
97
    if (MyFlags & MY_COPYTIME)
98
98
    {
99
99
      struct utimbuf timep;
100
100
      timep.actime  = stat_buff.st_atime;
101
101
      timep.modtime = stat_buff.st_mtime;
102
 
      utime((char*) to, &timep); /* last accessed and modified times */
 
102
      VOID(utime((char*) to, &timep)); /* last accessed and modified times */
103
103
    }
104
104
    return(0);
105
105
  }
106
106
 
107
107
err:
108
 
  if (from_file >= 0) my_close(from_file,MyFlags);
 
108
  if (from_file >= 0) VOID(my_close(from_file,MyFlags));
109
109
  if (to_file >= 0)
110
110
  {
111
 
    my_close(to_file, MyFlags);
 
111
    VOID(my_close(to_file, MyFlags));
112
112
    /* attempt to delete the to-file we've partially written */
113
 
    my_delete(to, MyFlags);
 
113
    VOID(my_delete(to, MyFlags));
114
114
  }
115
115
  return(-1);
116
116
} /* my_copy */