• 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
Re: Um... How do you rename a file?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Um... How do you rename a file?


  • Subject: Re: Um... How do you rename a file?
  • From: Alastair Houghton <email@hidden>
  • Date: Fri, 26 Mar 2004 11:20:03 +0000

On 26 Mar 2004, at 09:17, p3consulting wrote:

> A latest small point:
> case-sensitivity of the target file system may influence the success or
> failure of a rename operation according to
> the system call used by the application:
> Finder (Carbon application) is successfull at renaming a file to
> another case spelling: eg "foo" to "Foo"
> where ProjectBuilder and Xcode (Cocoa application) both fail to.
>
> In consequence, moving files from a case-sensitive file system to a
> non-case sensitve one may turn out to be a tricky operation:
> the set of files ("foo", "Foo") will generate the set of results
> ("foo", failure) if movePath:toPath is used.
>
> For that particular aspect movePath:toPath is NOT equivalent to mv.

I don't know about you, but I consider that to be a bug.

A workaround might be to use rename() for simple renames and only
resort to NSFileManager for actual move operations... something like
this:

if (rename ([oldName fileSystemRepresentation],
[newName fileSystemRepresentation]) < 0) {
if (errno == EXDEV) {
if (![[NSFileManager defaultManager] movePath:oldName
toPath:newName
handler:nil]) {
/* Failure */
}
else {
/* Failure */
}
}

Kind regards,

Alastair.

--
http://www.alastairs-place.net

[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
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: Um... How do you rename a file?
      • From: p3consulting <email@hidden>
References: 
 >Re: Um... How do you rename a file? (From: Ken Tozier <email@hidden>)
 >Re: Um... How do you rename a file? (From: Alastair Houghton <email@hidden>)
 >Re: Um... How do you rename a file? (From: p3consulting <email@hidden>)

  • Prev by Date: Re: NSValueTransformer used with table colulms
  • Next by Date: accessing an Array Controller, Doc based app.
  • Previous by thread: Re: Um... How do you rename a file?
  • Next by thread: Re: Um... How do you rename a file?
  • Index(es):
    • Date
    • Thread