Author Topic: if utWriteFile(..) fails..  (Read 6873 times)

Offline neil

  • Sr. Member
  • ****
  • Posts: 438
    • View Profile
if utWriteFile(..) fails..
« on: May 31, 2011, 04:43:04 PM »
Hi Mark,
  If utWriteFile(..) failes , and not due to lack of disk space (and valid handle) :

1. Is it possible that anything can be written if UTFAT_SUCCESS not returned? For example, if 600 bytes was to be written, can 512 bytes be written and ptr_utFile->usLastReadWriteLength would = 512?

2. Is it a waste of time trying to write again? Or create a new file and write the data?

Thanks
neil

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3236
    • View Profile
    • uTasker
Re: if utWriteFile(..) fails..
« Reply #1 on: May 31, 2011, 08:30:42 PM »
Neil

1) It is (theoretically) possible that a write to a particular area of the SD card could fail. In this case some of the data may have been written and the rest not.

2) However, if this happens it presumably means that there is a serious problem with the card (or there is an error in the driver). Since the SD cards will have a controller performing management of bad blocks I wouldn't normally expect an error of this nature that could be cured by writing to a different file (the controller would be moving blocks around internally and will also internally write data to another block if one fails).

I would generally expect that no writes should ever fail (as long as the capacity is not used up) and if they do it is because of either communication errors or driver errors rather than memory errors on the card. A failed write is therefore more like an un-recoverable error.

Regards

Mark