Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Compilers LCC > Re: Getting the...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 64 of 172 Topic 1054 of 1070
Post > Topic >>

Re: Getting the file name from a FILE *

by CBFalconer <cbfalconer@[EMAIL PROTECTED] > Jun 25, 2008 at 06:25 PM

jacob navia wrote:
> CBFalconer wrote:
>
>> If you just want the name under which the file was opened, save
>> that at fopen time.  No load on the library, no muss, no fuss.  See
>> the strcpy function.
> 
> Yes sure. And how do the other functions that need this information
> will be able to get it????
> 
> int readfromLog(FILE *fp) {
>         char buf[512];
>         size_t bufsiz=sizeof(buf);
>         int s = fread(buf,1,bufsiz,fp);
>         if (s <= 0) {
>                 // How do I get the name of the file here Mr Falconer?
>         }
> }
> 
> You see the problem?

For example, create a thing:

  typdef struct fdata {
     FILE *f;
     char *fn;
  } fdata;

and replace your FILE * variables with that.  Initialize the
structures of that type to NULL and NULL.  Now you can store all
the data you require, no impingement on the standard, etc.  If you
want to pass the structure onward you can write:

   int getcx(fdata *ff) {
      int ch;
      if (EOF == (ch = getc(ff->f)) {
         printf("EOF received from %s\n", ff-?fn);
         /* here you can access whatever you wish */
      }
      return ch;
   }

or whatever is really needed.  You can make your own version of
fopen that initializes the fn field (use a deep copy of the actual
string).  Now it is never attempting to do the impossible.  No
tables needed.

The real point is that there are absolute impossibilities involved
in providing the ability in general through the system library. 
There are no difficulties in providing things at the user level
where the user can see exactly what is happening.

-- 
 [mail]: Chuck F (cbfalconer at maineline dot net) 
 [page]: <http://cbfalconer.home.att.net>
            Try the download section.


** Posted from http://www.teranews.com
**
 




 172 Posts in Topic:
Getting the file name from a FILE *
jacob navia <jacob@[EM  2008-06-20 17:11:49 
Re: Getting the file name from a FILE *
vippstar@[EMAIL PROTECTED  2008-06-20 08:28:12 
Re: Getting the file name from a FILE *
jacob navia <jacob@[EM  2008-06-20 18:00:50 
Re: Getting the file name from a FILE *
Kenneth Brody <kenbrod  2008-06-20 14:48:44 
Re: Getting the file name from a FILE *
Lew Pitcher <lpitcher@  2008-06-23 11:19:29 
Re: Getting the file name from a FILE *
vippstar@[EMAIL PROTECTED  2008-06-20 09:13:37 
Re: Getting the file name from a FILE *
Kenneth Brody <kenbrod  2008-06-20 14:43:21 
Re: Getting the file name from a FILE *
"Joachim Schmitz&quo  2008-06-20 17:32:27 
Re: Getting the file name from a FILE *
jacob navia <jacob@[EM  2008-06-20 18:05:18 
Re: Getting the file name from a FILE *
Eric Sosman <Eric.Sosm  2008-06-20 12:41:50 
Re: Getting the file name from a FILE *
mingyanguo <guomingyan  2008-06-20 10:49:05 
Re: Getting the file name from a FILE *
jacob navia <jacob@[EM  2008-06-20 20:14:11 
Re: Getting the file name from a FILE *
santosh <santosh.k83@[  2008-06-20 23:56:40 
Re: Getting the file name from a FILE *
Eric Sosman <Eric.Sosm  2008-06-20 14:49:52 
Re: Getting the file name from a FILE *
richard@[EMAIL PROTECTED]  2008-06-20 22:18:18 
Re: Getting the file name from a FILE *
William Ahern <william  2008-06-23 20:15:43 
Re: Getting the file name from a FILE *
"Dik T. Winter"  2008-06-24 10:42:18 
Re: Getting the file name from a FILE *
"christian.bau"  2008-06-20 15:10:46 
Re: Getting the file name from a FILE *
richard@[EMAIL PROTECTED]  2008-06-20 22:21:41 
Re: Getting the file name from a FILE *
Ian Collins <ian-news@  2008-06-21 10:27:08 
Re: Getting the file name from a FILE *
CBFalconer <cbfalconer  2008-06-20 19:42:30 
Re: Getting the file name from a FILE *
roberson@[EMAIL PROTECTED  2008-06-20 15:40:36 
Re: Getting the file name from a FILE *
jacob navia <jacob@[EM  2008-06-20 23:03:33 
Re: Getting the file name from a FILE *
Chris Peters <no@[EMAI  2008-06-20 22:22:46 
Re: Getting the file name from a FILE *
roberson@[EMAIL PROTECTED  2008-06-20 21:38:20 
Re: Getting the file name from a FILE *
jacob navia <jacob@[EM  2008-06-20 23:39:05 
Re: Getting the file name from a FILE *
richard@[EMAIL PROTECTED]  2008-06-20 22:25:39 
Re: Getting the file name from a FILE *
Keith Thompson <kst-u@  2008-06-20 15:10:51 
Re: Getting the file name from a FILE *
CBFalconer <cbfalconer  2008-06-20 19:49:31 
Re: Getting the file name from a FILE *
rlb@[EMAIL PROTECTED] (R  2008-06-23 07:35:52 
Re: Getting the file name from a FILE *
CBFalconer <cbfalconer  2008-06-23 17:53:40 
Re: Getting the file name from a FILE *
Richard<rgrdev@[EMAIL   2008-06-29 21:40:20 
Re: Getting the file name from a FILE *
Richard<rgrdev@[EMAIL   2008-06-30 14:10:34 
Re: Getting the file name from a FILE *
CBFalconer <cbfalconer  2008-06-29 20:27:38 
Re: Getting the file name from a FILE *
santosh <santosh.k83@[  2008-06-30 09:40:25 
Re: Getting the file name from a FILE *
Richard<rgrdev@[EMAIL   2008-06-30 12:49:34 
Re: Getting the file name from a FILE *
gazelle@[EMAIL PROTECTED]  2008-06-30 11:45:59 
Re: Getting the file name from a FILE *
CBFalconer <cbfalconer  2008-06-30 22:18:47 
Re: Getting the file name from a FILE *
Nigel <nigel.redding@[  2008-06-29 09:48:19 
Re: Getting the file name from a FILE *
roberson@[EMAIL PROTECTED  2008-06-29 18:46:24 
Re: Getting the file name from a FILE *
CBFalconer <cbfalconer  2008-06-29 15:22:55 
Re: Getting the file name from a FILE *
roberson@[EMAIL PROTECTED  2008-06-29 20:07:10 
Re: Getting the file name from a FILE *
Keith Thompson <kst-u@  2008-06-29 13:02:34 
Re: Getting the file name from a FILE *
Johannes Bauer <dfnson  2008-06-20 18:04:21 
Re: Getting the file name from a FILE *
jacob navia <jacob@[EM  2008-06-20 18:08:16 
Re: Getting the file name from a FILE *
"Charlie Gordon"  2008-08-14 00:18:43 
Re: Getting the file name from a FILE *
vippstar@[EMAIL PROTECTED  2008-06-20 09:17:31 
Re: Getting the file name from a FILE *
Eric Sosman <Eric.Sosm  2008-06-20 12:25:30 
Re: Getting the file name from a FILE *
Daniel Pitts <newsgrou  2008-06-20 09:23:19 
Re: Getting the file name from a FILE *
Keith Thompson <kst-u@  2008-06-20 10:29:02 
Re: Getting the file name from a FILE *
Flash Gordon <spam@[EM  2008-06-20 19:42:16 
Re: Getting the file name from a FILE *
Peter Nilsson <airia@[  2008-06-24 20:45:14 
Re: Getting the file name from a FILE *
CBFalconer <cbfalconer  2008-06-25 09:08:25 
Re: Getting the file name from a FILE *
jacob navia <jacob@[EM  2008-06-25 16:55:07 
Re: Getting the file name from a FILE *
Cesar Rabak <csrabak@[  2008-06-25 15:13:10 
Re: Getting the file name from a FILE *
jacob navia <jacob@[EM  2008-06-25 20:47:02 
Re: Getting the file name from a FILE *
Cesar Rabak <csrabak@[  2008-06-25 17:26:27 
Re: Getting the file name from a FILE *
Eric Sosman <Eric.Sosm  2008-06-25 16:34:48 
Re: Getting the file name from a FILE *
"Dik T. Winter"  2008-06-26 10:31:32 
Re: Getting the file name from a FILE *
"rio" <a@[EM  2008-06-25 22:11:27 
Re: Getting the file name from a FILE *
Tor Rustad <bwzcab@[EM  2008-06-25 22:52:21 
Re: Getting the file name from a FILE *
jacob navia <jacob@[EM  2008-06-25 23:24:52 
Re: Getting the file name from a FILE *
Tor Rustad <bwzcab@[EM  2008-06-26 00:21:26 
Re: Getting the file name from a FILE *
CBFalconer <cbfalconer  2008-06-25 18:25:21 
Re: Getting the file name from a FILE *
Chris Dollin <chris.do  2008-06-25 16:07:42 
Re: Getting the file name from a FILE *
Ben Bacarisse <ben.use  2008-06-25 15:46:40 
Re: Getting the file name from a FILE *
vippstar@[EMAIL PROTECTED  2008-06-25 08:38:19 
Re: Getting the file name from a FILE *
jacob navia <jacob@[EM  2008-06-25 18:51:21 
Re: Getting the file name from a FILE *
Ian Collins <ian-news@  2008-06-26 07:13:16 
Re: Getting the file name from a FILE *
Ben Bacarisse <ben.use  2008-06-25 16:41:45 
Re: Getting the file name from a FILE *
"Bartc" <bc@  2008-06-25 16:15:30 
Re: Getting the file name from a FILE *
vippstar@[EMAIL PROTECTED  2008-06-25 10:05:38 
Re: Getting the file name from a FILE *
Richard<rgrdev@[EMAIL   2008-06-25 19:09:52 
Re: Getting the file name from a FILE *
Ben Bacarisse <ben.use  2008-06-25 22:13:23 
Re: Getting the file name from a FILE *
CBFalconer <cbfalconer  2008-06-25 10:58:12 
Re: Getting the file name from a FILE *
Nick Keighley <nick_ke  2008-06-26 01:54:33 
Re: Getting the file name from a FILE *
vippstar@[EMAIL PROTECTED  2008-06-26 03:34:12 
Re: Getting the file name from a FILE *
Tor Rustad <tor_rustad  2008-06-20 21:19:25 
Re: Getting the file name from a FILE *
jacob navia <jacob@[EM  2008-06-20 23:01:22 
Re: Getting the file name from a FILE *
Tor Rustad <tor_rustad  2008-06-21 18:45:27 
Re: Getting the file name from a FILE *
Keith Thompson <kst-u@  2008-06-21 20:19:27 
Re: Getting the file name from a FILE *
Richard Heathfield <rj  2008-06-22 03:53:23 
Re: Getting the file name from a FILE *
Tor Rustad <tor_rustad  2008-06-22 10:34:55 
Re: Getting the file name from a FILE *
CBFalconer <cbfalconer  2008-06-20 18:20:17 
Re: Getting the file name from a FILE *
Richard<rgrdev@[EMAIL   2008-06-21 00:47:09 
Re: Getting the file name from a FILE *
"Serve Lau" <  2008-06-21 16:48:30 
Re: Getting the file name from a FILE *
richard@[EMAIL PROTECTED]  2008-06-21 16:13:14 
Re: Getting the file name from a FILE *
"Serve Lau" <  2008-06-21 18:22:45 
Re: Getting the file name from a FILE *
richard@[EMAIL PROTECTED]  2008-06-21 17:53:26 
Re: Getting the file name from a FILE *
"Serve Lau" <  2008-06-21 21:37:53 
Re: Getting the file name from a FILE *
richard@[EMAIL PROTECTED]  2008-06-21 21:38:18 
Re: Getting the file name from a FILE *
jacob navia <jacob@[EM  2008-06-21 23:39:13 
Re: Getting the file name from a FILE *
richard@[EMAIL PROTECTED]  2008-06-21 21:53:29 
Re: Getting the file name from a FILE *
Ralf Damaschke <rwspam  2008-06-21 18:08:46 
Re: Getting the file name from a FILE *
roberson@[EMAIL PROTECTED  2008-06-21 19:30:37 
Re: Getting the file name from a FILE *
Eric Sosman <esosman@[  2008-06-21 15:33:13 
Re: Getting the file name from a FILE *
"Serve Lau" <  2008-06-27 19:08:07 
Re: Getting the file name from a FILE *
richard@[EMAIL PROTECTED]  2008-06-27 20:18:52 
Re: Getting the file name from a FILE *
jacob navia <jacob@[EM  2008-06-27 23:16:56 
Re: Getting the file name from a FILE *
Chris Peters <no@[EMAI  2008-06-27 22:29:55 
Re: Getting the file name from a FILE *
jacob navia <jacob@[EM  2008-06-27 23:33:12 
Re: Getting the file name from a FILE *
Richard Heathfield <rj  2008-06-27 21:41:46 
Re: Getting the file name from a FILE *
richard@[EMAIL PROTECTED]  2008-06-27 21:46:46 
Re: Getting the file name from a FILE *
"Serve Lau" <  2008-06-27 23:53:03 
Re: Getting the file name from a FILE *
Tor Rustad <bwzcab@[EM  2008-06-29 14:40:14 
Re: Getting the file name from a FILE *
richard@[EMAIL PROTECTED]  2008-06-29 14:49:37 
Re: Getting the file name from a FILE *
Tor Rustad <bwzcab@[EM  2008-06-29 20:45:26 
Re: Getting the file name from a FILE *
richard@[EMAIL PROTECTED]  2008-06-29 22:10:24 
Re: Getting the file name from a FILE *
Tor Rustad <bwzcab@[EM  2008-06-30 02:05:18 
Re: Getting the file name from a FILE *
richard@[EMAIL PROTECTED]  2008-06-30 08:38:53 
Re: Getting the file name from a FILE *
Tor Rustad <bwzcab@[EM  2008-06-30 18:46:23 
Re: Getting the file name from a FILE *
richard@[EMAIL PROTECTED]  2008-06-30 17:28:10 
Re: Getting the file name from a FILE *
Tor Rustad <bwzcab@[EM  2008-06-30 20:27:39 
Re: Getting the file name from a FILE *
richard@[EMAIL PROTECTED]  2008-06-30 19:18:56 
Re: Getting the file name from a FILE *
"Dik T. Winter"  2008-06-30 03:15:40 
Re: Getting the file name from a FILE *
jacob navia <jacob@[EM  2008-06-30 10:23:26 
Re: Getting the file name from a FILE *
richard@[EMAIL PROTECTED]  2008-06-30 08:43:16 
Re: Getting the file name from a FILE *
santosh <santosh.k83@[  2008-06-22 01:18:04 
Re: Getting the file name from a FILE *
jacob navia <jacob@[EM  2008-06-21 20:01:45 
Re: Getting the file name from a FILE *
"Serve Lau" <  2008-06-21 21:47:13 
Re: Getting the file name from a FILE *
jacob navia <jacob@[EM  2008-06-21 23:41:24 
Re: Getting the file name from a FILE *
Richard Heathfield <rj  2008-06-21 22:02:04 
Re: Getting the file name from a FILE *
jacob navia <jacob@[EM  2008-06-22 00:12:22 
Re: Getting the file name from a FILE *
Richard Heathfield <rj  2008-06-21 23:17:29 
Re: Getting the file name from a FILE *
"Serve Lau" <  2008-06-22 03:47:29 
Re: Getting the file name from a FILE *
"Bartc" <bc@  2008-06-22 17:06:41 
Re: Getting the file name from a FILE *
"Charlie Gordon"  2008-08-16 22:51:28 
Re: Getting the file name from a FILE *
Nick Keighley <nick_ke  2008-06-23 01:18:23 
Re: Getting the file name from a FILE *
richard@[EMAIL PROTECTED]  2008-06-23 09:37:10 
Re: Getting the file name from a FILE *
"Serve Lau" <  2008-06-23 20:00:49 
Re: Getting the file name from a FILE *
Peter Nilsson <airia@[  2008-06-26 17:01:16 
Re: Getting the file name from a FILE *
forkazoo <wrosecrans@[  2008-06-21 19:47:59 
Re: Getting the file name from a FILE *
CBFalconer <cbfalconer  2008-06-22 01:33:24 
Re: Getting the file name from a FILE *
John Bode <jfbode1029@  2008-06-22 09:32:37 
Re: Getting the file name from a FILE *
CBFalconer <cbfalconer  2008-06-22 01:10:58 
Re: Getting the file name from a FILE *
Richard<rgrdev@[EMAIL   2008-06-23 12:45:10 
Re: Getting the file name from a FILE *
jacob navia <jacob@[EM  2008-06-23 13:09:23 
Re: Getting the file name from a FILE *
Antoninus Twink <nospa  2008-06-23 20:43:49 
Re: Getting the file name from a FILE *
John Bode <jfbode1029@  2008-06-23 07:16:14 
Re: Getting the file name from a FILE *
jacob navia <jacob@[EM  2008-06-23 16:22:01 
Re: Getting the file name from a FILE *
"Dik T. Winter"  2008-06-23 14:58:21 
Re: Getting the file name from a FILE *
richard@[EMAIL PROTECTED]  2008-06-23 17:23:42 
Re: Getting the file name from a FILE *
CBFalconer <cbfalconer  2008-06-23 18:01:08 
Re: Getting the file name from a FILE *
richard@[EMAIL PROTECTED]  2008-06-24 00:38:49 
Re: Getting the file name from a FILE *
CBFalconer <cbfalconer  2008-06-23 22:22:26 
Re: Getting the file name from a FILE *
Ian Collins <ian-news@  2008-06-24 17:46:45 
Re: Getting the file name from a FILE *
jacob navia <jacob@[EM  2008-06-24 08:02:36 
Re: Getting the file name from a FILE *
Ian Collins <ian-news@  2008-06-24 19:24:14 
Re: Getting the file name from a FILE *
"Bartc" <bc@  2008-06-24 09:40:04 
Re: Getting the file name from a FILE *
roberson@[EMAIL PROTECTED  2008-06-24 12:42:54 
Re: Getting the file name from a FILE *
CBFalconer <cbfalconer  2008-06-24 17:08:53 
Re: Getting the file name from a FILE *
Hans Schneider <hans@[  2008-06-28 03:12:33 
Re: Getting the file name from a FILE *
CBFalconer <cbfalconer  2008-06-28 09:48:09 
Re: Getting the file name from a FILE *
Richard Heathfield <rj  2008-06-24 09:41:13 
Re: Getting the file name from a FILE *
roberson@[EMAIL PROTECTED  2008-06-24 13:25:32 
Re: Getting the file name from a FILE *
Richard Heathfield <rj  2008-06-24 13:36:50 
Re: Getting the file name from a FILE *
Nick Keighley <nick_ke  2008-06-24 00:28:09 
Re: Getting the file name from a FILE *
Ian Collins <ian-news@  2008-06-24 19:31:49 
Re: Getting the file name from a FILE *
Nick Keighley <nick_ke  2008-06-24 00:31:09 
Re: Getting the file name from a FILE *
Nick Keighley <nick_ke  2008-06-24 00:38:50 
Re: Getting the file name from a FILE *
Ian Collins <ian-news@  2008-06-24 19:41:46 
Re: Getting the file name from a FILE *
Nick Keighley <nick_ke  2008-06-24 02:20:03 
Re: Getting the file name from a FILE *
"robertwessel2@[EMAI  2008-06-25 21:17:10 
Re: Getting the file name from a FILE *
Ben Bacarisse <ben.use  2008-06-23 15:44:18 
Re: Getting the file name from a FILE *
"Bartc" <bc@  2008-06-23 15:08:33 
Re: Getting the file name from a FILE *
Richard Heathfield <rj  2008-06-23 15:24:46 
Re: Getting the file name from a FILE *
"robertwessel2@[EMAI  2008-06-23 13:54:18 
Re: Getting the file name from a FILE *
Ben Bacarisse <ben.use  2008-06-23 22:14:04 
Re: Getting the file name from a FILE *
Richard<rgrdev@[EMAIL   2008-06-23 12:44:34 
Re: Getting the file name from a FILE *
Richard<rgrdev@[EMAIL   2008-06-24 11:03:50 
Re: Getting the file name from a FILE *
"Bartc" <bc@  2008-06-25 20:41:28 
Re: Getting the file name from a FILE *
CBFalconer <cbfalconer  2008-06-25 18:42:21 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Tue Oct 7 12:41:02 CDT 2008.