ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/gclib/gclib/GCdbYank.cpp
(Generate patch)
# Line 12 | Line 12
12   #define O_BINARY 0x0000
13   #endif
14  
15 + //default size of the index record for records stored with 32bit offsets
16 + uint32 irec_size32=8;
17  
18   #ifdef ENABLE_COMPRESSION
19  
# Line 68 | Line 70
70   //returns: the number of bytes decompressed
71   int GCdbZFasta::decompress(FastaSeq& rec, int csize, int zfofs, charFunc* seqCallBack) {
72   if (zfofs>=0) {
73 <    if (fseek(zf, zfofs, 0))
74 <      GError("GCdbZFasta::decompress: error fseek() to %d\n", zfofs);
73 >    if (fseeko(zf, zfofs, 0))
74 >      GError("GCdbZFasta::decompress: error fseeko() to %d\n", zfofs);
75      }
76    else
77       if (feof(zf)) return 0;
# Line 249 | Line 251
251         return 0;
252         }
253  
254 < int parse_int(FILE* f, char* buf, const char* key, int& e) {
254 > int parse_int(char* buf, const char* key, int& e) {
255     char* p, *q;
256     while (e!=EOF && isspace(e)) { //skip any spaces
257       if (e=='\n') GError(ERR_RANGEFMT, key);
# Line 416 | Line 418
418  
419   off_t fpos; //this will be the fastadb offset
420   uint32 reclen;  //this will be the fasta record offset
421 < if (len>8) { //64 bit file offset was used
421 > if (len>irec_size32) { //64 bit file offset was used
422    fpos=gcvt_offt(bytes);
423    reclen=gcvt_uint(&bytes[sizeof(uint32)<<1]);
424    }
# Line 456 | Line 458
458   return 0;
459   }
460  
461 < off_t GCdbYank::getRecordPos(const char* key) {
461 > off_t GCdbYank::getRecordPos(const char* key, uint32* record_len) {
462   //assumes fdb is open, cdb was created on the index file
463   int r=cdb->find(key);
464   if (r==0 && warnings) {
# Line 467 | Line 469
469     GError("cdbyank: error searching for key %s in %s\n", key, idxfile);
470   off_t pos = cdb->datapos(); //position of this key's record in the index file
471   unsigned int len=cdb->datalen(); // length of this key's record
472 < char bytes[32]; // data buffer -- should just accomodate fastarec_pos, fastarec_length
472 > char bytes[64]; // data buffer -- should just accomodate fastarec_pos, fastarec_length
473   if (cdb->read(bytes,len,pos) == -1)
474         GError("cdbyank: error at GCbd::read (%s)!\n", idxfile);
475  
476   off_t fpos; //this will be the fastadb offset
477 < //uint32 reclen;  this will be the fasta record length
478 < if (len>8) //64 bit file offset was used
479 <      fpos=gcvt_offt(bytes);
480 <     else  //32bit offset used
481 <      fpos=gcvt_uint(bytes);
477 > uint32 rlen;  //this will be the fasta record length
478 > if (len>irec_size32) { //64 bit file offset was used
479 >  fpos=gcvt_offt(bytes);
480 >  rlen=gcvt_uint(&bytes[offsetof(CIdxData, reclen)]);
481 >  }
482 >  else { //32bit offset used
483 >  fpos=gcvt_uint(bytes);
484 >  rlen=gcvt_uint(&bytes[offsetof(CIdxData32, reclen)]);
485 >  }
486 >  if (record_len!=NULL) *record_len=rlen;
487    return fpos;
488   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines