mDirBuf += NS_LITERAL_CSTRING("FILE ");
mDirBuf.AppendLiteral("FILE ");
nsGnomeVFSInputStream::DoRead(char *aBuf, PRUint32 aCount, PRUint32 *aCountRead){  GnomeVFSResult rv;  if (mHandle)  {    GnomeVFSFileSize bytesRead;    rv = gnome_vfs_read(mHandle, aBuf, aCount, &bytesRead);    if (rv == GNOME_VFS_OK)    {      *aCountRead = (PRUint32) bytesRead;      mBytesRemaining -= *aCountRead;    }  }  else if (mDirOpen)  {    rv = GNOME_VFS_OK;    while (aCount && rv != GNOME_VFS_ERROR_EOF)    {      // Copy data out of our buffer      PRUint32 bufLen = mDirBuf.Length() - mDirBufCursor;      if (bufLen)      {        PRUint32 n = PR_MIN(bufLen, aCount);        memcpy(aBuf, mDirBuf.get() + mDirBufCursor, n);        *aCountRead += n;        aBuf += n;        aCount -= n;        mDirBufCursor += n;      }      if (!mDirListPtr)    // Are we at the end of the directory list?      {        rv = GNOME_VFS_ERROR_EOF;      }      else if (aCount)     // Do we need more data?      {        GnomeVFSFileInfo *info = (GnomeVFSFileInfo *) mDirListPtr->data;        // Prune '.' and '..' from directory listing.        if (info->name[0] == '.' &&               (info->name[1] == '\0' ||                   (info->name[1] == '.' && info->name[2] == '\0')))        {          mDirListPtr = mDirListPtr->next;          continue;        }        mDirBuf.Assign("201: ");        // The "filename" field        char *escName = nsEscape(info->name, url_Path);        if (escName)        {          mDirBuf.Append(escName);          mDirBuf.Append(' ');          nsMemory::Free(escName);        }        // The "content-length" field        // XXX truncates size from 64-bit to 32-bit        mDirBuf.AppendInt(PRInt32(info->size));        mDirBuf.Append(' ');        // The "last-modified" field        //         // NSPR promises: PRTime is compatible with time_t        // we just need to convert from seconds to microseconds        PRExplodedTime tm;        PRTime pt = ((PRTime) info->mtime) * 1000000;        PR_ExplodeTime(pt, PR_GMTParameters, &tm);        {          char buf[64];          PR_FormatTimeUSEnglish(buf, sizeof(buf),              "%a,%%20%d%%20%b%%20%Y%%20%H:%M:%S%%20GMT ", &tm);          mDirBuf.Append(buf);        }        // The "file-type" field        switch (info->type)        {          case GNOME_VFS_FILE_TYPE_REGULAR:            mDirBuf += NS_LITERAL_CSTRING("FILE ");            break;          case GNOME_VFS_FILE_TYPE_DIRECTORY:            mDirBuf += NS_LITERAL_CSTRING("DIRECTORY ");            break;          case GNOME_VFS_FILE_TYPE_SYMBOLIC_LINK:            mDirBuf += NS_LITERAL_CSTRING("SYMBOLIC-LINK ");            break;          default:            break;        }        mDirBuf.Append('\n');        mDirBufCursor = 0;        mDirListPtr = mDirListPtr->next;      }    }  }  else  {    NS_NOTREACHED("reading from what?");    rv = GNOME_VFS_ERROR_GENERIC;  }  return rv;}