I use NSFileManager setAttribute to set the modification date for files.
Everything works fine but when I do that on some SMB disks sometimes in a non deterministic manner the date isn't changed.
The code shown below for simplicity doesn't check error but in real code all API calls return success so it's impossible to understand what hell doesn't work
What I do is
The code I use is
NSString* srcPath = @"/Volumes/smbtest/folder-1/ATKXP.INF";
NSString* destPath = @"/Volumes/smbtest/folder-2/ATKXP.INF";
NSDictionary* srcAttrs = [[NSFileManager defaultManager] attributesOfItemAtPath:srcPath
error:nil];
[[NSFileManager defaultManager] copyItemAtPath:srcPath
toPath:destPath
error:nil];
NSDictionary* dateAttrs = [NSDictionary dictionaryWithObjectsAndKeys:
srcAttrs.fileCreationDate, NSFileCreationDate,
srcAttrs.fileModificationDate, NSFileModificationDate,
nil];
[[NSFileManager defaultManager] setAttributes:dateAttrs
ofItemAtPath:destPath
error:nil];
Everything work always correctly on local HFS disks
Doesn't look like there's an error. So the problem seems like it's in either the file system driver or on the server side. I don't know if you're in a position to look at logs on the server. In any case, it seems like it's beyond your control. Either live with the behavior or try putting a check for the attribute value after trying to set it and, if it isn't what you tried to set it to, try again (up to some retry limit).