Re: How do I check the existence of a file programmatically in C?q~~.
From: Giorgos Keramidas (keramida_at_ceid.upatras.gr)
Date: 09/01/05
- Next message: Måns Rullgård: "Re: How do I check the existence of a file programmatically in C?q~~."
- Previous message: Bjorn Reese: "Re: where for interop questions?"
- In reply to: Anton Petrusevich: "Re: How do I check the existence of a file programmatically in C?q~~."
- Next in thread: Maxim Yegorushkin: "Re: How do I check the existence of a file programmatically in C?q~~."
- Reply: Maxim Yegorushkin: "Re: How do I check the existence of a file programmatically in C?q~~."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 01 Sep 2005 22:48:18 +0300
Anton Petrusevich <casus@att-ltd.biz> writes:
>M?ns Rullg?rd wrote:
>> Just because not everybody needs it, it isn't a good idea to add extra
>> code to get rid of it.
>
> It depends. Suppose we have:
>
> void read_data(const char *fdata)
> {
> [...]
> }
>
> int main()
> {
> [...]
> for(i = 0; i < NUMOF(datafiles); ++i)
> if(access(datafiles[i], R_OK) == 0)
> read_data(datafiles[i]);
> [...]
> }
>
> I think it's perfectly ok to check existence of a file before calling
> supposedly heavy function read_data().
That looks a lot like a micro-optimization, and these are, in general,
only justified if they're backed with real experimental data that shows
the micro-optimization *is*, in fact, required.
Not to mention that the fictitious read_data() function is not only
expensive, but a bit maldesigned, having no meaningful way to return
success or failure :P
- Next message: Måns Rullgård: "Re: How do I check the existence of a file programmatically in C?q~~."
- Previous message: Bjorn Reese: "Re: where for interop questions?"
- In reply to: Anton Petrusevich: "Re: How do I check the existence of a file programmatically in C?q~~."
- Next in thread: Maxim Yegorushkin: "Re: How do I check the existence of a file programmatically in C?q~~."
- Reply: Maxim Yegorushkin: "Re: How do I check the existence of a file programmatically in C?q~~."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]