I am compiling a program on Windows with Mingw. How can I get the access mode for an open file descriptor?
相关问题
- Multiple sockets for clients to connect to
- What is the best way to do a search in a large fil
- Inheritance impossible in Windows Runtime Componen
- glDrawElements only draws half a quad
- how to get running process information in java?
As far as I can tell, you cant.
http://www.zemris.fer.hr/predmeti/os1/misc/Unix2Win.htm is a good guide for unix-to-windows porting.
Maybe you could use the Cygwin POSIX "emulation"?
According to Win32.hlp, the API supplies the function
BOOL GetFileInformationByHandle(HANDLE hFile, LPBY_HANDLE_FILE_INFORMATION lpFileInformation)
in KERNEL32.LPBY_HANDLE_FILE_INFORMATION
is aBY_HANDLE_FILE_INFORMATION*
, whereBY_HANDLE_FILE_INFORMATION
is as follows:After calling said function, if it returns true, the
BY_HANDLE_FILE_INFORMATION
contains data pertinent to your file.dwFileAttributes
may contain theFILE_ATTRIBUTE_READ_ONLY
flag.If you want more than that, there is also:
The API reference is necessarily vague on what a
SECURITY_DESCRIPTOR
is, but you can call a bunch of other functions using its address as a parameter to get specific properties. TheSECURITY_INFORMATION
is just aDWORD
constant specifying which of these functions you plan to call. You can find more info at http://msdn.microsoft.com/en-us/library/aa446641%28VS.85%29.aspxEdit - the second code section keeps coming out looking screwy, but the link to the API reference will lead you where you need to go if you dig around a bit.