Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modernize -creationDate for iOS #177

Merged
merged 1 commit into from
Nov 26, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 0 additions & 35 deletions Lumberjack/DDFileLogger.m
Original file line number Diff line number Diff line change
Expand Up @@ -1008,42 +1008,7 @@ - (NSDate *)creationDate
{
if (creationDate == nil)
{

#if TARGET_OS_IPHONE

const char *path = [filePath UTF8String];

struct attrlist attrList;
memset(&attrList, 0, sizeof(attrList));
attrList.bitmapcount = ATTR_BIT_MAP_COUNT;
attrList.commonattr = ATTR_CMN_CRTIME;

struct {
u_int32_t attrBufferSizeInBytes;
struct timespec crtime;
} attrBuffer;

int result = getattrlist(path, &attrList, &attrBuffer, sizeof(attrBuffer), 0);
if (result == 0)
{
double seconds = (double)(attrBuffer.crtime.tv_sec);
double nanos = (double)(attrBuffer.crtime.tv_nsec);

NSTimeInterval ti = seconds + (nanos / 1000000000.0);

creationDate = [NSDate dateWithTimeIntervalSince1970:ti];
}
else
{
NSLogError(@"DDLogFileInfo: creationDate(%@): getattrlist result = %i", self.fileName, result);
}

#else

creationDate = [[self fileAttributes] objectForKey:NSFileCreationDate];

#endif

}
return creationDate;
}
Expand Down