forked from mkazhdan/PoissonRecon
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove more silently failing file writes. See mkazhdan#280.
In general, the code's IO design has a problem: It uses RAII for file resource handling. This is not robust, because only `fclose()` (or `fflush()`) is guaranteed to actually pass data to the OS, and thus surface potential errors. "RAII-for-files" requires that `fclose()` be put in C++ destructors. But destructors are not allowed to `throw`. Thus "RAII-for-files" cannot do proper error handling of failed writes. **C++ RAII cannot be used for file management.** Or anything where the cleanup action can fail. (Unless you're happy to swallow errors silently, which nobody should be.) This commit replaces all calls to `fwrite()` and `fclose()` by throwing_fwrite() throwing_fclose() fwrite_from_destructor() fclose_from_destructor() All variants try to report good error reasons, such as "no space left on device" (currently only imlemented for POSIX, not for Windows, where no error details are produced). The `*_from_destructor()` versions use non-allocating writes to `std::cerr` and terminate the program.
- Loading branch information
Showing
23 changed files
with
161 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.