mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 00:41:02 +00:00
Merge branch 'master' of github.com:gnustep/libs-base
This commit is contained in:
commit
3ff8291da6
2 changed files with 38 additions and 12 deletions
|
@ -613,7 +613,7 @@ static NSStringEncoding defaultEncoding;
|
|||
ub[1].tv_sec = truncl(ti);
|
||||
ub[1].tv_nsec = (ti - (double)ub[1].tv_sec) * 1.0e6;
|
||||
|
||||
ok = (utimensat(0, lpath, ub, 0) == 0);
|
||||
ok = (utimensat(AT_FDCWD, lpath, ub, 0) == 0);
|
||||
#elif defined(_POSIX_VERSION)
|
||||
struct _UTIMB ub;
|
||||
ub.actime = sb.st_atime;
|
||||
|
@ -662,7 +662,7 @@ static NSStringEncoding defaultEncoding;
|
|||
ub[1].tv_sec = truncl(ti);
|
||||
ub[1].tv_nsec = (ti - (double)ub[1].tv_sec) * 1.0e6;
|
||||
|
||||
ok = (utimensat(0, lpath, ub, 0) == 0);
|
||||
ok = (utimensat(AT_FDCWD, lpath, ub, 0) == 0);
|
||||
#elif defined(_WIN32) || defined(_POSIX_VERSION)
|
||||
struct _UTIMB ub;
|
||||
ub.actime = sb.st_atime;
|
||||
|
@ -1282,8 +1282,8 @@ static NSStringEncoding defaultEncoding;
|
|||
|
||||
/* Don't attempt to retain ownership of copy ... we want the copy
|
||||
* to be owned by the current user.
|
||||
* Also, the new copy should not have the creation/modification
|
||||
* date of the original.
|
||||
* However, the new copy should have the creation/modification date
|
||||
* of the original (unlike Posix semantics).
|
||||
*/
|
||||
attrs = AUTORELEASE([attrs mutableCopy]);
|
||||
[(NSMutableDictionary*)attrs removeObjectForKey: NSFileOwnerAccountID];
|
||||
|
@ -1292,9 +1292,6 @@ static NSStringEncoding defaultEncoding;
|
|||
[(NSMutableDictionary*)attrs setObject: NSUserName()
|
||||
forKey: NSFileOwnerAccountName];
|
||||
|
||||
[(NSMutableDictionary*)attrs removeObjectForKey: NSFileCreationDate];
|
||||
[(NSMutableDictionary*)attrs removeObjectForKey: NSFileModificationDate];
|
||||
|
||||
if ([fileType isEqualToString: NSFileTypeDirectory] == YES)
|
||||
{
|
||||
|
||||
|
|
|
@ -6,8 +6,15 @@
|
|||
#import <Foundation/NSProcessInfo.h>
|
||||
#import <Foundation/NSPathUtilities.h>
|
||||
#import <Foundation/NSError.h>
|
||||
#import <Foundation/NSThread.h>
|
||||
#import <Foundation/NSURL.h>
|
||||
|
||||
#ifdef EQ
|
||||
#undef EQ
|
||||
#endif
|
||||
#define EPSILON (FLT_EPSILON*100)
|
||||
#define EQ(x,y) ((x >= y - EPSILON) && (x <= y + EPSILON))
|
||||
|
||||
@interface MyHandler : NSObject
|
||||
{
|
||||
@public
|
||||
|
@ -140,7 +147,7 @@ int main()
|
|||
str2 = [[NSString alloc] initWithData: dat1 encoding: 1];
|
||||
PASS([str1 isEqualToString: str2], "NSFileManager file contents match");
|
||||
}
|
||||
|
||||
[NSThread sleepForTimeInterval: 1.0]; // So date of file is clearly in past
|
||||
[handler reset];
|
||||
PASS([mgr copyPath: @"NSFMFile"
|
||||
toPath: @"NSFMCopy"
|
||||
|
@ -154,10 +161,32 @@ int main()
|
|||
}
|
||||
NSDictionary *oa = [mgr fileAttributesAtPath: @"NSFMFile" traverseLink: NO];
|
||||
NSDictionary *na = [mgr fileAttributesAtPath: @"NSFMCopy" traverseLink: NO];
|
||||
PASS(![[oa fileCreationDate] isEqual: [na fileCreationDate]],
|
||||
"copy creation date differs from that of original")
|
||||
PASS(![[oa fileModificationDate] isEqual: [na fileModificationDate]],
|
||||
"copy modification date differs from that of original")
|
||||
NSTimeInterval ot, nt;
|
||||
ot = [[oa fileCreationDate] timeIntervalSinceReferenceDate];
|
||||
nt = [[na fileCreationDate] timeIntervalSinceReferenceDate];
|
||||
PASS(EQ(ot, nt), "copy creation date equals original")
|
||||
ot = [[oa fileModificationDate] timeIntervalSinceReferenceDate];
|
||||
nt = [[na fileModificationDate] timeIntervalSinceReferenceDate];
|
||||
PASS(EQ(ot, nt), "copy modification date equals original")
|
||||
{
|
||||
NSData *dat1 = [mgr contentsAtPath: @"NSFMFile"];
|
||||
NSError *err;
|
||||
BOOL ok;
|
||||
|
||||
ok = [dat1 writeToFile: @"NSFMFile"
|
||||
options: NSDataWritingAtomic
|
||||
error: &err];
|
||||
PASS(ok, "can rewrite data file")
|
||||
if (NO == ok) NSLog(@"Problem: %@ with %@", err, dat1);
|
||||
na = [mgr fileAttributesAtPath: @"NSFMFile" traverseLink: NO];
|
||||
NSLog(@"%@\n%@", oa, na);
|
||||
ot = [[oa fileCreationDate] timeIntervalSinceReferenceDate];
|
||||
nt = [[na fileCreationDate] timeIntervalSinceReferenceDate];
|
||||
PASS(!EQ(ot, nt), "rewritten file creation date changed")
|
||||
ot = [[oa fileModificationDate] timeIntervalSinceReferenceDate];
|
||||
nt = [[na fileModificationDate] timeIntervalSinceReferenceDate];
|
||||
PASS(!EQ(ot, nt), "rewritten file modification date changed")
|
||||
}
|
||||
|
||||
PASS([mgr movePath: @"NSFMFile"
|
||||
toPath: @"NSFMMove"
|
||||
|
|
Loading…
Reference in a new issue