Exemple #1
0
void Reader::seekTo(size_t bytes)
{
    if (m_inRAM)
    {
        if (bytes > m_inRAMSize)
        {
            bytes = m_inRAMSize;
        }
        m_inRAMCurrentPos = bytes;
    }
    else if (m_in)
    {
#ifdef GTO_HAVE_FULL_IOSTREAMS
        m_in->seekg(bytes, ios_base::beg);
#else
        m_in->seekg(bytes, ios::beg);
#endif
    }
#ifdef GTO_SUPPORT_ZIP
    else
    {
        #if ZLIB_VERNUM >= UPDATED_ZLIB_VERNUM
            gzseek((gzFile_s*)m_gzfile, bytes, SEEK_SET);
        #else
            gzseek(m_gzfile, bytes, SEEK_SET);
        #endif
    }
#endif
}
Exemple #2
0
bool ZipFile::seek(int64_t offset, int whence /* = SEEK_SET */) {
  assert(m_gzFile);

  if (whence == SEEK_CUR) {
    off_t result = gzseek(m_gzFile, 0, SEEK_CUR);
    if (result != (off_t)-1) {
      offset += result - (bufferedLen() + getPosition());
    }
    if (offset > 0 && offset < bufferedLen()) {
      setReadPosition(getReadPosition() + offset);
      setPosition(getPosition() + offset);
      return true;
    }
    offset += getPosition();
    whence = SEEK_SET;
  }

  // invalidate the current buffer
  setWritePosition(0);
  setReadPosition(0);
  setEof(false);
  flush();
  off_t result = gzseek(m_gzFile, offset, whence);
  setPosition(result);
  return result != (off_t)-1;
}
Exemple #3
0
void Reader::seekForward(size_t bytes)
{
    if (m_inRAM)
    {
        m_inRAMCurrentPos += bytes;
        if (m_inRAMCurrentPos > m_inRAMSize)
        {
            m_inRAMCurrentPos = m_inRAMSize;
        }
    }
    else if (m_in)
    {
#ifdef GTO_HAVE_FULL_IOSTREAMS
        m_in->seekg(bytes, ios_base::cur);
#else
        m_in->seekg(bytes, ios::cur);
#endif
    }
#ifdef GTO_SUPPORT_ZIP
    else
    {
        #if ZLIB_VERNUM >= UPDATED_ZLIB_VERNUM
            gzseek((gzFile_s*)m_gzfile, bytes, SEEK_CUR);
        #else
            gzseek(m_gzfile, bytes, SEEK_CUR);
        #endif
    }
#endif
}
Exemple #4
0
bool ZipFile::seek(int64_t offset, int whence /* = SEEK_SET */) {
  assert(m_gzFile);

  if (whence == SEEK_CUR) {
    off_t result = gzseek(m_gzFile, 0, SEEK_CUR);
    if (result != (off_t)-1) {
      offset += result - (m_writepos - m_readpos + m_position);
    }
    if (offset > 0 && offset < m_writepos - m_readpos) {
      m_readpos += offset;
      m_position += offset;
      return true;
    }
    offset += m_position;
    whence = SEEK_SET;
  }

  // invalidate the current buffer
  m_writepos = 0;
  m_readpos = 0;
  m_eof = false;
  flush();
  off_t result = gzseek(m_gzFile, offset, whence);
  m_position = result;
  return result != (off_t)-1;
}
Exemple #5
0
void gpuShowPic() {
	char Text[255];
	gzFile f;

	if (!ShowPic) {
		unsigned char *pMem;

		pMem = (unsigned char *) malloc(128*96*3);
		if (pMem == NULL) return;
		GetStateFilename(Text, StatesC);

		GPU_freeze(2, (GPUFreeze_t *)&StatesC);

		f = gzopen(Text, "rb");
		if (f != NULL) {
			gzseek(f, 32, SEEK_SET); // skip header
            gzseek(f, sizeof(u32), SEEK_CUR);
            gzseek(f, sizeof(boolean), SEEK_CUR);
			gzread(f, pMem, 128*96*3);
			gzclose(f);
		} else {
			memcpy(pMem, NoPic_Image.pixel_data, 128*96*3);
			DrawNumBorPic(pMem, StatesC+1);
		}
		GPU_showScreenPic(pMem);

		free(pMem);
		ShowPic = 1;
	} else { GPU_showScreenPic(NULL); ShowPic = 0; }
}
Exemple #6
0
/*!

*/
std::streampos
gzfilebuf::seekpos( std::streampos pos,
                    std::ios_base::openmode mode )
{
    if ( ! is_open() )
    {
        return -1;
    }

    std::streampos ret = -1;
#ifdef HAVE_LIBZ
    if ( ( M_impl->open_mode_ & std::ios_base::in )
         && ( mode & std::ios_base::in ) )
    {
        ret = gzseek( M_impl->file_, pos, SEEK_SET );
        // and reset buffer pointer to initial position
        M_remained_size = 0;
        this->setg( M_buf, M_buf, M_buf );
    }

    if ( ( M_impl->open_mode_ & std::ios_base::out )
         && ( mode & std::ios_base::out ) )
    {
        std::streampos cur = gztell( M_impl->file_ );
        if ( pos <= cur )
        {
            ret = gzseek( M_impl->file_, pos, SEEK_SET );
            this->setp( M_buf, M_buf + M_buf_size );
        }
    }
#endif
    return ret;
}
Exemple #7
0
/*
 * Auto detects size to distinguish between short and long maq variants
 * Returns 64 for short
 *         128 for long
 *         -1 for error
 */
