| | |
Get File creation Date
Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Dec 2008
Posts: 2
Reputation:
Solved Threads: 1
C++ Syntax (Toggle Plain Text)
do { FSRef ref; if (noErr != FSPathMakeRef((const UInt8 *)filePath, &ref, NULL)) break; FSCatalogInfo catalogInfo; if (noErr != FSGetCatalogInfo(&ref, kFSCatInfoCreateDate, &catalogInfo, NULL, NULL, NULL)) break; UTCDateTime createDate = catalogInfo.createDate; CFAbsoluteTime absTime; if (noErr != UCConvertUTCDateTimeToCFAbsoluteTime (&createDate, &absTime)) break; CFGregorianDate gregorianDate = CFAbsoluteTimeGetGregorianDate (absTime, NULL); } while (false);
CFGregorianDate is a struct containing fields such as year, month, day etc.
•
•
Join Date: Dec 2008
Posts: 2
Reputation:
Solved Threads: 1
basically:
FSPathMakeRef creates a FSRef object from a given file path.
This object is passed to FSGetCatalogInfo function which returns an info about the file. kFSCatInfoCreateDate is a flag that notifies you're interested only in the creation date. You can combine different flags to obtain information about the file, which returns in catalogInfo object. Since you're interested only in the creation time, you can then access it via catalogInfo.createDate field. It's saved as UTCTime object. If you want to convert it to readable format, you first need to convert it to absolute time (using UCConvertUTCDateTimeToCFAbsoluteTime), and then to CFGregorianDate by using CFAbsoluteTimeGetGregorianDate.
BTW, developer.apple.com is an excellent source of information, you can read about all these methods there.
FSPathMakeRef creates a FSRef object from a given file path.
This object is passed to FSGetCatalogInfo function which returns an info about the file. kFSCatInfoCreateDate is a flag that notifies you're interested only in the creation date. You can combine different flags to obtain information about the file, which returns in catalogInfo object. Since you're interested only in the creation time, you can then access it via catalogInfo.createDate field. It's saved as UTCTime object. If you want to convert it to readable format, you first need to convert it to absolute time (using UCConvertUTCDateTimeToCFAbsoluteTime), and then to CFGregorianDate by using CFAbsoluteTimeGetGregorianDate.
BTW, developer.apple.com is an excellent source of information, you can read about all these methods there.
![]() |
Similar Threads
- Output a file's type and created date (Java)
- File Creation Dates: Recoverable? (Windows Vista and Windows 7)
- Open In New Window Php (PHP)
- reading of file date (Java)
- "Cannot delete file: Cannot read from the source file or disk." (Windows NT / 2000 / XP)
- I've got Trojan.Holax... is this bad? (Viruses, Spyware and other Nasties)
- Browser redirect/about:blank/other problems... (Viruses, Spyware and other Nasties)
Other Threads in the C++ Forum
- Previous Thread: Palindrome re-visited
- Next Thread: opening 2 files...?
| Thread Tools | Search this Thread |
api array arrays beginner binary bitmap c++ c/c++ calculator char class classes code coding compile compiler console conversion convert count data database delete desktop developer directshow dll download dynamic encryption error file forms fstream function functions game generator getline givemetehcodez google graph gui homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux loop looping loops map math matrix memory news node number output parameter pointer problem program programming project proxy python random read recursion recursive return string strings struct temperature template templates test text text-file tree unix url variable vector video visualstudio win32 windows winsock word wordfrequency wxwidgets





