~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/my_copy.cc

  • Committer: Brian Aker
  • Date: 2009-02-12 22:45:08 UTC
  • Revision ID: brian@tangent.org-20090212224508-mrd9jwgn1zjdpqdk
Minor refactoring (we will need to disconnect the code from the include
file).

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 <my_dir.h> /* for stat */
 
17
 
18
18
#include <mystrings/m_string.h>
19
19
#if defined(HAVE_UTIME_H)
20
20
#include <utime.h>
28
28
};
29
29
#endif
30
30
 
 
31
#include <drizzled/util/test.h>
31
32
 
32
33
/*
33
34
  int my_copy(const char *from, const char *to, myf MyFlags)
62
63
  if (MyFlags & MY_HOLD_ORIGINAL_MODES)         /* Copy stat if possible */
63
64
    new_file_stat= test(!stat((char*) to, &new_stat_buff));
64
65
 
65
 
  if ((from_file=my_open(from,O_RDONLY | O_SHARE,MyFlags)) >= 0)
 
66
  if ((from_file=my_open(from,O_RDONLY,MyFlags)) >= 0)
66
67
  {
67
68
    if (stat(from, &stat_buff))
68
69
    {
74
75
    create_flag= (MyFlags & MY_DONT_OVERWRITE_FILE) ? O_EXCL : O_TRUNC;
75
76
 
76
77
    if ((to_file=  my_create(to,(int) stat_buff.st_mode,
77
 
                             O_WRONLY | create_flag | O_BINARY | O_SHARE,
 
78
                             O_WRONLY | create_flag,
78
79
                             MyFlags)) < 0)
79
80
      goto err;
80
81
 
93
94
    if (MyFlags & MY_HOLD_ORIGINAL_MODES && !new_file_stat)
94
95
        return(0);                      /* File copyed but not stat */
95
96
    chmod(to, stat_buff.st_mode & 07777); /* Copy modes */
96
 
    chown(to, stat_buff.st_uid,stat_buff.st_gid); /* Copy ownership */
 
97
    if(chown(to, stat_buff.st_uid,stat_buff.st_gid)!=0)
 
98
        return 0;
97
99
    if (MyFlags & MY_COPYTIME)
98
100
    {
99
101
      struct utimbuf timep;