简体   繁体   中英

NSFileManager: Copy a file atomically?

in my iPhone projects, I am currently copying files using NSFileManager 's -copyItemAtPath:toPath:error: method. However, the docs so not say anything about atomicity, so I might run into trouble if my app tries to read a file that is currently being replaced by another thread. Is there a way to copy or replace a file atomically? I am searching for something like NSData 's -writeDataToFilr:atomically: .

How do you use NSFileManager ? According to the docs , it says the following:

In iOS and Mac OS X v 10.5 and later you should consider using [[NSFileManager alloc] init] rather than the singleton method defaultManager . Instances of NSFileManager are considered thread-safe when created using [[NSFileManager alloc] init] .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM