예제 #1
0
파일: hio.c 프로젝트: eltoder/libxmp
long hio_tell(HIO_HANDLE *h)
{
	switch (HIO_HANDLE_TYPE(h)) {
	case HIO_HANDLE_TYPE_FILE:
		return ftell(h->handle.file);
	case HIO_HANDLE_TYPE_MEMORY:
		return mtell(h->handle.mem);
	default:
		return -1;
	}
}
예제 #2
0
int mcopy(memstream *to, const unsigned int size, memstream *s){
	int _size=size;
	if(_size>mavail(s))_size=mavail(s);
	if(_size>mavail(to))_size=mavail(to);
	if(!_size)return 0;

	mread((unsigned char*)(to->p)+mtell(to),_size,s);mseek(to,_size,SEEK_CUR);
	//mwrite((unsigned char*)(s->p)+mtell(s),_size,to);mseek(s,_size,SEEK_CUR);

	return _size;
}
예제 #3
0
파일: SizeBin_.z.c 프로젝트: 8l/nhc98
int hs_sizeBin (BinHandle bh)
{ int n;
  
   unsigned curpos;
   closecache(bh);
   if (bh->file) {
     curpos = vtell(bh);		/* store current position */
     n = lseek(bh->loc.fd,0,SEEK_END);	/* jump to end of file */
   } else {
     curpos = mtell(bh);		/* store current position */
     n = bh->attrib.size;
   }
   opencache(bh);			/* then skip back again */
   bh->cptr = curpos - forceCacheTo(bh,curpos);
  return n;
}
예제 #4
0
types::Function::ReturnValue sci_mtell(types::typed_list &in, int _iRetCount, types::typed_list &out)
{
    int iFile           = -1; //default file : last opened file
    int dims            = 2;
    int dimsArray[2]    = {1, 1};
    types::Double* pOut = NULL;

    if (in.size() > 1)
    {
        Scierror(77, _("%s: Wrong number of input argument(s): %d to %d expected.\n"), "mtell", 0, 1);
        return types::Function::Error;
    }
    if (in.size() == 1)
    {
        if (in[0]->isDouble() == false || in[0]->getAs<types::Double>()->isScalar() == false || in[0]->getAs<types::Double>()->isComplex())
        {
            Scierror(999, _("%s: Wrong type for input argument #%d: A Real expected.\n"), "mtell", 1);
            return types::Function::Error;
        }

        iFile = static_cast<int>(in[0]->getAs<types::Double>()->get(0));
    }

    switch (iFile)
    {
        case 0: // stderr
        case 5: // stdin
        case 6: // stdout
            Scierror(999, _("%s: Wrong file descriptor: %d.\n"), "mtell", iFile);
            return types::Function::Error;
    }

    long long offset = mtell(iFile);
    if (offset < 0)
    {
        Scierror(999, _("%s: Error while opening, reading or writing.\n"), "mtell");
        return types::Function::Error;
    }

    pOut = new types::Double(dims, dimsArray);
    pOut->set(0, (double)offset);

    out.push_back(pOut);
    return types::Function::OK;
}