When an application saves data to system NAND memory or USB storage, it can call the flush function after calling the write function in order to complete the save. Only call the flush function once, after the entire series of writes is finished.
If this guideline were not in place and the Power Button were pressed, the application would exit while it was still writing save data and would have to initialize the save data the next time it started. The purpose of this guideline is to avoid the need to initialize the save data in this situation. Essentially, the following issues must be prevented.
The Wii U system has measures to prevent data corruption. If the power is turned off during a write, it will roll back to the pre-write state. In this way, the system guarantees that data will not be corrupted if a user turns off the system during a write. However, if the application has multiple interdependent files, then performing separate flushes could result in inconsistencies between the files. As an example, consider an application that handles 10 separate files as a single save data file and flushes after writing to each file. If the power is turned off before the application finishes writing, when the user restarts the application, some of the files will be in an updated state and some will not.
When an application saves data to system NAND memory or USB storage, it can call the flush function after calling the write function in order to complete the save. Only call the flush function once, after the entire series of writes is finished. If this guideline were not in place and the Power Button were pressed, the application would exit while it was still writing save data and would have to initialize the save data the next time it started. The purpose of this guideline is to avoid the need to initialize the save data in this situation. Essentially, the following issues must be prevented. The Wii U system has measures to prevent data corruption. If the power is turned off during a write, it will roll back to the pre-write state. In this way, the system guarantees that data will not be corrupted if a user turns off the system during a write. However, if the application has multiple interdependent files, then performing separate flushes could result in inconsistencies between the files. As an example, consider an application that handles 10 separate files as a single save data file and flushes after writing to each file. If the power is turned off before the application finishes writing, when the user restarts the application, some of the files will be in an updated state and some will not.