int maq_detect_size(gzFile fp) {
    z_off_t curr = gztell(fp);
    maqmap128_t m;
    maqmap64_t m64;
    int i, sz = 128;

    if (gzread(fp, &m, sizeof(maqmap128_t)) == -1)
	return -1;

    gzseek(fp, curr, SEEK_SET);

    /* We know the sequence size should >= 0 and <= 128 */
    if (/*m.size >= 0 &&*/ m.size <= 128) {
	/* The sequence struct from m.size onwards should be nul padded. */
	for (i = m.size; i < 127; i++) {
	    if (m.seq[i] != 0) {
		sz = 64;
		break;
	    }
	}

	/* Check for valid name */
	for (i = 0; i < MAX_NAMELEN; i++) {
	    if (!m.name[i])
		break;
	    if (!isprint(m.name[i])) {
		sz = 64;
		break;
	    }
	}
	
    } else {
	sz = 64;
    }

    /* If we think the size is now really 64, do a similar check again */
    if (sz == 64) {
	if (gzread(fp, &m64, sizeof(maqmap64_t)) == -1)
	    return -1;

	gzseek(fp, curr, SEEK_SET);
	if (/*m64.size < 0 || */ m64.size > 64)
	    return -1;

	for (i = m64.size; i < 63; i++) {
	    if (m64.seq[i] != 0)
		return -1;
	}

	/* Check for valid name */
	for (i = 0; i < MAX_NAMELEN; i++) {
	    if (!m64.name[i])
		break;
	    if (!isprint(m64.name[i]))
		return -1;
	}
    }

    return sz;
}
	uint32 size() const {
		assert(fh);
		uint32 oldPos = gztell(fh);
		gzseek(fh, 0, SEEK_END);
		uint32 length = gztell(fh);
		gzseek(fh, oldPos, SEEK_SET);
		return length;
	}
