[Filesystem] Problem with uncatchable exception when checking empty card reader
Hello, I am using the Filesystem library from boost 1.38.0 on Windows (Visual Studio 2005) like this: if (boost::filesystem::exists("W:") && boost::filesystem::is_empty("W:")) { ... do something useful ... } "W:" is assigned to an (usually) empty card reader slot. Unfortunately Filesystem's exists() function fails with an uncatchable exception. At least I cannot catch it... The exception is thrown by GetFileAttributesA() in operations.hpp: inline DWORD get_file_attributes( const char * ph ) { return ::GetFileAttributesA( ph ); } The exception pops up an error message that is titled "Windows - no disc" and it says: Exception Processing Message c0000013 Parameters 75b0bf9c 4 75b0bf9c 75b0bf9c Sadly, all I can do is to prefix a call to exists() with a call to GetVolumeInformationA() (from winbase.h) like this: if (GetVolumeInformationA("W:", NULL, NULL, NULL, NULL, NULL, NULL, NULL)) { if (boost::filesystem::exists("W:") && boost::filesystem::is_empty("W:")) { ... do something useful ... } } Is there any way to do this platform-independent? I have been searching the docs and the boost website, google and so on, to see if that can already be done with boost Filesystem. Since I did not find anything on this topic, I hope you can put me on the right track. Cheers, Marco Marco Wedekind | Software Developer | marco.wedekind@tomtom.com | +49(0)34124495-62 office | +49(0)34124495-25 fax TomTom Development Germany GmbH, Maximilianallee 4, D-04129 Leipzig, Germany | www.tomtomwork.com Amtsgericht Leipzig | HRB 22234 | Geschäftsführer: Thomas Schmidt, Marina Wyatt Think before you print This e-mail message contains information which is confidential and may be privileged. It is intended for use by the addressee only. If you are not the intended addressee, we request that you notify the sender immediately and delete or destroy this e-mail message and any attachment(s), without copying, saving, forwarding, disclosing or using its contents in any other way. TomTom N.V., TomTom Software, Ltd or any other company belonging to the TomTom group of companies will not be liable for damage relating to the communication by e-mail of data, documents or any other information. This e-mail message contains information which is confidential and may be privileged. It is intended for use by the addressee only. If you are not the intended addressee, we request that you notify the sender immediately and delete or destroy this e-mail message and any attachment(s), without copying, saving, forwarding, disclosing or using its contents in any other way. TomTom N.V., TomTom Software, Ltd or any other company belonging to the TomTom group of companies will not be liable for damage relating to the communication by e-mail of data, documents or any other information.
Marco Wedekind wrote:
Hello,
I am using the Filesystem library from boost 1.38.0 on Windows (Visual Studio 2005) like this:
if (boost::filesystem::exists("W:") && boost::filesystem::is_empty("W:")) { ... do something useful ... }
"W:" is assigned to an (usually) empty card reader slot. Unfortunately Filesystem's exists() function fails with an uncatchable exception. At least I cannot catch it... The exception is thrown by GetFileAttributesA() in operations.hpp:
inline DWORD get_file_attributes( const char * ph ) { return ::GetFileAttributesA( ph ); }
The exception pops up an error message that is titled "Windows - no disc" and it says:
Exception Processing Message c0000013 Parameters 75b0bf9c 4 75b0bf9c 75b0bf9c
This is a Windows structured exception, not a C++ exception. A call to SetErrorMode( SEM_FAILCRITICALERRORS ) may be what you need. http://msdn.microsoft.com/en-us/library/ms680621%28VS.85%29.aspx
participants (2)
-
Marco Wedekind
-
Peter Dimov