~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/csv/transparent_file.cc

  • Committer: Brian Aker
  • Date: 2008-10-06 06:47:29 UTC
  • Revision ID: brian@tangent.org-20081006064729-2i9mhjkzyvow9xsm
Remove uint.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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 */
15
15
 
 
16
#ifdef USE_PRAGMA_IMPLEMENTATION
 
17
#pragma implementation        // gcc: Class implementation
 
18
#endif
16
19
 
17
 
#include "config.h"
18
 
#include <cstdlib>
19
 
#include "drizzled/internal/my_sys.h"
 
20
#include <drizzled/common_includes.h>
20
21
#include "transparent_file.h"
21
22
 
22
 
using namespace drizzled;
23
 
 
24
23
Transparent_file::Transparent_file() : lower_bound(0), buff_size(IO_SIZE)
25
 
{
26
 
  buff= static_cast<unsigned char *>(malloc(buff_size*sizeof(unsigned char)));
 
24
 
25
  buff= (unsigned char *) my_malloc(buff_size*sizeof(unsigned char),  MYF(MY_WME)); 
27
26
}
28
27
 
29
28
Transparent_file::~Transparent_file()
30
 
{
31
 
  free(buff);
 
29
 
30
  free((unsigned char*)buff); 
32
31
}
33
32
 
34
 
void Transparent_file::init_buff(int filedes_arg)
 
33
void Transparent_file::init_buff(File filedes_arg)
35
34
{
36
35
  filedes= filedes_arg;
37
36
  /* read the beginning of the file */
38
37
  lower_bound= 0;
39
 
  lseek(filedes, 0, SEEK_SET);
 
38
  my_seek(filedes, 0, MY_SEEK_SET, MYF(0));
40
39
  if (filedes && buff)
41
 
    upper_bound= internal::my_read(filedes, buff, buff_size, MYF(0));
 
40
    upper_bound= my_read(filedes, buff, buff_size, MYF(0));
42
41
}
43
42
 
44
43
unsigned char *Transparent_file::ptr()
45
 
{
46
 
  return buff;
 
44
 
45
  return buff; 
47
46
}
48
47
 
49
48
off_t Transparent_file::start()
50
 
{
51
 
  return lower_bound;
 
49
 
50
  return lower_bound; 
52
51
}
53
52
 
54
53
off_t Transparent_file::end()
55
 
{
56
 
  return upper_bound;
 
54
 
55
  return upper_bound; 
57
56
}
58
57
 
59
58
off_t Transparent_file::read_next()
64
63
     No need to seek here, as the file managed by Transparent_file class
65
64
     always points to upper_bound byte
66
65
  */
67
 
  if ((bytes_read= internal::my_read(filedes, buff, buff_size, MYF(0))) == MY_FILE_ERROR)
 
66
  if ((bytes_read= my_read(filedes, buff, buff_size, MYF(0))) == MY_FILE_ERROR)
68
67
    return (off_t) -1;
69
68
 
70
69
  /* end of file */
86
85
  if ((lower_bound <= offset) && (offset < upper_bound))
87
86
    return buff[offset - lower_bound];
88
87
 
89
 
  lseek(filedes, offset, SEEK_SET);
 
88
  my_seek(filedes, offset, MY_SEEK_SET, MYF(0));
90
89
  /* read appropriate portion of the file */
91
 
  if ((bytes_read= internal::my_read(filedes, buff, buff_size,
 
90
  if ((bytes_read= my_read(filedes, buff, buff_size,
92
91
                           MYF(0))) == MY_FILE_ERROR)
93
92
    return 0;
94
93