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 <drizzled/common_includes.h>
19
#include "drizzled/internal/my_sys.h"
21
20
#include "transparent_file.h"
22
using namespace drizzled;
23
24
Transparent_file::Transparent_file() : lower_bound(0), buff_size(IO_SIZE)
25
buff= (uchar *) my_malloc(buff_size*sizeof(uchar), MYF(MY_WME));
26
buff= static_cast<unsigned char *>(malloc(buff_size*sizeof(unsigned char)));
28
29
Transparent_file::~Transparent_file()
30
my_free((uchar*)buff, MYF(MY_ALLOW_ZERO_PTR));
33
void Transparent_file::init_buff(File filedes_arg)
34
void Transparent_file::init_buff(int filedes_arg)
35
36
filedes= filedes_arg;
36
37
/* read the beginning of the file */
38
VOID(my_seek(filedes, 0, MY_SEEK_SET, MYF(0)));
39
lseek(filedes, 0, SEEK_SET);
39
40
if (filedes && buff)
40
upper_bound= my_read(filedes, buff, buff_size, MYF(0));
41
upper_bound= internal::my_read(filedes, buff, buff_size, MYF(0));
43
uchar *Transparent_file::ptr()
44
unsigned char *Transparent_file::ptr()
48
49
off_t Transparent_file::start()
53
54
off_t Transparent_file::end()
58
59
off_t Transparent_file::read_next()
63
64
No need to seek here, as the file managed by Transparent_file class
64
65
always points to upper_bound byte
66
if ((bytes_read= my_read(filedes, buff, buff_size, MYF(0))) == MY_FILE_ERROR)
67
if ((bytes_read= internal::my_read(filedes, buff, buff_size, MYF(0))) == MY_FILE_ERROR)
85
86
if ((lower_bound <= offset) && (offset < upper_bound))
86
87
return buff[offset - lower_bound];
88
VOID(my_seek(filedes, offset, MY_SEEK_SET, MYF(0)));
89
lseek(filedes, offset, SEEK_SET);
89
90
/* read appropriate portion of the file */
90
if ((bytes_read= my_read(filedes, buff, buff_size,
91
if ((bytes_read= internal::my_read(filedes, buff, buff_size,
91
92
MYF(0))) == MY_FILE_ERROR)