hetelek / Velocity

A cross-platform application built using the Qt framework that allows you to browse and edit Xbox 360 files.
GNU General Public License v3.0
162 stars 47 forks source link

Disconnecting a drive while being read may cause infinite loop #25

Closed SteffenL closed 11 years ago

SteffenL commented 11 years ago

More specifically, FileIO doesn't check if read/write failed, and code using it may keep trying to read data, e.g. in FatxDrive::ReadClusterChain(). The result is that the program will freeze.

Now throws exception on failure. Not sure if other checks are necessary, so it only checks read/write this time.

If the error is caused by the user disconnecting a USB device, the user probably doesn't see the USB device itself as a "file", and the exception message "Error reading from file" may in that case seem misleading.

Still, I think it's better than the program freezing.

Another idea is to set the exception mask for the stream so that a more specific exception type is thrown. Please see this: http://www.cplusplus.com/reference/ios/ios/exceptions/

Since std::string is thrown pretty much everywhere already, I followed that practice.