views:

106

answers:

1

What is the difference in writing to files atomically on the iPhone in objective-c and not, is there any performance difference between the two?

Thanks in advance!

+6  A: 

Atomic in general means the operation cannot be interrupted. When writing files, that is accomplished by writing to a temporary file then replacing the original with the temporary when the write completes.

A crash while writing an atomic file means the original is not modified and there is a garbage file that can be deleted. A crash while writing normally would mean an expected good file is corrupt.

Performance wise the cost is minimal. During the write you will have two copies of a file. The file replace is a very simple operation at the file system level.

drawnonward