Skip navigation.
 
mlRe: Possible Bug in NSFileManager -moveItemAtPath:toPath:error:
FROM : Jens Alfke
DATE : Sat May 31 19:17:46 2008

On 31 May '08, at 9:27 AM, Jonathan Dann wrote:

> Just a quick one.  I would expect renaming a file named HELLO.TXT to 
> hello.txt (or another variant where the case of a few letters 
> change) with -moveItemAtPath:toPath:error: to be allowed. As it is 
> not (it generates an NSFileWriteUnknownError) is this a bug or just 
> me?


That ought to work, even on HFS+. (It's not a no-op, because HFS+ 
preserves the case of filenames, so getting the directory contents 
will return the name in its new case.)

> If not, is there are more appropriate API for renaming files?


Try using the system call "rename". (Use "man 2 rename" to see the 
documentation.)
Call -fileSystemRepresentation on your path strings to convert them to 
appropriate C strings.

—Jens

Related mailsAuthorDate
mlPossible Bug in NSFileManager -moveItemAtPath:toPath:error: Jonathan Dann May 31, 18:27
mlRe: Possible Bug in NSFileManager -moveItemAtPath:toPath:error: Torsten Curdt May 31, 18:37
mlRe: Possible Bug in NSFileManager -moveItemAtPath:toPath:error: Jens Alfke May 31, 19:17
mlRe: Possible Bug in NSFileManager -moveItemAtPath:toPath:error: Jonathan Dann May 31, 23:33
mlRe: Possible Bug in NSFileManager -moveItemAtPath:toPath:error: Jonathan Dann May 31, 23:35
mlRe: Possible Bug in NSFileManager -moveItemAtPath:toPath:error: stephen joseph but… May 31, 23:51
mlRe: Possible Bug in NSFileManager -moveItemAtPath:toPath:error: Jonathan Dann Jun 1, 00:35