This is the mail archive of the cygwin@sources.redhat.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Optimizing away "ReadFile" calls when Make calls stat()


>  Date: Thu, 15 Feb 2001 16:09:46 -0500
>  From: "Larry Hall (RFK Partners, Inc)" <lhall@rfk.com>
>  
>  >Example code:
>  >
>  >         struct stat st;
>  >         stat_select("foo", &st, ST_MODE | ST_MTIME);
>  >
>  >Cygwin.DLL:
>  >         int stat(const char* file, struct stat* pst) 
>  >         {
>  >                 return stat_select(file, pst, 0xFFFFFFFF);
>  >         }
>  
>  
>  Sure, this is an idea for new, Cygwin specific code.  I'm not quite 
>  sure why someone who was writing new code (or changing old) wouldn't just
>  use Win32 APIs to accomplish the required task though.

Because all you would have to do to modify your code to work with
Cygwin is to use stat_select with the correct bitmask.  You wouldn't
have to convert any of the information returned by the Win32 APIs into
the format the rest of your code expects, and in fact you could just
keep using the same "struct stat" as you were using before.

In other words, something like this is a lot simpler than writing a
lot of Win32 API calls in your code:

        struct stat st;
        #ifdef __CYGWIN__
        stat_select("foo", &st, <whatever>);
        #else
        stat("foo", &st);
        #endif

  jik

--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]