Sponsored Content
Top Forums Programming q on fseek() & ftell() + tga files Post 302220055 by JamesGoh on Wednesday 30th of July 2008 09:17:56 PM
Old 07-30-2008
q on fseek() & ftell() + tga files

In determining the true file size of a .tga file is the

Code:
fseek(fptr,0,SEEK_END);
file_size = ftell(fptr);

combination reliable ? The reason Im asking is because the value of file_size is in agreement with doing a

Code:
wc -c mytga.tga

however when I get the value of the extension area offset, it turns out to be much larger than the actual file size.

Thoughts and comments are much appreciated

James
 

10 More Discussions You Might Find Interesting

1. Programming

error when using fseek() function

The errors EBADF & ESPIPE occur at this fseek call. Does anybody know how to solve this problem? Thanks in advance. toFileStream=fdopen(localFileDes,"ra+"); if(fseek(toFileStream, 0, SEEK_END)!=0){ if(errno==EBADF) printf("errno==EBADF\n"); if(errno==EINVAL)... (3 Replies)
Discussion started by: ivancheung
3 Replies

2. Programming

Need help with ftell() function ..

Hello friends, I need help with ftell function in my programme, I can't figure out why I am not getting the file position what I supposed to get Here is my code void read_line(void *fh, double *input_re, double *input_im){ double a, b; char s; int n; ... (3 Replies)
Discussion started by: user_prady
3 Replies

3. Programming

.tga file reader + programming language

For a job I have to do, I have to design a .tga file reader, however I have had no prior experience in this area, so I was wondering what would be the best language to use to develop my .tga reader ? many thanks (1 Reply)
Discussion started by: JamesGoh
1 Replies

4. Programming

help with fseek

Hi, I working a c project in IBM AIX. I have a requirement like this. I have some contents in *temp. I am writing the contents of *temp to a file pointer ftemp (*ftemp for an tmp file tmpfile.txt) Now I want to read the contents of *ftemp in the reverse order an dneed to print it in the... (2 Replies)
Discussion started by: ramkrix
2 Replies

5. Shell Programming and Scripting

Find & Replace string in multiple files & folders using perl

find . -type f -name "*.sql" -print|xargs perl -i -pe 's/pattern/replaced/g' this is simple logic to find and replace in multiple files & folders Hope this helps. Thanks Zaheer (0 Replies)
Discussion started by: Zaheer.mic
0 Replies

6. Shell Programming and Scripting

How to compare 2 files & get only few columns based on a condition related to both files?

Hiiiii friends I have 2 files which contains huge data & few lines of it are as shown below File1: b.dat(which has 21 columns) SSR 1976 8 12 13 10 44.00 39.0700 70.7800 7.0 0 0.00 0 2.78 0.00 0.00 0 0.00 2.78 0 NULL ISC 1976 8 12 22 32 37.39 36.2942 70.7338... (6 Replies)
Discussion started by: reva
6 Replies

7. UNIX for Dummies Questions & Answers

How to compare 2 files & get specific value & replace it in other file.

Hiiii Friends I have 2 files with huge data. I want to compare this 2 files & if they hav same set of vales in specific rows & columns i need to get that value from one file & replace it in other. For example: I have few set data of both files here: a.dat: PDE-W 2009 12 16 5 29 11.11 ... (10 Replies)
Discussion started by: reva
10 Replies

8. Programming

help with reading a binary file and fseek

this is my code and no matter what record number the user enters i cant get any of the records fields to read into the structure acct. What am i doing wrong? #include <stdio.h> typedef struct { char name; int number; float balance; } acct_info_t; int main (int... (0 Replies)
Discussion started by: bjhum33
0 Replies

9. UNIX for Advanced & Expert Users

Find all files other than first two files dates & last file date for month

Hi All, I need to find all files other than first two files dates & last file date for month and month/year wise list. lets say there are following files in directory Mar 19 2012 c.txt Mar 19 2012 cc.txt Mar 21 2012 d.txt Mar 22 2012 f.txt Mar 24 2012 h.txt Mar 25 2012 w.txt Feb 12... (16 Replies)
Discussion started by: Makarand Dodmis
16 Replies

10. Shell Programming and Scripting

Compressing & removing files in a directory & subdirectory

Hi, I want a simple line of code that will compress files within a directory specified (parameter) and its subdirectories and also i want to remove files which are exactly 365 days old from the sysdate after this compression. Please help. Thanks, JD (8 Replies)
Discussion started by: Jesshelle David
8 Replies
FSEEK(3)						     Linux Programmer's Manual							  FSEEK(3)

NAME
fgetpos, fseek, fsetpos, ftell, rewind - reposition a stream SYNOPSIS
#include <stdio.h> int fseek(FILE *stream, long offset, int whence); long ftell(FILE *stream); void rewind(FILE *stream); int fgetpos(FILE *stream, fpos_t *pos); int fsetpos(FILE *stream, fpos_t *pos); DESCRIPTION
The fseek() function sets the file position indicator for the stream pointed to by stream. The new position, measured in bytes, is obtained by adding offset bytes to the position specified by whence. If whence is set to SEEK_SET, SEEK_CUR, or SEEK_END, the offset is relative to the start of the file, the current position indicator, or end-of-file, respectively. A successful call to the fseek() function clears the end-of-file indicator for the stream and undoes any effects of the ungetc(3) function on the same stream. The ftell() function obtains the current value of the file position indicator for the stream pointed to by stream. The rewind() function sets the file position indicator for the stream pointed to by stream to the beginning of the file. It is equivalent to: (void) fseek(stream, 0L, SEEK_SET) except that the error indicator for the stream is also cleared (see clearerr(3)). The fgetpos() and fsetpos() functions are alternate interfaces equivalent to ftell() and fseek() (with whence set to SEEK_SET), setting and storing the current value of the file offset into or from the object referenced by pos. On some non-Unix systems an fpos_t object may be a complex object and these routines may be the only way to portably reposition a text stream. RETURN VALUE
The rewind() function returns no value. Upon successful completion, fgetpos(), fseek(), fsetpos() return 0, and ftell() returns the cur- rent offset. Otherwise, -1 is returned and errno is set to indicate the error. ERRORS
EBADF The stream specified is not a seekable stream. EINVAL The whence argument to fseek() was not SEEK_SET, SEEK_END, or SEEK_CUR. The functions fgetpos(), fseek(), fsetpos(), and ftell() may also fail and set errno for any of the errors specified for the routines fflush(3), fstat(2), lseek(2), and malloc(3). CONFORMING TO
C89, C99. SEE ALSO
lseek(2), fseeko(3) COLOPHON
This page is part of release 3.27 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/. GNU
1993-11-29 FSEEK(3)
All times are GMT -4. The time now is 12:07 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy