• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
copyPath command doesn't copy as the Finder. Help!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

copyPath command doesn't copy as the Finder. Help!


  • Subject: copyPath command doesn't copy as the Finder. Help!
  • From: Lorenzo Puleo <email@hidden>
  • Date: Fri, 05 Apr 2002 00:02:46 +0200

Hi,
I can't copy a file to a destination file just as the Finder uses to do.

-----------------
If I use the API:
[[NSFileManager defaultManager] copyPath:source toPath:dest handler:nil];
the source file is really copied to the dest, but, it doesn't have the same
creation and modification dates, nor attributes.

-----------------
Well, I add the commands:
sourceAttribute = [[NSFileManager defaultManager]
fileAttributesAtPath:source traverseLink:NO];

[[NSFileManager defaultManager] changeFileAttributes:sourceAttribute
atPath:dest];
The modification date is correct and the attributes too, but the creation
date is not correct; it is the creation date of the copied file (today), and
I want the same creation date of the source file, of course;

-----------------
Well, I made a C++ routine which copies the creation date and more, so I can
even don't use the command "changeFileAttributes" above:
- (BOOL)SetCatInfo:(NSString*)sourceItem toDest:(NSString*)destItem
{
int err;
UInt8 *path;
FSRef sourceRef, destRef;
Boolean isFSDirectory;
FSCatalogInfo theInfo;

path = (UInt8*)[sourceItem UTF8String];
err = FSPathMakeRef(path, &sourceRef, &isFSDirectory);
if(err) return NO;
err = FSGetCatalogInfo(&sourceRef, kFSCatInfoSettableInfo, &theInfo,
nil, nil, nil);
if(err) return NO;

path = (UInt8*)[destItem UTF8String];
err = FSPathMakeRef(path, &destRef, &isFSDirectory);
if(err) return NO;

err = FSSetCatalogInfo(&destRef, kFSCatInfoSettableInfo, &theInfo);
if(err) return NO;

return YES;
}
This fixes the creationDate of the destination file, even if I think for
large amount of files this could be too slow.


My question is:
When the owner has the permission "Read Only" for the source file,
I can copy well the source file to the dest file, but then I can't modify
the creation date of the destination file.

Is anyone that would please show me the solution to this trouble?
Did I loose something on the way?
Is a way to override all the permissions when programming?


Thank you and Regards
--
Lorenzo Puleo
mailto:email@hidden
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: copyPath command doesn't copy as the Finder. Help!
      • From: Ondra Cada <email@hidden>
  • Prev by Date: Re: Toplevel Objects in NIB files
  • Next by Date: Re: copyPath command doesn't copy as the Finder. Help!
  • Previous by thread: OpenGL
  • Next by thread: Re: copyPath command doesn't copy as the Finder. Help!
  • Index(es):
    • Date
    • Thread