rv = file->GetLeafName(leafNameBuf);
rv = file->GetNativeLeafName(leafNameBuf);
nsresult MakeUnique(nsILocalFile* file){    PRBool flagExists;    nsresult rv = file->Exists(&flagExists);    if (NS_FAILED(rv)) return rv;    if (!flagExists) return NS_ERROR_FAILURE;    nsCAutoString leafNameBuf;    rv = file->GetLeafName(leafNameBuf);    if (NS_FAILED(rv)) return rv;    // XXX this code should use iterators    char *leafName = (char *) leafNameBuf.get();    char* lastDot = strrchr(leafName, '.');    char* suffix = "";    if (lastDot)    {        suffix = nsCRT::strdup(lastDot); // include '.'        *lastDot = '\0'; // strip suffix and dot.    }    // 27 should work on Macintosh, Unix, and Win32.    const int maxRootLength = 27 - strlen(suffix) - 1;    if ((int)strlen(leafName) > (int)maxRootLength)        leafName[maxRootLength] = '\0';    for (short indx = 1; indx < 1000 && flagExists; indx++)    {        // start with "Picture-1.jpg" after "Picture.jpg" exists        char newName[32];        sprintf(newName, "%s-%d%s", leafName, indx, suffix);        file->SetLeafName(nsDependentCString(newName));        rv = file->Exists(&flagExists);        if (NS_FAILED(rv)) return rv;    }    return NS_OK;}