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
19
#include "drizzled/internal/my_sys.h"
20
#include "mysql_priv.h"
20
21
#include "transparent_file.h"
22
23
Transparent_file::Transparent_file() : lower_bound(0), buff_size(IO_SIZE)
24
buff= static_cast<unsigned char *>(malloc(buff_size*sizeof(unsigned char)));
25
buff= (uchar *) my_malloc(buff_size*sizeof(uchar), MYF(MY_WME));
27
28
Transparent_file::~Transparent_file()
30
my_free((uchar*)buff, MYF(MY_ALLOW_ZERO_PTR));
32
void Transparent_file::init_buff(int filedes_arg)
33
void Transparent_file::init_buff(File filedes_arg)
34
35
filedes= filedes_arg;
35
36
/* read the beginning of the file */
37
lseek(filedes, 0, SEEK_SET);
38
VOID(my_seek(filedes, 0, MY_SEEK_SET, MYF(0)));
38
39
if (filedes && buff)
39
40
upper_bound= my_read(filedes, buff, buff_size, MYF(0));
42
unsigned char *Transparent_file::ptr()
43
uchar *Transparent_file::ptr()
47
48
off_t Transparent_file::start()
52
53
off_t Transparent_file::end()
57
58
off_t Transparent_file::read_next()
84
85
if ((lower_bound <= offset) && (offset < upper_bound))
85
86
return buff[offset - lower_bound];
87
lseek(filedes, offset, SEEK_SET);
88
VOID(my_seek(filedes, offset, MY_SEEK_SET, MYF(0)));
88
89
/* read appropriate portion of the file */
89
90
if ((bytes_read= my_read(filedes, buff, buff_size,
90
91
MYF(0))) == MY_FILE_ERROR)