NSData Silently Failing to Write on Leopard

  • So I'm having some weird problems with an NSData object writing to a
    file on Leopard.  Here's the relevant three lines of code:

    > NSError *fileWriteError = nil;
    > NSLog(@"%@",fullWritePath);
    > BOOL wrote = [[theImage TIFFRepresentation] writeToFile:
    > fullWritePath options:1 error:&fileWriteError];
    > NSLog(@"%@",fileWriteError);
    > if (! wrote) NSLog(@"write failed");

    The variable "fullWritePath" is a path to a directory I know exists
    and one to which I can write: /Users/username/Desktop/testdir/

    On Tiger, the path gets displayed, the error that's logged is
    "(null)", and no "write failed" message ever comes up.  However, on
    Leopard, the path gets displayed, the error is *still* "(null)", but
    "write failed" comes up for each image that I am trying to write to
    disk.

    What would cause this code to work fine on Tiger but not on Leopard,
    and to cause it to fail but not generate any error message?  Any help
    would be much appreciated.

    -- Simone
  • Hi Simone,

    On 2007-12-09, at 19:15, Simone Manganelli wrote:

    > The variable "fullWritePath" is a path to a directory I know exists
    > and one to which I can write: /Users/username/Desktop/testdir/

    Just to clarify, fullWritePath is the path to that directory, or a
    path to a file in that directory?

    Jonathon Mah
    <me...>
  • Err.. sorry, that's *not* a path to a directory, but it is indeed a
    path to a *file* in that directory.  I meant that the parent directory
    of the path fullWritePath exists and is writable.

    -- Simone

    Il giorno 2007-12-09, alle ore 01:12, Jonathon Mah ha scritto:

    > Hi Simone,
    >
    > On 2007-12-09, at 19:15, Simone Manganelli wrote:
    >
    >> The variable "fullWritePath" is a path to a directory I know exists
    >> and one to which I can write: /Users/username/Desktop/testdir/
    >
    >
    > Just to clarify, fullWritePath is the path to that directory, or a
    > path to a file in that directory?
    >
    >
    >
    > Jonathon Mah
    > <me...>
    >
    >
  • > Il giorno 2007-12-09, alle ore 01:12, Jonathon Mah ha scritto:
    >
    >> Hi Simone,
    >>
    >> On 2007-12-09, at 19:15, Simone Manganelli wrote:
    >>
    >>> The variable "fullWritePath" is a path to a directory I know
    >>> exists and one to which I can write: /Users/username/Desktop/
    >>> testdir/
    >>
    >>
    >> Just to clarify, fullWritePath is the path to that directory, or a
    >> path to a file in that directory?
    >>

    I ran into something like this earlier in the week. Turns out I had a
    file descriptor leak (wasn't closing temp files) and I had hit the
    limit for open file descriptors (some number above 243). I figured
    this out by running fs_usage on my pid and looking at the errno on the
    open that failed which was 24 in my case.

    Dave
previous month december 2007 next month
MTWTFSS
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31            
Go to today