if (rv == GNOME_VFS_OK && info.mime_type && (strcmp(info.mime_type, "x-directory/normal") == 0))
if (rv == GNOME_VFS_OK && info.type == GNOME_VFS_FILE_TYPE_DIRECTORY)
nsGnomeVFSInputStream::DoOpen(){  GnomeVFSResult rv;  NS_ASSERTION(mHandle == nsnull, "already open");  // Push a callback handler on the stack for this thread, so we can intercept  // authentication requests from GnomeVFS.  We'll use the channel to get a  // nsIAuthPrompt instance.  gnome_vfs_module_callback_push(GNOME_VFS_MODULE_CALLBACK_AUTHENTICATION,                                 AuthCallback, mChannel, NULL);  // Query the mime type first (this could return NULL).   //  // XXX We need to do this up-front in order to determine how to open the URI.  //     Unfortunately, the error code GNOME_VFS_ERROR_IS_DIRECTORY is not  //     always returned by gnome_vfs_open when we pass it a URI to a directory!  //     Otherwise, we could have used that as a way to failover to opening the  //     URI as a directory.  Also, it would have been ideal if  //     gnome_vfs_get_file_info_from_handle were actually implemented by the  //     smb:// module, since that would have allowed us to potentially save a  //     round trip to the server to discover the mime type of the document in  //     the case where gnome_vfs_open would have been used.  (Oh well!  /me  //     throws hands up in the air and moves on...)  GnomeVFSFileInfo info = {0};  rv = gnome_vfs_get_file_info(mSpec.get(), &info, GNOME_VFS_FILE_INFO_DEFAULT);  if (rv == GNOME_VFS_OK && info.mime_type &&        (strcmp(info.mime_type, "x-directory/normal") == 0))  {    rv = gnome_vfs_directory_list_load(&mDirList, mSpec.get(),                                       GNOME_VFS_FILE_INFO_DEFAULT);    LOG(("gnomevfs: gnome_vfs_directory_list_load returned %d (%s) [spec=\"%s\"]\n",        rv, gnome_vfs_result_to_string(rv), mSpec.get()));  }  else  {    rv = gnome_vfs_open(&mHandle, mSpec.get(), GNOME_VFS_OPEN_READ);    LOG(("gnomevfs: gnome_vfs_open returned %d (%s) [spec=\"%s\"]\n",        rv, gnome_vfs_result_to_string(rv), mSpec.get()));  }  gnome_vfs_module_callback_pop(GNOME_VFS_MODULE_CALLBACK_AUTHENTICATION);  if (rv == GNOME_VFS_OK)  {    if (mHandle)    {      // Here we set the content type of the channel to the value of the mime      // type determined by GnomeVFS.  However, if GnomeVFS is telling us that      // the document is binary, we'll ignore that and keep the channel's      // content type unspecified.  That will enable our content type sniffing      // algorithms.  This should provide more consistent mime type handling.      if (info.mime_type && (strcmp(info.mime_type, APPLICATION_OCTET_STREAM) != 0))        SetContentTypeOfChannel(info.mime_type);      // XXX truncates size from 64-bit to 32-bit      mBytesRemaining = (PRUint32) info.size;      // Update the content length attribute on the channel.  We do this      // synchronously without proxying.  This hack is not as bad as it looks!      if (mBytesRemaining != PR_UINT32_MAX)        mChannel->SetContentLength(mBytesRemaining);    }    else    {      mDirOpen = PR_TRUE;      // Sort mDirList      mDirList = g_list_sort(mDirList, FileInfoComparator);      mDirListPtr = mDirList;      // Write base URL (make sure it ends with a '/')      mDirBuf.Append(NS_LITERAL_CSTRING("300: ") + mSpec);      if (mSpec.Last() != '/')        mDirBuf.Append('/');      mDirBuf.Append('\n');      // Write column names      mDirBuf.Append("200: filename content-length last-modified file-type\n");      // Write charset (assume UTF-8)      // XXX is this correct?      mDirBuf.Append("301: UTF-8\n");      SetContentTypeOfChannel(APPLICATION_HTTP_INDEX_FORMAT);    }  }  gnome_vfs_file_info_clear(&info);  return rv;}