From f6d3d22234f796338dac471d666598e2ced68220 Mon Sep 17 00:00:00 2001 From: "alecf%netscape.com" Date: Wed, 9 Jan 2002 20:03:46 +0000 Subject: [PATCH] final fix for bug 100212 - removal final dependency on necko from xpcom by removing nsIFile.URL r=dougt, sr=darin Yay! git-svn-id: svn://10.0.0.236/trunk@111722 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/xpcom/io/Makefile.in | 1 - mozilla/xpcom/io/makefile.win | 1 - mozilla/xpcom/io/nsIFile.idl | 5 -- mozilla/xpcom/io/nsLocalFileCommon.cpp | 64 +-------------- mozilla/xpcom/io/nsLocalFileMac.cpp | 105 ------------------------ mozilla/xpcom/io/nsLocalFileMac.h | 3 - mozilla/xpcom/io/nsLocalFileOS2.cpp | 108 ------------------------- mozilla/xpcom/io/nsLocalFileOS2.h | 2 - mozilla/xpcom/io/nsLocalFileUnix.cpp | 75 ----------------- mozilla/xpcom/io/nsLocalFileUnix.h | 2 - mozilla/xpcom/io/nsLocalFileWin.cpp | 105 ------------------------ mozilla/xpcom/io/nsLocalFileWin.h | 2 - 12 files changed, 1 insertion(+), 472 deletions(-) diff --git a/mozilla/xpcom/io/Makefile.in b/mozilla/xpcom/io/Makefile.in index 7bdb5d20870..1540fc58486 100644 --- a/mozilla/xpcom/io/Makefile.in +++ b/mozilla/xpcom/io/Makefile.in @@ -31,7 +31,6 @@ XPIDL_MODULE = xpcom_io LIBRARY_NAME = xpcomio_s REQUIRES = uconv \ string \ - necko \ $(NULL) CPPSRCS = \ diff --git a/mozilla/xpcom/io/makefile.win b/mozilla/xpcom/io/makefile.win index c775a114ce2..91214fe1ab1 100644 --- a/mozilla/xpcom/io/makefile.win +++ b/mozilla/xpcom/io/makefile.win @@ -23,7 +23,6 @@ DEPTH=..\.. MODULE = xpcom REQUIRES = uconv \ string \ - necko \ $(NULL) ################################################################################ diff --git a/mozilla/xpcom/io/nsIFile.idl b/mozilla/xpcom/io/nsIFile.idl index b314b52b5f2..02afedbbe5a 100644 --- a/mozilla/xpcom/io/nsIFile.idl +++ b/mozilla/xpcom/io/nsIFile.idl @@ -297,11 +297,6 @@ interface nsIFile : nsISupports */ readonly attribute nsISimpleEnumerator directoryEntries; - /** - * Accesses the file: url for the nsIFile. Setting this causes the path - * to be reset. - */ - attribute string URL; }; %{C++ diff --git a/mozilla/xpcom/io/nsLocalFileCommon.cpp b/mozilla/xpcom/io/nsLocalFileCommon.cpp index 33692c9bce1..24f057f8b9e 100644 --- a/mozilla/xpcom/io/nsLocalFileCommon.cpp +++ b/mozilla/xpcom/io/nsLocalFileCommon.cpp @@ -35,11 +35,6 @@ * * ***** END LICENSE BLOCK ***** */ #include "nsIServiceManager.h" -#ifndef XPCOM_STANDALONE -#include "nsIURLParser.h" -#include "nsNetCID.h" -#endif /* XPCOM_STANDALONE */ - #include "nsLocalFile.h" // includes platform-specific headers #include "nsLocalFileUnicode.h" @@ -48,9 +43,6 @@ #include "nsCOMPtr.h" #include "nsXPIDLString.h" -#ifndef XPCOM_STANDALONE -static NS_DEFINE_CID(kURLParserCID, NS_NOAUTHURLPARSER_CID); -#endif void NS_StartupLocalFile() @@ -122,61 +114,7 @@ nsLocalFile::CreateUnique(PRUint32 type, PRUint32 attributes) return NS_ERROR_FILE_TOO_BIG; } -nsresult nsLocalFile::ParseURL(const char* inURL, char **outHost, char **outDirectory, - char **outFileBaseName, char **outFileExtension) -{ - nsresult rv = NS_ERROR_NOT_IMPLEMENTED; + -#ifndef XPCOM_STANDALONE - NS_ENSURE_ARG(inURL); - NS_ENSURE_ARG_POINTER(outHost); - *outHost = nsnull; - NS_ENSURE_ARG_POINTER(outDirectory); - *outDirectory = nsnull; - NS_ENSURE_ARG_POINTER(outFileBaseName); - *outFileBaseName = nsnull; - NS_ENSURE_ARG_POINTER(outFileExtension); - *outFileExtension = nsnull; - nsCOMPtr parser(do_GetService(kURLParserCID, &rv)); - if (NS_FAILED(rv)) return rv; - PRUint32 pathPos, filepathPos, directoryPos, basenamePos, extensionPos; - PRInt32 pathLen, filepathLen, directoryLen, basenameLen, extensionLen; - - // invoke the parser to extract the URL path - rv = parser->ParseURL(inURL, -1, - nsnull, nsnull, // dont care about scheme - nsnull, nsnull, // dont care about authority - &pathPos, &pathLen); - if (NS_FAILED(rv)) return rv; - - // invoke the parser to extract filepath from the path - rv = parser->ParsePath(inURL + pathPos, pathLen, - &filepathPos, &filepathLen, - nsnull, nsnull, // dont care about param - nsnull, nsnull, // dont care about query - nsnull, nsnull); // dont care about ref - if (NS_FAILED(rv)) return rv; - - filepathPos += pathPos; - - // invoke the parser to extract the directory and filename from filepath - rv = parser->ParseFilePath(inURL + filepathPos, filepathLen, - &directoryPos, &directoryLen, - &basenamePos, &basenameLen, - &extensionPos, &extensionLen); - if (NS_FAILED(rv)) return rv; - - if (directoryLen > 0) - *outDirectory = PL_strndup(inURL + filepathPos + directoryPos, directoryLen); - if (basenameLen > 0) - *outFileBaseName = PL_strndup(inURL + filepathPos + basenamePos, basenameLen); - if (extensionLen > 0) - *outFileExtension = PL_strndup(inURL + filepathPos + extensionPos, extensionLen); - // since we are using a no-auth url parser, there will never be a host - -#endif /* XPCOM_STANDALONE */ - - return NS_OK; -} diff --git a/mozilla/xpcom/io/nsLocalFileMac.cpp b/mozilla/xpcom/io/nsLocalFileMac.cpp index aeffe60141e..f8a7f4c819a 100644 --- a/mozilla/xpcom/io/nsLocalFileMac.cpp +++ b/mozilla/xpcom/io/nsLocalFileMac.cpp @@ -434,19 +434,6 @@ static nsresult ConvertMillisecondsToMacTime(PRInt64 aTime, PRUint32 *aOutMacTim return NS_OK; } -static void SwapSlashColon(char * s) -{ - while (*s) - { - if (*s == '/') - *s++ = ':'; - else if (*s == ':') - *s++ = '/'; - else - *s++; - } -} - static void myPLstrcpy(Str255 dst, const char* src) { int srcLength = strlen(src); @@ -2251,98 +2238,6 @@ nsLocalFile::GetDirectoryEntries(nsISimpleEnumerator * *entries) return NS_OK; } -NS_IMETHODIMP nsLocalFile::GetURL(char * *aURL) -{ - NS_ENSURE_ARG_POINTER(aURL); - *aURL = nsnull; - - nsresult rv; - char* ePath = nsnull; - nsCAutoString escPath; - - rv = GetPath(&ePath); - if (NS_SUCCEEDED(rv)) { - - SwapSlashColon(ePath); - - // Escape the path with the directory mask - rv = nsStdEscape(ePath, esc_Directory+esc_Forced, escPath); - if (NS_SUCCEEDED(rv)) { - if (escPath[escPath.Length() - 1] != '/') { - PRBool dir; - rv = IsDirectory(&dir); - NS_ASSERTION(NS_SUCCEEDED(rv), "Cannot tell if this is a directory"); - if (NS_SUCCEEDED(rv) && dir) { - // make sure we have a trailing slash - escPath += "/"; - } - } - escPath.Insert("file:///", 0); - - *aURL = ToNewCString(escPath); - rv = *aURL ? NS_OK : NS_ERROR_OUT_OF_MEMORY; - } - } - CRTFREEIF(ePath); - return rv; -} - -NS_IMETHODIMP nsLocalFile::SetURL(const char * aURL) -{ - NS_ENSURE_ARG(aURL); - nsresult rv; - - nsXPIDLCString host, directory, fileBaseName, fileExtension; - - rv = ParseURL(aURL, getter_Copies(host), getter_Copies(directory), - getter_Copies(fileBaseName), getter_Copies(fileExtension)); - if (NS_FAILED(rv)) return rv; - - nsCAutoString path; - nsCAutoString component; - - if (host) - { - // We can end up with a host when given: file:// instead of file:/// - // Check to see if the host is a volume name - If so prepend it - Str255 volName; - FSSpec volSpec; - - myPLstrcpy(volName, host); - volName[++volName[0]] = ':'; - if (::FSMakeFSSpec(0, 0, volName, &volSpec) == noErr) - path += host; - } - if (directory) - { - nsStdEscape(directory, esc_Directory, component); - path += component; - SwapSlashColon((char*)path.get()); - } - if (fileBaseName) - { - nsStdEscape(fileBaseName, esc_FileBaseName, component); - path += component; - } - if (fileExtension) - { - nsStdEscape(fileExtension, esc_FileExtension, component); - path += '.'; - path += component; - } - - nsUnescape((char*)path.get()); - - // wack off leading :'s - if (path.CharAt(0) == ':') - path.Cut(0, 1); - - rv = InitWithPath(path.get()); - - return rv; - -} - NS_IMETHODIMP nsLocalFile::GetPersistentDescriptor(char * *aPersistentDescriptor) { diff --git a/mozilla/xpcom/io/nsLocalFileMac.h b/mozilla/xpcom/io/nsLocalFileMac.h index 1116ac92929..378bf3d6df0 100644 --- a/mozilla/xpcom/io/nsLocalFileMac.h +++ b/mozilla/xpcom/io/nsLocalFileMac.h @@ -59,9 +59,6 @@ public: // nsILocalFileMac interface NS_DECL_NSILOCALFILEMAC - static nsresult ParseURL(const char* inURL, char **outHost, char **outDirectory, - char **outFileBaseName, char **outFileExtension); - protected: void MakeDirty(); diff --git a/mozilla/xpcom/io/nsLocalFileOS2.cpp b/mozilla/xpcom/io/nsLocalFileOS2.cpp index 75bd6b8ee51..f5d19cd9229 100644 --- a/mozilla/xpcom/io/nsLocalFileOS2.cpp +++ b/mozilla/xpcom/io/nsLocalFileOS2.cpp @@ -2052,114 +2052,6 @@ nsLocalFile::GetDirectoryEntries(nsISimpleEnumerator * *entries) return NS_OK; } -NS_IMETHODIMP nsLocalFile::GetURL(char * *aURL) -{ - NS_ENSURE_ARG_POINTER(aURL); - *aURL = nsnull; - - nsresult rv; - char* ePath = nsnull; - nsCAutoString escPath; - - rv = GetPath(&ePath); - if (NS_SUCCEEDED(rv)) { - - // Replace \ with / to convert to an url - char* s = ePath; - while (*s) - { - // We need to call IsDBCSLeadByte because - // Japanese windows can have 0x5C in the sencond byte - // of a Japanese character, for example 0x8F 0x5C is - // one Japanese character -#ifdef XP_OS2 - if(::isleadbyte(*s) && *(s+1) != nsnull) -#else - if(::IsDBCSLeadByte(*s) && *(s+1) != nsnull) -#endif - { - s++; - } - else if (*s == '\\') { - *s = '/'; - } - s++; - } - - // Escape the path with the directory mask - rv = nsStdEscape(ePath, esc_Directory+esc_Forced, escPath); - if (NS_SUCCEEDED(rv)) { - escPath.Insert("file:///", 0); - - PRBool dir; - rv = IsDirectory(&dir); - NS_ASSERTION(NS_SUCCEEDED(rv), "Cannot tell if this is a directory"); - if (NS_SUCCEEDED(rv) && dir && escPath[escPath.Length() - 1] != '/') { - // make sure we have a trailing slash - escPath += "/"; - } - *aURL = ToNewCString(escPath); - rv = *aURL ? NS_OK : NS_ERROR_OUT_OF_MEMORY; - } - } - CRTFREEIF(ePath); - return rv; -} - -NS_IMETHODIMP nsLocalFile::SetURL(const char * aURL) -{ - NS_ENSURE_ARG(aURL); - nsresult rv; - - nsXPIDLCString host, directory, fileBaseName, fileExtension; - - rv = ParseURL(aURL, getter_Copies(host), getter_Copies(directory), - getter_Copies(fileBaseName), getter_Copies(fileExtension)); - if (NS_FAILED(rv)) return rv; - - nsCAutoString path; - nsCAutoString component; - - if (host) - { - // We can end up with a host when given: file://C|/ instead of file:/// - if (strlen((const char *)host) == 2 && ((const char *)host)[1] == '|') - { - path += host; - path.SetCharAt(':', 1); - } - } - if (directory) - { - nsStdEscape(directory, esc_Directory, component); - if (!host && component.Length() > 2 && component.CharAt(2) == '|') - component.SetCharAt(':', 2); - component.ReplaceChar('/', '\\'); - path += component; - } - if (fileBaseName) - { - nsStdEscape(fileBaseName, esc_FileBaseName, component); - path += component; - } - if (fileExtension) - { - nsStdEscape(fileExtension, esc_FileExtension, component); - path += '.'; - path += component; - } - - nsUnescape((char*)path.get()); - - // remove leading '\' - if (path.CharAt(0) == '\\') - path.Cut(0, 1); - - rv = InitWithPath(path.get()); - - return rv; -} - NS_IMETHODIMP nsLocalFile::GetPersistentDescriptor(char * *aPersistentDescriptor) { diff --git a/mozilla/xpcom/io/nsLocalFileOS2.h b/mozilla/xpcom/io/nsLocalFileOS2.h index 4e3cda17c0f..aab3b9fd91a 100644 --- a/mozilla/xpcom/io/nsLocalFileOS2.h +++ b/mozilla/xpcom/io/nsLocalFileOS2.h @@ -140,8 +140,6 @@ private: nsresult SetModDate(PRInt64 aLastModifiedTime, PRBool resolveTerminal); - static nsresult ParseURL(const char* inURL, char **outHost, char **outDirectory, - char **outFileBaseName, char **outFileExtension); }; #endif diff --git a/mozilla/xpcom/io/nsLocalFileUnix.cpp b/mozilla/xpcom/io/nsLocalFileUnix.cpp index a2d6ad73d0a..d5987b94c72 100644 --- a/mozilla/xpcom/io/nsLocalFileUnix.cpp +++ b/mozilla/xpcom/io/nsLocalFileUnix.cpp @@ -1477,81 +1477,6 @@ nsLocalFile::GetDirectoryEntries(nsISimpleEnumerator **entries) (void **)entries); } -NS_IMETHODIMP nsLocalFile::GetURL(char * *aURL) -{ - NS_ENSURE_ARG_POINTER(aURL); - *aURL = nsnull; - - nsresult rv; - char* ePath = nsnull; - nsCAutoString escPath; - - rv = GetPath(&ePath); - if (NS_SUCCEEDED(rv)) { - - // Escape the path with the directory mask - rv = nsStdEscape(ePath, esc_Directory+esc_Forced, escPath); - if (NS_SUCCEEDED(rv)) { - if (escPath[escPath.Length() - 1] != '/') { - PRBool dir; - rv = IsDirectory(&dir); - NS_ASSERTION(NS_SUCCEEDED(rv), "Cannot tell if this is a directory"); - if (NS_SUCCEEDED(rv) && dir) { - // make sure we have a trailing slash - escPath += "/"; - } - } - - escPath.Insert("file://", 0); - - *aURL = ToNewCString(escPath); - rv = *aURL ? NS_OK : NS_ERROR_OUT_OF_MEMORY; - } - } - CRTFREEIF(ePath); - return rv; -} - -NS_IMETHODIMP nsLocalFile::SetURL(const char * aURL) -{ - NS_ENSURE_ARG(aURL); - nsresult rv; - - nsXPIDLCString host, directory, fileBaseName, fileExtension; - - rv = ParseURL(aURL, getter_Copies(host), - getter_Copies(directory), - getter_Copies(fileBaseName), - getter_Copies(fileExtension)); - - if (NS_FAILED(rv)) return rv; - - nsCAutoString path; - nsCAutoString component; - - if (directory) { - nsStdEscape(directory, esc_Directory, component); - path += component; - } - if (fileBaseName) - { - nsStdEscape(fileBaseName, esc_FileBaseName, component); - path += component; - } - if (fileExtension) - { - nsStdEscape(fileExtension, esc_FileExtension, component); - path += '.'; - path += component; - } - - nsUnescape((char*)path.get()); - - rv = InitWithPath(path.get()); - - return rv; -} - NS_IMETHODIMP nsLocalFile::Load(PRLibrary **_retval) { diff --git a/mozilla/xpcom/io/nsLocalFileUnix.h b/mozilla/xpcom/io/nsLocalFileUnix.h index 5740f2ebf80..832930ea630 100644 --- a/mozilla/xpcom/io/nsLocalFileUnix.h +++ b/mozilla/xpcom/io/nsLocalFileUnix.h @@ -104,8 +104,6 @@ protected: return NS_OK; } - static nsresult ParseURL(const char* inURL, char **outHost, char **outDirectory, - char **outFileBaseName, char **outFileExtension); }; #endif /* _nsLocalFileUNIX_H_ */ diff --git a/mozilla/xpcom/io/nsLocalFileWin.cpp b/mozilla/xpcom/io/nsLocalFileWin.cpp index 914b91c29b2..05b62f35629 100644 --- a/mozilla/xpcom/io/nsLocalFileWin.cpp +++ b/mozilla/xpcom/io/nsLocalFileWin.cpp @@ -1893,111 +1893,6 @@ nsLocalFile::GetDirectoryEntries(nsISimpleEnumerator * *entries) return NS_OK; } -NS_IMETHODIMP nsLocalFile::GetURL(char * *aURL) -{ - NS_ENSURE_ARG_POINTER(aURL); - *aURL = nsnull; - - nsresult rv; - char* ePath = nsnull; - nsCAutoString escPath; - - rv = GetPath(&ePath); - if (NS_SUCCEEDED(rv)) { - - // Replace \ with / to convert to an url - char* s = ePath; - while (*s) - { - // We need to call IsDBCSLeadByte because - // Japanese windows can have 0x5C in the sencond byte - // of a Japanese character, for example 0x8F 0x5C is - // one Japanese character - if(::IsDBCSLeadByte(*s) && *(s+1) != nsnull) { - s++; - } - else if (*s == '\\') - *s = '/'; - - s++; - } - - // Escape the path with the directory mask - rv = nsStdEscape(ePath, esc_Directory+esc_Forced, escPath); - if (NS_SUCCEEDED(rv)) { - if (escPath[escPath.Length() - 1] != '/') { - PRBool dir; - rv = IsDirectory(&dir); - NS_ASSERTION(NS_SUCCEEDED(rv), "Cannot tell if this is a directory"); - if (NS_SUCCEEDED(rv) && dir) { - // make sure we have a trailing slash - escPath += "/"; - } - } - escPath.Insert("file:///", 0); - *aURL = ToNewCString(escPath); - rv = *aURL ? NS_OK : NS_ERROR_OUT_OF_MEMORY; - } - } - CRTFREEIF(ePath); - return rv; - -} - -NS_IMETHODIMP nsLocalFile::SetURL(const char * aURL) -{ - NS_ENSURE_ARG(aURL); - nsresult rv; - - nsXPIDLCString host, directory, fileBaseName, fileExtension; - - rv = ParseURL(aURL, getter_Copies(host), getter_Copies(directory), - getter_Copies(fileBaseName), getter_Copies(fileExtension)); - if (NS_FAILED(rv)) return rv; - - nsCAutoString path; - nsCAutoString component; - - if (host) - { - // We can end up with a host when given: file://C|/ instead of file:/// - if (strlen((const char *)host) == 2 && ((const char *)host)[1] == '|') - { - path += host; - path.SetCharAt(':', 1); - } - } - if (directory) - { - nsStdEscape(directory, esc_Directory, component); - if (!host && component.Length() > 2 && component.CharAt(2) == '|') - component.SetCharAt(':', 2); - component.ReplaceChar('/', '\\'); - path += component; - } - if (fileBaseName) - { - nsStdEscape(fileBaseName, esc_FileBaseName, component); - path += component; - } - if (fileExtension) - { - nsStdEscape(fileExtension, esc_FileExtension, component); - path += '.'; - path += component; - } - - nsUnescape((char*)path.get()); - - // remove leading '\' - if (path.CharAt(0) == '\\') - path.Cut(0, 1); - - rv = InitWithPath(path.get()); - - return rv; -} - NS_IMETHODIMP nsLocalFile::GetPersistentDescriptor(char * *aPersistentDescriptor) { diff --git a/mozilla/xpcom/io/nsLocalFileWin.h b/mozilla/xpcom/io/nsLocalFileWin.h index 28d598f7a57..6261682e7fb 100644 --- a/mozilla/xpcom/io/nsLocalFileWin.h +++ b/mozilla/xpcom/io/nsLocalFileWin.h @@ -90,8 +90,6 @@ private: nsresult SetModDate(PRInt64 aLastModifiedTime, PRBool resolveTerminal); - static nsresult ParseURL(const char* inURL, char **outHost, char **outDirectory, - char **outFileBaseName, char **outFileExtension); };