E
Edd
Hello,
I have an array of strings containing filenames. I must open each in turn
and parse the data within. However, if a filename appears multiple times in
the list it must still only be read and parsed once.
Initially, to solve this problem I thought strcmp'ing the filenames would
suffice to check for duplicates in the list. However, it may be the case
that "somefile.in" identifies the same file as "~/inputs/somefile.in",
despite the strings being different. Thus simply using strcmp is inadequate.
Assuming:
FILE *fptr1 = fopen("somefile.in", "rb");
FILE *fptr2 = fopen("~/inputs/somefile.in", "rb");
both return non-NULL, is there a portable way of checking that fptr1 and
fptr2 are associated with the same stream?
As a really nasty hack, I could check equality of the appropriate fields in
the FILEs. But that probably wouldn't port outside of a given implementation
of the standard library, let alone across Operating Systems.
Can anybody suggest a way around my problem?
Thanks,
Edd
I have an array of strings containing filenames. I must open each in turn
and parse the data within. However, if a filename appears multiple times in
the list it must still only be read and parsed once.
Initially, to solve this problem I thought strcmp'ing the filenames would
suffice to check for duplicates in the list. However, it may be the case
that "somefile.in" identifies the same file as "~/inputs/somefile.in",
despite the strings being different. Thus simply using strcmp is inadequate.
Assuming:
FILE *fptr1 = fopen("somefile.in", "rb");
FILE *fptr2 = fopen("~/inputs/somefile.in", "rb");
both return non-NULL, is there a portable way of checking that fptr1 and
fptr2 are associated with the same stream?
As a really nasty hack, I could check equality of the appropriate fields in
the FILEs. But that probably wouldn't port outside of a given implementation
of the standard library, let alone across Operating Systems.
Can anybody suggest a way around my problem?
Thanks,
Edd