module NHC.Binary ( sizeBin ) where import NHC.GreenCard import BinHandle ({-type-}BinHandle(..)) %-#include "cLowBinary.h" %fun sizeBin :: BinHandle -> IO Int %call (binHandle bh) %code % 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); %result (int n)