~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/archive/ha_archive.cc

  • Committer: Brian Aker
  • Date: 2009-02-10 19:47:25 UTC
  • Revision ID: brian@tangent.org-20090210194725-muf2iiu0pfiykpl4
Remove my_open() call for Archive.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
#include <storage/myisam/myisam.h>
22
22
#include <drizzled/table.h>
23
23
#include <drizzled/session.h>
 
24
#include <stdio.h>
24
25
 
25
26
#include <storage/archive/ha_archive.h>
26
27
 
501
502
{
502
503
  char name_buff[FN_REFLEN];
503
504
  char linkname[FN_REFLEN];
504
 
  int error;
 
505
  int error= 0;
505
506
  azio_stream create_stream;            /* Archive file we are working with */
506
 
  File frm_file;                   /* File handler for readers */
 
507
  FILE *frm_file;                   /* File handler for readers */
507
508
  struct stat file_stat;
508
509
  unsigned char *frm_ptr;
509
510
  int r;
573
574
  /*
574
575
    Here is where we open up the frm and pass it to archive to store
575
576
  */
576
 
  if ((frm_file= my_open(name_buff, O_RDONLY, MYF(0))) > 0)
 
577
  if ((frm_file= fopen(name_buff, "r")) > 0)
577
578
  {
578
 
    if (fstat(frm_file, &file_stat))
 
579
    if (fstat(fileno(frm_file), &file_stat))
579
580
    {
580
581
      if ((uint64_t)file_stat.st_size > SIZE_MAX)
581
582
      {
585
586
      frm_ptr= (unsigned char *)malloc((size_t)file_stat.st_size);
586
587
      if (frm_ptr)
587
588
      {
588
 
        my_read(frm_file, frm_ptr, (size_t)file_stat.st_size, MYF(0));
589
 
        azwrite_frm(&create_stream, (char *)frm_ptr, (size_t)file_stat.st_size);
 
589
        size_t length_io;
 
590
        length_io= read(fileno(frm_file), frm_ptr, (size_t)file_stat.st_size);
 
591
 
 
592
        if (length_io != (size_t)file_stat.st_size)
 
593
        {
 
594
          free(frm_ptr);
 
595
          goto error2;
 
596
        }
 
597
 
 
598
        length_io= azwrite_frm(&create_stream, (char *)frm_ptr, (size_t)file_stat.st_size);
 
599
 
 
600
        if (length_io != (size_t)file_stat.st_size)
 
601
        {
 
602
          free(frm_ptr);
 
603
          goto error2;
 
604
        }
 
605
 
590
606
        free(frm_ptr);
591
607
      }
592
608
    }
593
 
    my_close(frm_file, MYF(0));
 
609
    fclose(frm_file);
594
610
  }
595
611
 
596
612
  if (create_info->comment.str)
597
 
    azwrite_comment(&create_stream, create_info->comment.str,
598
 
                    (unsigned int)create_info->comment.length);
 
613
  {
 
614
    size_t write_length;
 
615
 
 
616
    write_length= azwrite_comment(&create_stream, create_info->comment.str,
 
617
                                  (unsigned int)create_info->comment.length);
 
618
 
 
619
    if (write_length == (size_t)create_info->comment.length)
 
620
      goto error2;
 
621
  }
599
622
 
600
623
  /*
601
624
    Yes you need to do this, because the starting value
623
646
*/
624
647
int ha_archive::real_write_row(unsigned char *buf, azio_stream *writer)
625
648
{
626
 
  my_off_t written;
 
649
  off_t written;
627
650
  unsigned int r_pack_length;
628
651
 
629
652
  /* We pack the row for writing */