Thanks Cho, that option looks familiar from years back when I was dealing dealing with sound recording devices. I don’t think it applies in my case.
Let’s say that I’ve implemented the code for writing the data directly to a file and all is working as expected. An UPS (or is it A UPS?) does not resolve or answer the original question - because a UPS can also break down!
Here’s an analogy using an old analog tape recorder:
I decide I’m going to record my latest greatest guitar composition
I set the levels then press record
I complete my composition (approx. 2 minutes)
The phone rings and I get distracted, therefore forget to press stop record
After ten minutes on the phone, there is a power blackout
When the power comes back on, I suddenly realise that I didn’t press stop record - but no big deal because I know the important recording is still on the tape somewhere. I then rewind the tape to that part and listen back to my wonderful performance.
BUT imagine if the situation was the same (as in the bullet points above) except, when the power came back on, I re-wound the tape to where the recording should have been, only to find, to my greatest alarm, there was nothing there!!
So then I do a bit of research and find out that this particular model of tape recorder has a peculiar habit of erasing the last recording on power up if there had been a power failure. Well, that situation would be utterly absurd and I would likely spend the rest of my life hunting down the perpetrator who created the said device and explaining to them my displeasure via the means of a clenched fist!
SO, this is where I’m at:
I will be implementing the “save as you go” approach. The file will be writing as it is reading from the usb port. But the issue still remains the same. If the user does not press stop, the file will not be closed and therefore a potential for corruption of the file?
Therefore, as I suggested earlier, would it not be better to do incremental saves, as in the temp file is incremented, ie. temp01, temp02, etc. that way it can at least be assured, that backup files are being created/written to/saved. This could be done say every 10 seconds. In the unlikely event of a power failure, the user could import a recovery file that is as the data file was, 10 seconds before the failure?
OR am I just over-thinking this?