|
-
April 28th, 2004, 12:56 PM
#1
filelength of file descriptor?
Im seeing g++ does not have a filelength function like Borland? So I wrote my own. My function always seems to return 5 greater than the value I need...
Code:
long filelength(int fd)
{
long pos = lseek(fd, 0, SEEK_CUR);
long end = lseek(fd, 0, SEEK_END);
lseek(fd, pos, SEEK_SET);
return (end);
}
-
April 28th, 2004, 01:03 PM
#2
-- deleted -- wrong code.
Last edited by Guysl; April 28th, 2004 at 01:15 PM.
**** **** **** **** **/**
-
April 28th, 2004, 01:39 PM
#3
Try something like:
Code:
long filelength(int fd)
{
long pos = tell(fd);
lseek(fd, 0, SEEK_END);
long end = tell(fd);
lseek(fd, pos, SEEK_SET);
return (end);
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|