From: C. M. <cl...@ci...> - 2011-11-01 07:18:02
|
On 30 October 2011 23:49, <min...@li...> wrote: > > Message: 8 > Date: Sun, 30 Oct 2011 19:32:23 +0400 > From: LRN <lr...@gm...> > Subject: Re: [Mingw-users] testing whether a file is a directory under > mingw > To: min...@li... > Message-ID: <4EA...@gm...> > Content-Type: text/plain; charset=UTF-8 > > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > On 30.10.2011 19:18, C. Meli wrote: >> Hello all, what is the preferred mingw way to test whether a file >> is a directory ? >> >> Best regards and thanks in advance CM >> > Well, one way would be to do: > > DWORD error, attributes = 0; > SetLastError (0); > attributes = GetFileAttributesA (filename); > error = GetLastError (); > if (attributes == INVALID_FILE_ATTRIBUTES || error != NO_ERROR) > { > /* handle the error */ > } > else if (attributes & FILE_ATTRIBUTE_DIRECTORY) > { > /* It's a directory */ > } > else > { > /* It is not a directory */ > } Thank you very much, that was what I was looking for (how to do it in C++). Sorry for the brevity of my post, but I was a bit in a rush.. :) I tried using stat but that function didn't work under mingw. I am using the TDM build (64 bit version). I did find an alternative - calling opendir on filename +"\\" allows me to determine this too successfully. Best regards and thanks CM >> >> >> Well, one way would be to do: >> > > Certainly, if you want to do it in a C/C++ program. But if you want > to do it in an MSYS shell it would be a different construct. What > does the OP really mean? > > -- > Earnie > -- http://www.for-my-kids.com > > > > ------------------------------ > > ------------------------------------------------------------------------------ > Get your Android app more play: Bring it to the BlackBerry PlayBook > in minutes. BlackBerry App World™ now supports Android™ Apps > for the BlackBerry® PlayBook™. Discover just how easy and simple > it is! http://p.sf.net/sfu/android-dev2dev > > > ------------------------------ > > _______________________________________________ > MinGW-users mailing list > Min...@li... > > You may change your MinGW Account Options or unsubscribe at: > https://lists.sourceforge.net/lists/listinfo/mingw-users > > > End of MinGW-users Digest, Vol 65, Issue 24 > ******************************************* > |