NSFileHandle
is not the ideal class for this. Is there some reason you want to use that class or feel you have to?
You should use -[NSURL getResourceValue:forKey:error:]
with the keys NSURLCreationDateKey
, NSURLContentModificationDateKey
, and NSURLTypeIdentifierKey
.
If you really only have an NSFileHandle
to go on, you will have to obtain its file descriptor using the -fileDescriptor
method and then the fstat()
function to obtain the creation and modification times. You can use fcntl()
with F_GETPATH
to recover the path from a file descriptor. From there, you can construct an NSURL
use that to get the type (and, if you prefer, the dates, too).