static unsigned long VFSGZIP_GetLen(vfsfile_t *file) 
{
	int r, currentpos;
	vfsgzipfile_t *vfsgz = (vfsgzipfile_t *)file;
	
	// VFS-FIXME: Error handling
	currentpos = gztell((gzFile)vfsgz->parent->handle);
	r = gzseek((gzFile)vfsgz->parent->handle, 0, SEEK_END);
	gzseek((gzFile)vfsgz->parent->handle, currentpos, SEEK_SET);

	return r;
}
Exemple #10
0
//----------------------------------------------------
int zu_seek(ZUFILE *f, long offset, int whence)
{
    int res = 0;
    int bzerror=BZ_OK;
    if (whence == SEEK_END) {
        return -1;              // TODO
    }
    
    switch(f->type) {         //SEEK_SET, SEEK_CUR
        case ZU_COMPRESS_NONE :
            res = fseek((FILE*)(f->zfile), offset, whence);
            f->pos = ftell((FILE*)(f->zfile));
            break;
        case ZU_COMPRESS_GZIP :
            if (whence == SEEK_SET) {
                res = gzseek((gzFile)(f->zfile), offset, whence);
            }
            else {     // !!! BUG with SEEK_CUR in ZLIB !!!
                int p1 = gztell((gzFile)(f->zfile));
                res = gzseek((gzFile)(f->zfile), p1+offset, SEEK_SET);
            }
            f->pos = gztell((gzFile)(f->zfile));
            if (res >= 0)
                res = 0;
            break;
#ifndef __ANDROID__
        case ZU_COMPRESS_BZIP :
            if (whence==SEEK_SET  &&  offset >= f->pos) {
                res = zu_bzSeekForward(f, offset-f->pos);
            }
            else if (whence==SEEK_CUR) {
                res = zu_bzSeekForward(f, offset);
            }
            else {    // BAD : reopen file
                BZ2_bzReadClose (&bzerror,(BZFILE*)(f->zfile));
                bzerror=BZ_OK;
                rewind(f->faux);
                f->pos = 0;
                f->zfile = (void *) BZ2_bzReadOpen(&bzerror,f->faux,0,0,NULL,0);
                if (bzerror != BZ_OK) {
                    BZ2_bzReadClose (&bzerror,(BZFILE*)(f->zfile));
                    fclose(f->faux);
                    f->zfile = NULL;
                    f->ok = 0;
                }
                res = zu_bzSeekForward(f, offset);
            }
            break;
#endif
    }
    return res;
}
Exemple #11
0
int CFitSeek(struct CFitfp *ptr,
		 int yr,int mo,int dy,int hr,int mt,int sc,double *atme) {
  struct CFitdata *cfit=NULL;
  int status=0;
  double tval;
  int bjmp=0;
  tval=TimeYMDHMSToEpoch(yr,mo,dy,hr,mt,sc);
  cfit=CFitMake();
  cfit->frang=0;
  cfit->rsep=0;
  if (cfit==NULL) return -1;


  if (tval<ptr->ctime) {
    /* rewind the file */
    if (ptr->fbuf==NULL) gzseek(ptr->fp,0,SEEK_SET);
    else ptr->fptr=0;
    ptr->ctime=0;
    ptr->blen=0;
  }

  if (tval>=ptr->ctime) {
    do {
     bjmp=ptr->blen;
     status=CFitRead(ptr,cfit);
    } while ((tval>=ptr->ctime) && (status !=-1));

    if (status!=-1) {
      if (ptr->fbuf==NULL) gzseek(ptr->fp,-(ptr->blen+bjmp),SEEK_CUR);
        else ptr->fptr-=ptr->blen+bjmp;
    } else return -1;
  }
  /* get the actual time */

  do {  
    status=CFitRead(ptr,cfit);
  } while (status !=0);

  if (ptr->fbuf==NULL) gzseek(ptr->fp,-ptr->blen,SEEK_CUR);
  else ptr->fptr-=ptr->blen;

  if (atme !=NULL) {
    *atme=ptr->ctime;
  }

  CFitFree(cfit);
  if (status==-1) return 0;
  return 0;
} 
Exemple #12
0
int FCEU_fseek(FCEUFILE *fp, long offset, int whence)
{
 if(fp->type==1)
 {
  return( (gzseek(fp->fp,offset,whence)>0)?0:-1);
 } 
 else if(fp->type>=2)
 {
  MEMWRAP *wz;
  wz=(MEMWRAP*)fp->fp;

  switch(whence)
  {
   case SEEK_SET:if(offset>=wz->size)
                  return(-1);
                 wz->location=offset;break;
   case SEEK_CUR:if(offset+wz->location>wz->size)
                  return (-1);
                 wz->location+=offset;
                 break;
  }    
  return 0;
 }
 else
  return fseek((FILE *)fp->fp,offset,whence);
}
Exemple #13
0
static void findsize()
{
   if (!z)
     {
	fseek(rom_file, 0L, SEEK_END);
	taille_rom=ftell(rom_file);
	printf ("rom size: %d bytes (or %d Mb or %d Megabits)\n", 
		taille_rom, taille_rom/1024/1024, taille_rom/1024/1024*8);
	fseek(rom_file, 0L, SEEK_SET);
     }
   else if (z == 1)
     {
	taille_rom=0;
	rom=malloc(100000);
	for(;;)
	  {
	     i = gzread(z_rom_file, rom, 100000);
	     taille_rom += i;
	     printf ("rom size: %d bytes (or %d Mb or %d Megabits)\r",
		     taille_rom, taille_rom/1024/1024, taille_rom/1024/1024*8);
	     fflush(stdout);
	     if (!i) break;
	  }
	free(rom);
	rom = NULL;
	printf("\n");
	gzseek(z_rom_file, 0L, SEEK_SET);
     }
}
Exemple #14
0
DWORD ZFileSeek()
{
#ifdef CCBETA
    ZLog_Message("ZFileSeek %d",ZFileSeekHandle);

    if(FILETYPE[ZFileSeekHandle]==1)
    {
      return(0xFFFFFFFF);
    }
    else
    {
#endif
        int mode = 0;
        if (ZFileSeekMode==0)
            mode = SEEK_SET;
        else if (ZFileSeekMode==1) {
            mode = SEEK_END;
            if (TextFile==0)
                printf("Warning : gzseek(SEEK_END) not supported");
        } else return (0xFFFFFFFF);

        if (TextFile) {
            fseek(FILEHANDLE[ZFileSeekHandle], ZFileSeekPos, mode);
            return 0;
        } else {
            gzseek(FILEHANDLE[ZFileSeekHandle], ZFileSeekPos, mode);
            return 0;
        }
#ifdef CCBETA
    }
#endif
}
Exemple #15
0
/* -------------------------------------------------------------------------- */
float * MM5_getfield(t_mm5_file *file, int findex, int timestep, int vflag)
{
  static float *value;
  int i;
  int datanum;
  int dim1, dim2, dim3;
  z_off_t start;

  /* wrong request */
  if (findex < 0   || findex >= file->total_num     ||
      timestep < 0 || timestep >= file->total_times ||
      file == NULL) return NULL;

  /* get space */
  value = NULL;
  if ((value = malloc(file->vars[findex].fsize)) == NULL) return NULL;

  /* locate variable */
  start = file->vars[findex].fpos + file->timesize * timestep;
  if (file->mm5version == 3 && timestep > 0)
    start -= timestep * (5 * sizeof(int) + sizeof(t_mm5v3_big_header));

  /* go there and read it !! */
  gzseek(file->fp, start, SEEK_SET);
  if (fortran_read(file->fp, file->machorder,
               file->vars[findex].fsize, (char *) value) < 0)
  {
    fprintf(stderr, "Error read at pos %ld\n", start);
    free(value);
    return NULL;
  }
  if (file->machorder == LITTLE)
  {
    datanum = file->vars[findex].fsize / sizeof(float);
    for (i = 0; i < datanum; i ++) swab4(value+i);
  }

  /* fill dimensions */
  dim1 = file->vars[findex].fstopi[0] - file->vars[findex].fstarti[0] + 1;
  dim2 = file->vars[findex].fstopi[1] - file->vars[findex].fstarti[1] + 1;
  dim3 = file->vars[findex].fstopi[2] - file->vars[findex].fstarti[2] + 1;

  /* get rid of full sigma levels. I do not need them anymore */
  if (vflag)
  {
    if (file->vars[findex].full)
    {
      if (file->vars[findex].fstopi[2] > 1)
      {
        value = vertint(value, dim1, dim2, dim3 + 1);
      }
    }
  }

  /* sorry but in C we have transpost matrices */
  value = transpost(value, dim1, dim2, dim3);

  /* all ok */
  return value;
}
Exemple #16
0
/**
**	CLseek		Library file seek
**
**	@param file	CLFile pointer.
**	@param offset	Seek position
**	@param whence	How to seek
*/
global int CLseek(CLFile *file, long offset, int whence)
{
    int tp, ret = -1;

    if (file && (tp = file->cl_type) != CLF_TYPE_INVALID) {
	if (tp == CLF_TYPE_PLAIN) {
	    ret = fseek(file->cl_plain, offset, whence);
	}
#ifdef USE_ZLIB
	if (tp == CLF_TYPE_GZIP) {
	    ret = gzseek(file->cl_gz, offset, whence);
	}
#endif	// USE_ZLIB
#ifdef USE_BZ2LIB
	if (tp == CLF_TYPE_BZIP2) {
	    bzseek(file->cl_bz, offset, whence);
	    ret = 0;
	}
#endif	// USE_BZ2LIB
#ifdef USE_ZZIPLIB
	if (tp == CLF_TYPE_ZZIP) {
	    zzip_seek(file->cl_zz, offset, whence);
	    ret = 0;
	}
#endif	// USE_ZZIPLIB
    } else {
	errno = EBADF;
    }
    return ret;
}
Exemple #17
0
int CFile::PImpl::seek(long offset, int whence)
{
	int ret = -1;
	int tp = cl_type;

	if (tp != CLF_TYPE_INVALID) {
		if (tp == CLF_TYPE_PLAIN) {
			ret = fseek(cl_plain, offset, whence);
		}
#ifdef USE_ZLIB
		if (tp == CLF_TYPE_GZIP) {
			ret = gzseek(cl_gz, offset, whence);
		}
#endif // USE_ZLIB
#ifdef USE_BZ2LIB
		if (tp == CLF_TYPE_BZIP2) {
			bzseek(cl_bz, offset, whence);
			ret = 0;
		}
#endif // USE_BZ2LIB
	} else {
		errno = EBADF;
	}
	return ret;
}
Exemple #18
0
/**
   Move the current position pointer, like fseek
*/
int zfseek(file_t *fp, long offset, int whence) {
    if(fp->isgzip) {
        return gzseek((voidp)fp->p,offset,whence)<0?-1:0;
    } else {
        return fseek((FILE*)fp->p,offset,whence);
    }
}
Exemple #19
0
static Iterator getNextClass(ClassRegister *cr, Iterator ip, char **cn, 
      CMPIConstClass **cls, void **id)
{
   char *buf;
   CMPIConstClass *cc;
   ClassBase *cb = (ClassBase *) cr->hdl;
   ClassRecord *crec;
   int r;
   
   Iterator i = cb->ht->ft->getNext(cb->ht, ip, (void**)cn, (void**)&crec);
   if (i==0) return i;
 
   if (crec->cachedCls) {
      *id=crec;
      *cls=crec->cachedCls;
      return i;
   }
   *id=NULL;
   
   r=gzseek(cr->f, crec->position, SEEK_SET);
   
   buf = (char *) malloc(crec->length);
   r=gzread(cr->f, buf, crec->length);  
   
   cc = NEW(CMPIConstClass);
   cc->hdl = buf;
   cc->ft = CMPIConstClassFT;
   cc->ft->relocate(cc);
   *cls=cc;
   return i;
}      
Exemple #20
0
int RibTempClose( PRIB_INSTANCE prib )
{
   register PRIB_INSTANCE  rib = prib;


   
   if ( rib->status & kRIB_STATUS_STDIN )
      return kRIB_OK;

   rib->status |= kRIB_STATUS_CLOSED;
#if defined(RIB_ZLIB)
 {
    auto gzFile  *fp;
    
    /* Assume Affine Z library. */
    fp = rib->fp;

    rib->fpoffset = gzseek(fp, 0L, SEEK_CUR);/*gztell(fp);*/
    if (gzclose( fp ) )
      return kRIB_ERRRC_INT;
 }
#else
   if (fclose( rib->fp ) )
   {
      return kRIB_ERRRC_INT;
   }
   rib->fp = NULL;
#endif
   gRibNOpenSubfiles--;
   
   return kRIB_OK;
}
int do_gzip(const char* strGZ, const char* strInput)
{
	// take an input file (strInput) and turn it into a compressed file (strGZ)
	// get rid of the input file after 

	FILE* fIn = boinc_fopen(strInput, "rb");
	if (!fIn)  return 1; //error
	gzFile fOut = gzopen(strGZ, "wb");
	if (!fOut) return 1; //error

	fseek(fIn, 0, SEEK_SET);  // go to the top of the files
	gzseek(fOut, 0, SEEK_SET);
	unsigned char buf[1024];
	long lRead = 0, lWrite = 0;
	while (!feof(fIn)) { // read 1KB at a time until end of file
		memset(buf, 0x00, 1024);
		lRead = 0;
		lRead = fread(buf, 1, 1024, fIn);
		lWrite = gzwrite(fOut, buf, lRead);
		if (lRead != lWrite) break;
	}
	gzclose(fOut);
	fclose(fIn);

	if (lRead != lWrite) return 1;  //error -- read bytes != written bytes

	// if we made it here, it compressed OK, can erase strInput and leave
	boinc_delete_file(strInput);
	return 0;
}
Exemple #22
0
int
uproc_io_seek(uproc_io_stream *stream, long offset,
              enum uproc_io_seek_whence whence)
{
    int w;
    switch (whence) {
        case UPROC_IO_SEEK_SET:
            w = SEEK_SET;
            break;
        case UPROC_IO_SEEK_CUR:
            w = SEEK_CUR;
            break;
    }

    switch (stream->type) {
        case UPROC_IO_GZIP:
#if HAVE_ZLIB_H
            return gzseek(stream->s.gz, offset, w) >= 0 ? 0 : -1;
#endif
        case UPROC_IO_STDIO:
            return fseek(stream->s.fp, offset, w);
    }
    uproc_error_msg(UPROC_EINVAL, "invalid stream");
    return -1;
}
Exemple #23
0
static TACommandVerdict gzseek_cmd(TAThread thread,TAInputStream stream)
{
    void* file;
    z_off_t offset, res;
    int errnum, whence;

    file = readPointer(&stream);
    offset = (off_t)readLLong(&stream);
    whence = readInt(&stream);

    START_TARGET_OPERATION(thread);

    res = gzseek(file, offset, whence);

    END_TARGET_OPERATION(thread);

    gzerror(file, &errnum);

    writeInt(thread, errnum);
    writeLLong(thread, (long long)res);

    sendResponse(thread);

    return taDefaultVerdict;
}
Exemple #24
0
static int
fontFileSeek(fontFile *ff, z_off_t offset, int whence)
{
    if (ff->type == gzFontFile) {
	return gzseek(ff->f.gz, offset, whence);
    } else {
	/* bzlib has no easy equivalent so we have to fake it,
	 * fortunately, we only have to handle a couple of cases
	 */
	int n;
	char buf[BUFSIZ];

	switch (whence) {
	  case SEEK_SET:
	    n = offset - ff->pos;
	    break;
	  case SEEK_CUR:
	    n = offset;
	    break;
	  default:
	    return -1;
	}

	while (n > BUFSIZ) {
	    if (BZ2_bzread(ff->f.bz2, buf, BUFSIZ) != BUFSIZ)
		return -1;
	    n -= BUFSIZ;
	}
	if (BZ2_bzread(ff->f.bz2, buf, n) != n)
	    return -1;
	ff->pos = offset;
	return offset;
    }
}
Exemple #25
0
void MDFNI_SaveMovie(char *fname, uint32 *fb, MDFN_Rect *LineWidths)
{
    gzFile fp;

    if(current < 0)	/* Can't interrupt playback.*/
        return;

    if(current > 0)	/* Stop saving. */
    {
        StopRecording();
        return;
    }

    memset(&RewindBuffer, 0, sizeof(StateMem));
    RewindBuffer.initial_malloc = 16;

    current=CurrentMovie;

    if(fname)
        fp = gzopen(fname, "wb3");
    else
    {
        fp=gzopen(MDFN_MakeFName(MDFNMKF_MOVIE,CurrentMovie,0).c_str(),"wb3");
    }

    if(!fp) return;

    MDFNSS_SaveFP(fp, fb, LineWidths);
    gzseek(fp, 0, SEEK_END);
    gzflush(fp, Z_SYNC_FLUSH); // Flush output so that previews will still work right while
    // the movie is being recorded.  Purely cosmetic. :)
    slots[current] = fp;
    current++;
    MDFN_DispMessage(_("Movie recording started."));
}
Exemple #26
0
void gpuShowPic() {
	char Text[255];
	gzFile f;

	if (!ShowPic) {
		unsigned char *pMem;

		pMem = (unsigned char *) malloc(128*96*3);
		if (pMem == NULL) return;
		sprintf(Text, "sstates\\%10.10s.%3.3d", CdromLabel, StatesC);

		GPU_freeze(2, (GPUFreeze_t *)&StatesC);

		f = gzopen(Text, "rb");
		if (f != NULL) {
			gzseek(f, 32, SEEK_SET); // skip header
			gzread(f, pMem, 128*96*3);
			gzclose(f);
		} else {
			memcpy(pMem, NoPic_Image.pixel_data, 128*96*3);
			DrawNumBorPic(pMem, StatesC+1);
		}
		GPU_showScreenPic(pMem);

		free(pMem);
		ShowPic = 1;
	} else { GPU_showScreenPic(NULL); ShowPic = 0; }
}
Exemple #27
0
ossimGzStreamBuf::pos_type ossimGzStreamBuf::seekoff(off_type t,
                                                     std::ios_base::seekdir dir,
                                                     std::ios_base::openmode /* omode */)
{
   int whence = 0;
   switch(dir)
   {
      case std::ios::beg:
      {
         whence = SEEK_SET;
         break;
      }
      case std::ios::end:
      {
         whence = SEEK_END;
         break;
      }
      case std::ios::cur:
      {
         whence = SEEK_CUR;
         break;
      }
      default:
      {
         whence = SEEK_CUR;
         break;
      }
   }

   return gzseek(prvtData->file, t, whence);
}
Exemple #28
0
int get_header(struct log_global_header *hdr)
{
   int c;

   c = gzread(GBL_LOG_FD, hdr, sizeof(struct log_global_header));

   if (c != sizeof(struct log_global_header))
      return -E_INVALID;
   
   /* convert to host order */
   
   hdr->magic = ntohs(hdr->magic);
   
   if (hdr->magic != EC_LOG_MAGIC)
      return -E_INVALID;
   
   hdr->first_header = ntohs(hdr->first_header);
   gzseek(GBL_LOG_FD, hdr->first_header, SEEK_SET);
  
   /* adjust the timestamp */
   hdr->tv.tv_sec = ntohl(hdr->tv.tv_sec);
   hdr->tv.tv_usec = ntohl(hdr->tv.tv_usec);
   
   hdr->type = ntohl(hdr->type);
   
   return E_SUCCESS;
}
Exemple #29
0
/* 
 * Peaks at next line in file and counts number of fields.
 * Can be used to determine number of samples in file.
 * File is rewound to beginning after.
 * Returns -1 on failure.
*/
long impute_count_fields(gzFile fh) {
  char *line, *cur, *tok;
  char delim[] = " \t";
  long n;
  
  /* read a line */
  line = util_gzgets_line(fh);

  if(line == NULL) {
    my_err("%s:%d: no lines left in file, cannot count fields\n",
	   __FILE__, __LINE__);
  }

  cur = line;
  n = 0;
  while((tok = strsep(&cur, delim)) != NULL) {
    n++;
  }

  my_free(line);

  /* rewind to beginning of file */
  if(gzseek(fh, 0L, SEEK_SET) != 0) {
    my_err("%s:%d: could not rewind filehandle", __FILE__, __LINE__);
  }
  
  return n;
}
Exemple #30
-1
//Returns the number of bytes that can be read (or skipped over) from this input stream without blocking by the next caller of a method for this input stream. 
int GZInputStream::available()
{
	gzseek(m_file, 0, SEEK_END);
	long max_length = gztell(m_file);
	gzseek(m_file, 0, SEEK_SET);
	return max_length;
}