~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/my_copy.cc

Reverted 1103

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
 
 
20
 
#include <fcntl.h>
21
 
 
22
 
#include "drizzled/internal/m_string.h"
 
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
15
 
 
16
#include "mysys/mysys_priv.h"
 
17
 
 
18
#include <mystrings/m_string.h>
23
19
#if defined(HAVE_UTIME_H)
24
20
#include <utime.h>
25
21
#elif defined(HAVE_SYS_UTIME_H)
32
28
};
33
29
#endif
34
30
 
35
 
#ifdef HAVE_SYS_STAT_H
36
 
# include <sys/stat.h>
37
 
#endif
38
 
 
39
31
#include <drizzled/util/test.h>
40
32
 
41
 
namespace drizzled
42
 
{
43
 
namespace internal
44
 
{
45
 
 
46
33
/*
47
34
  int my_copy(const char *from, const char *to, myf MyFlags)
48
35
 
67
54
  uint32_t Count;
68
55
  bool new_file_stat= 0; /* 1 if we could stat "to" */
69
56
  int create_flag;
70
 
  int from_file,to_file;
 
57
  File from_file,to_file;
71
58
  unsigned char buff[IO_SIZE];
72
59
  struct stat stat_buff,new_stat_buff;
73
60
 
80
67
  {
81
68
    if (stat(from, &stat_buff))
82
69
    {
83
 
      errno=errno;
 
70
      my_errno=errno;
84
71
      goto err;
85
72
    }
86
73
    if (MyFlags & MY_HOLD_ORIGINAL_MODES && new_file_stat)
92
79
                             MyFlags)) < 0)
93
80
      goto err;
94
81
 
95
 
    while ((Count= static_cast<uint32_t>(my_read(from_file, buff,
96
 
            sizeof(buff), MyFlags))) != 0)
 
82
    while ((Count=my_read(from_file, buff, sizeof(buff), MyFlags)) != 0)
97
83
    {
98
84
        if (Count == (uint32_t) -1 ||
99
85
            my_write(to_file,buff,Count,MYF(MyFlags | MY_NABP)))
130
116
  }
131
117
  return(-1);
132
118
} /* my_copy */
133
 
 
134
 
} /* namespace internal */
135
 
} /* namespace drizzled */