How to get the file's created, modified dates and the kind of the file using NSFileHandle? please help me out with this question. i tried with NSDate, but dint find the solution.
Asked
Active
Viewed 149 times
1 Answers
0
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).

Ken Thomases
- 88,520
- 7
- 116
- 154