Re: HAVE: FILE *, WANT: filename
- From: Flash Gordon <spam@xxxxxxxxxxxxxxxxxx>
- Date: Fri, 12 Sep 2008 19:47:58 +0100
Richard wrote, On 12/09/08 12:43:
vippstar@xxxxxxxxx writes:
On Sep 12, 2:23 pm, Pelle <pelle1...@xxxxxx> wrote:Hello programmers,
I have a toolbox that's often working with a FILE * to access files
and the lot.
Recently, need has arisen to look at the filename of a file when I
only have a FILE *. I know I could be passing the filename from the
calling function, but since I don't know which entry to the toolbox I
took (e.g. toolbox-functions calling each other) it would be far
preferable
to query the filename of the file from the FILE * pointer that I
have.
Oh, and of course I'd need to find out if FILE * points to an actual
file or maybe something else.
Does anyone know how to do this?
Yes. Compile and link with a debug version of the libraries in question
and investigate in the debugger.
Assuming that debug versions of all the relevant code is available.
Or use a package like tags or etags or
cscope in order to find the definition of your implementations FILE
structure. Possibly what you want is stored for you. Possibly not. The
you get into implementation specific regions and you are better off
asking the provider of your compiler or experts in a forum/group
dedicated to that particular version.
So here you are giving exactly the advice you complain about vippstar giving, i.e. ask in a group dedicated to the specific implementation.
Not possible in standard C.
Nonsense. It is totally possible in C. What do you think the
implementations headers are? Pascal?
They can be implemented in any way the implementor wants, there is no requirement for them to be actual files let alone files containing C. They commonly are, but it is not required.
There might not be a function to
help him but if you think
"pFile->szFileName" is not standard C then there is a problem
Strangely enough the definition of the FILE structure on my system here does not include a pointer to the file name. I just looked. So if pFile is defined as a pointer to FILE it is NOT standard. If, on the other hand, it is a pointer to a user defined structure which has a field named szFileName it is entirely standard.
myStruct is not standard C either ....
It is an identifier the C standard allows the user to define. Nothing non-standard about it unless you are assuming the implementation provides it.
Jacob Navia maintains a compiler that offers this as an extension.
<http://www.cs.virginia.edu/~lcc-win32/>
There's possibly other compilers with such extensions. Discussing
those extensions, or the compilers here is off-topic.
For someone learning C you sure didn't take long to start strutting
around telling people what they can and can not discuss.
Perhaps he is a faster learner than you.
--
Flash Gordon
.
- Follow-Ups:
- Re: HAVE: FILE *, WANT: filename
- From: Pelle
- Re: HAVE: FILE *, WANT: filename
- References:
- HAVE: FILE *, WANT: filename
- From: Pelle
- Re: HAVE: FILE *, WANT: filename
- From: vippstar
- Re: HAVE: FILE *, WANT: filename
- From: Richard
- HAVE: FILE *, WANT: filename
- Prev by Date: Re: Returning structures from functions.
- Next by Date: Re: Reading .bmp file in C
- Previous by thread: Re: HAVE: FILE *, WANT: filename
- Next by thread: Re: HAVE: FILE *, WANT: filename
- Index(es):
Relevant Pages
|
Loading