error checking in getfilesize

This commit is contained in:
Anshul Maheshwari 2014-07-23 13:10:42 +05:30
parent 6b98856892
commit fb49e680a6

View File

@ -9,9 +9,16 @@ LLONG buffered_read_opt_file (unsigned char *buffer, unsigned int bytes);
LLONG getfilesize (int in)
{
int ret = 0;
LLONG current=LSEEK (in, 0, SEEK_CUR);
LLONG length = LSEEK (in,0,SEEK_END);
LSEEK (in,current,SEEK_SET);
if(current < 0 ||length < 0)
return -1;
ret = LSEEK (in,current,SEEK_SET);
if (ret < 0)
return -1;
return length;
}