13
13
along with this program; if not, write to the Free Software
14
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
16
#ifdef USE_PRAGMA_IMPLEMENTATION
17
#pragma implementation // gcc: Class implementation
20
#include "mysql_priv.h"
19
#include "drizzled/internal/my_sys.h"
21
20
#include "transparent_file.h"
23
22
Transparent_file::Transparent_file() : lower_bound(0), buff_size(IO_SIZE)
25
buff= (uchar *) my_malloc(buff_size*sizeof(uchar), MYF(MY_WME));
24
buff= static_cast<unsigned char *>(malloc(buff_size*sizeof(unsigned char)));
28
27
Transparent_file::~Transparent_file()
30
my_free((uchar*)buff, MYF(MY_ALLOW_ZERO_PTR));
33
void Transparent_file::init_buff(File filedes_arg)
32
void Transparent_file::init_buff(int filedes_arg)
35
34
filedes= filedes_arg;
36
35
/* read the beginning of the file */
38
VOID(my_seek(filedes, 0, MY_SEEK_SET, MYF(0)));
37
lseek(filedes, 0, SEEK_SET);
39
38
if (filedes && buff)
40
39
upper_bound= my_read(filedes, buff, buff_size, MYF(0));
43
uchar *Transparent_file::ptr()
42
unsigned char *Transparent_file::ptr()
48
47
off_t Transparent_file::start()
53
52
off_t Transparent_file::end()
58
57
off_t Transparent_file::read_next()
85
84
if ((lower_bound <= offset) && (offset < upper_bound))
86
85
return buff[offset - lower_bound];
88
VOID(my_seek(filedes, offset, MY_SEEK_SET, MYF(0)));
87
lseek(filedes, offset, SEEK_SET);
89
88
/* read appropriate portion of the file */
90
89
if ((bytes_read= my_read(filedes, buff, buff_size,
91
90
MYF(0))) == MY_FILE_ERROR)