From 55649b036cea35b8b91a4d929debafa934eeeb99 Mon Sep 17 00:00:00 2001 From: "sdagley%netscape.com" Date: Fri, 30 Jul 1999 00:37:58 +0000 Subject: [PATCH] Temp hack for the Mac to address error opening files that aren't properly un-escaped (%20 still in the path instead of spaces for example). We still fail to open the file but now there's an error message to go along with the failure. Note that this will require Macsbug to be installed or a Mac hitting this error will crash. Since we were already telling people that they needed Macsbug installed to run the developmental builds I don't see a problem with this. --- netwerk/protocol/file/src/nsFileChannel.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/netwerk/protocol/file/src/nsFileChannel.cpp b/netwerk/protocol/file/src/nsFileChannel.cpp index 11613698b808..232c70cbd766 100644 --- a/netwerk/protocol/file/src/nsFileChannel.cpp +++ b/netwerk/protocol/file/src/nsFileChannel.cpp @@ -107,6 +107,23 @@ nsFileChannel::Init(nsFileProtocolHandler* handler, } else { nsFilePath filePath(fileString); mSpec = filePath; + + // Don't assume we actually created a good file spec + FSSpec theSpec = mSpec.GetFSSpec(); + if (!theSpec.name[0]) + { + NS_ERROR("failed to create a file spec"); + + // Some temp debugstr hackery so optimized builds display an error message + // !!!!!REMOVE THIS ONCE WE GET THE FILE NAME UN-ESCAPING CODE IN + DebugStr("\p\rFailed to create a file spec for the specified file.\r"\ + "This is usually due to having a space somewhere in the path\r"\ + "to the application (say if your hard drive is named Macintosh HD\r"\ + "or you're trying to run from the Desktop Folder). We'll fix this soon."); + + // Since we didn't actually create the file spec we return an error + return NS_ERROR_MALFORMED_URI; + } } #else nsFilePath filePath(fileString);