1/* Copyright (c) 2000, 2006, 2007 MySQL AB, 2009 Sun Microsystems, Inc.
2 Use is subject to license terms.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; version 2 of the License.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
16
17/* Quicker interface to read & write. Used with my_nosys.h */
18
19#include "mysys_priv.h"
20#include "my_nosys.h"
21
22
23#ifdef _WIN32
24extern size_t my_win_read(File Filedes,uchar *Buffer,size_t Count);
25#endif
26
27size_t my_quick_read(File Filedes,uchar *Buffer,size_t Count,myf MyFlags)
28{
29 size_t readbytes;
30#ifdef _WIN32
31 readbytes= my_win_read(Filedes, Buffer, Count);
32#else
33 readbytes= read(Filedes, Buffer, Count);
34#endif
35 if(readbytes != Count)
36 {
37#ifndef DBUG_OFF
38 if ((readbytes == 0 || readbytes == (size_t) -1) && errno == EINTR)
39 {
40 DBUG_PRINT("error", ("my_quick_read() was interrupted and returned %d"
41 ". This function does not retry the read!",
42 (int) readbytes));
43 }
44#endif
45 my_errno=errno;
46 return readbytes;
47 }
48 return (MyFlags & (MY_NABP | MY_FNABP)) ? 0 : readbytes;
49}
50
51
52
53size_t my_quick_write(File Filedes, const uchar *Buffer, size_t Count)
54{
55#ifdef _WIN32
56 return my_win_write(Filedes, Buffer, Count);
57#else
58
59#ifndef DBUG_OFF
60 size_t writtenbytes;
61#endif
62
63 if ((
64#ifndef DBUG_OFF
65 writtenbytes =
66#endif
67 (size_t) write(Filedes,Buffer,Count)) != Count)
68 {
69#ifndef DBUG_OFF
70 if ((writtenbytes == 0 || writtenbytes == (size_t) -1) && errno == EINTR)
71 {
72 DBUG_PRINT("error", ("my_quick_write() was interrupted and returned %d"
73 ". This function does not retry the write!",
74 (int) writtenbytes));
75 }
76#endif
77 my_errno=errno;
78 return (size_t) -1;
79 }
80 return 0;
81#endif
82}
83