From 14973255e8cd7791af62b7a4d41de9386248c168 Mon Sep 17 00:00:00 2001 From: "pete%alphanumerica.com" Date: Tue, 4 Dec 2001 00:27:43 +0000 Subject: [PATCH] b=112515, r=douft, sr=jst remove spawn method from nsIFile. /** Warning nsIFile API change */ --pete git-svn-id: svn://10.0.0.236/trunk@109584 18797224-902f-48f8-a5cc-f745e15eee43 --- .../content/viewers/styleRules/styleRules.js | 9 ++- .../exthandler/os2/nsOSHelperAppService.cpp | 9 ++- .../exthandler/unix/nsOSHelperAppService.cpp | 9 ++- .../exthandler/win/nsOSHelperAppService.cpp | 9 ++- mozilla/xpcom/io/nsIFile.idl | 7 -- mozilla/xpcom/io/nsLocalFileMac.cpp | 26 -------- mozilla/xpcom/io/nsLocalFileOS2.cpp | 64 ------------------- mozilla/xpcom/io/nsLocalFileUnix.cpp | 38 ----------- mozilla/xpcom/io/nsLocalFileWin.cpp | 40 ------------ 9 files changed, 31 insertions(+), 180 deletions(-) diff --git a/mozilla/extensions/inspector/resources/content/viewers/styleRules/styleRules.js b/mozilla/extensions/inspector/resources/content/viewers/styleRules/styleRules.js index 3fbaeb75a79..e372fc31fab 100644 --- a/mozilla/extensions/inspector/resources/content/viewers/styleRules/styleRules.js +++ b/mozilla/extensions/inspector/resources/content/viewers/styleRules/styleRules.js @@ -190,8 +190,13 @@ StyleRulesViewer.prototype = try { var exe = XPCU.createInstance("@mozilla.org/file/local;1", "nsILocalFile"); exe.initWithPath("c:\\windows\\notepad.exe"); - exe = exe.nsIFile; - exe.spawn([url], 1); + exe = exe.nsIFile; + var C = Components; + var proc = C.classes['@mozilla.org/process/util;1'].createInstance + (C.interfaces.nsIProcess); + proc.init(exe); + var pid = {}; + proc.run(false, [url], 1, pid); } catch (ex) { alert("Unable to open editor."); } diff --git a/mozilla/uriloader/exthandler/os2/nsOSHelperAppService.cpp b/mozilla/uriloader/exthandler/os2/nsOSHelperAppService.cpp index 22415600d06..434ff127c0e 100644 --- a/mozilla/uriloader/exthandler/os2/nsOSHelperAppService.cpp +++ b/mozilla/uriloader/exthandler/os2/nsOSHelperAppService.cpp @@ -28,6 +28,7 @@ #include "nsIURL.h" #include "nsIMIMEInfo.h" #include "nsILocalFile.h" +#include "nsProcess.h" #include @@ -110,7 +111,13 @@ NS_IMETHODIMP nsOSHelperAppService::LaunchAppWithTempFile(nsIMIMEInfo * aMIMEInf // if we were given an application to use then use it....otherwise // make the registry call to launch the app const char * strPath = (const char *) path; - application->Spawn(&strPath, 1); + nsCOMPtr process = do_CreateInstance(NS_PROCESS_CONTRACTID); + nsresult rv; + if (NS_FAILED(rv = process->Init(application))) + return rv; + PRUint32 pid; + if (NS_FAILED(rv = process->Run(PR_FALSE, &strPath, 1, &pid))) + return rv; } else // use the system default { diff --git a/mozilla/uriloader/exthandler/unix/nsOSHelperAppService.cpp b/mozilla/uriloader/exthandler/unix/nsOSHelperAppService.cpp index e8e5990a7f9..40c2493dd97 100644 --- a/mozilla/uriloader/exthandler/unix/nsOSHelperAppService.cpp +++ b/mozilla/uriloader/exthandler/unix/nsOSHelperAppService.cpp @@ -31,6 +31,7 @@ #include "nsIFileStreams.h" #include "nsILineInputStream.h" #include "nsILocalFile.h" +#include "nsIProcess.h" #include "nsIPref.h" #include "nsHashtable.h" #include "nsCRT.h" @@ -148,7 +149,13 @@ NS_IMETHODIMP nsOSHelperAppService::LaunchAppWithTempFile(nsIMIMEInfo * aMIMEInf // if we were given an application to use then use it....otherwise // make the registry call to launch the app const char * strPath = path.get(); - application->Spawn(&strPath, 1); + nsCOMPtr process = do_CreateInstance(NS_PROCESS_CONTRACTID); + nsresult rv; + if (NS_FAILED(rv = process->Init(application))) + return rv; + PRUint32 pid; + if (NS_FAILED(rv = process->Run(PR_FALSE, &strPath, 1, &pid))) + return rv; } else { diff --git a/mozilla/uriloader/exthandler/win/nsOSHelperAppService.cpp b/mozilla/uriloader/exthandler/win/nsOSHelperAppService.cpp index 778ca6835c2..50e6e0478bf 100644 --- a/mozilla/uriloader/exthandler/win/nsOSHelperAppService.cpp +++ b/mozilla/uriloader/exthandler/win/nsOSHelperAppService.cpp @@ -28,6 +28,7 @@ #include "nsIMIMEInfo.h" #include "nsMimeTypes.h" #include "nsILocalFile.h" +#include "nsIProcess" // we need windows.h to read out registry information... #include @@ -62,7 +63,13 @@ NS_IMETHODIMP nsOSHelperAppService::LaunchAppWithTempFile(nsIMIMEInfo * aMIMEInf // if we were given an application to use then use it....otherwise // make the registry call to launch the app const char * strPath = (const char *) path; - application->Spawn(&strPath, 1); + nsCOMPtr process = do_CreateInstance(NS_PROCESS_CONTRACTID); + nsresult rv; + if (NS_FAILED(rv = process->Init(application))) + return rv; + PRUint32 pid; + if (NS_FAILED(rv = process->Run(PR_FALSE, &strPath, 1, &pid))) + return rv; } else // use the system default { diff --git a/mozilla/xpcom/io/nsIFile.idl b/mozilla/xpcom/io/nsIFile.idl index 3be10892e45..79d72805670 100644 --- a/mozilla/xpcom/io/nsIFile.idl +++ b/mozilla/xpcom/io/nsIFile.idl @@ -159,13 +159,6 @@ interface nsIFile : nsISupports void moveTo(in nsIFile newParentDir, [const] in string newName); void moveToUnicode(in nsIFile newParentDir, [const] in wstring newName); - /** - * This will try to execute this file. It will not block for - * execution. 'args' will be passed through on the command line - * if the OS supports that. - */ - void spawn([array, size_is(count)] in string args, in unsigned long count); - /** * This will try to delete this file. The 'recursive' flag * must be PR_TRUE to delete directories which are not empty. diff --git a/mozilla/xpcom/io/nsLocalFileMac.cpp b/mozilla/xpcom/io/nsLocalFileMac.cpp index 39ddd923f90..450f591229e 100644 --- a/mozilla/xpcom/io/nsLocalFileMac.cpp +++ b/mozilla/xpcom/io/nsLocalFileMac.cpp @@ -1779,32 +1779,6 @@ nsLocalFile::MoveTo(nsIFile *newParentDir, const char *newName) return MoveCopy( newParentDir, newName, PR_FALSE, PR_FALSE ); } -NS_IMETHODIMP -nsLocalFile::Spawn(const char **args, PRUint32 count) -{ - OSErr err = noErr; - LaunchParamBlockRec launchPB; - PRBool isFile; - nsresult rv = IsFile(&isFile); - - if (NS_FAILED(rv)) - return rv; - - launchPB.launchAppSpec = &mTargetSpec; - launchPB.launchAppParameters = NULL; - launchPB.launchBlockID = extendedBlock; - launchPB.launchEPBLength = extendedBlockLen; - launchPB.launchFileFlags = NULL; - launchPB.launchControlFlags = launchContinue + launchNoFileFlags + launchUseMinimum; - launchPB.launchControlFlags += launchDontSwitch; - - err = LaunchApplication(&launchPB); - if (err != noErr) - return MacErrorMapper(err); - - return NS_OK; -} - NS_IMETHODIMP nsLocalFile::Load(PRLibrary * *_retval) { diff --git a/mozilla/xpcom/io/nsLocalFileOS2.cpp b/mozilla/xpcom/io/nsLocalFileOS2.cpp index 6d46622a556..6cb8b48b98f 100644 --- a/mozilla/xpcom/io/nsLocalFileOS2.cpp +++ b/mozilla/xpcom/io/nsLocalFileOS2.cpp @@ -1181,70 +1181,6 @@ nsLocalFile::MoveTo(nsIFile *newParentDir, const char *newName) return CopyMove(newParentDir, newName, PR_FALSE, PR_TRUE); } -NS_IMETHODIMP -nsLocalFile::Spawn(const char **args, PRUint32 count) -{ - PRBool isFile; - nsresult rv = IsFile(&isFile); - - if (NS_FAILED(rv)) - return rv; - - // make sure that when we allocate we have 1 greater than the - // count since we need to null terminate the list for the argv to - // pass into PR_CreateProcessDetached -// char **my_argv = NULL; - -// my_argv = (char **)nsMemory::Alloc(sizeof(char *) * (count + 2) ); -// if (!my_argv) { -// return NS_ERROR_OUT_OF_MEMORY; -// } - - // copy the args - PRUint32 i; - ULONG paramLen = 0; - for (i=0; i < count; i++) { -// my_argv[i+1] = (char *)args[i]; - paramLen += strlen((char *)args[i]) + 1; - } - // we need to set argv[0] to the program name. -// my_argv[0] = mResolvedPath; - - // Build a single string with all of the parameters - char *pszInputs = NULL; - pszInputs = (char *)nsMemory::Alloc( paramLen ); - - strcpy(pszInputs, (char *)args[0]); - for (i=1; i < count; i++) { - strcat(pszInputs, " "); - strcat(pszInputs, (char *)args[i]); - } - - // null terminate the array -// my_argv[count+1] = NULL; - -// Need to use DosStartSession to launch a program of another type -// rv = PR_CreateProcessDetached(mResolvedPath, my_argv, NULL, NULL); - STARTDATA sd; - ULONG sid; - PID pid; - memset(&sd, 0, sizeof(STARTDATA)); - sd.Length = 24; - sd.PgmName = NS_CONST_CAST(char*, mResolvedPath.get()); - sd.PgmInputs = pszInputs; - APIRET rc = DosStartSession(&sd, &sid, &pid); - - // free up our argv -// nsMemory::Free(my_argv); - nsMemory::Free(pszInputs); - -// if (PR_SUCCESS == rv) - if (rc == NO_ERROR || rc == ERROR_SMG_START_IN_BACKGROUND) - return NS_OK; - else - return NS_ERROR_FILE_EXECUTION_FAILED; -} - NS_IMETHODIMP nsLocalFile::Load(PRLibrary * *_retval) { diff --git a/mozilla/xpcom/io/nsLocalFileUnix.cpp b/mozilla/xpcom/io/nsLocalFileUnix.cpp index 6e91426ace1..95bf5b0b0f0 100644 --- a/mozilla/xpcom/io/nsLocalFileUnix.cpp +++ b/mozilla/xpcom/io/nsLocalFileUnix.cpp @@ -1448,44 +1448,6 @@ nsLocalFile::GetTarget(char **_retval) return rv; } -/** - * Warning this method is going away - */ -NS_IMETHODIMP -nsLocalFile::Spawn(const char **args, PRUint32 count) -{ - CHECK_mPath(); - - /** - * make sure that when we allocate we have 1 greater than the - * count since we need to null terminate the list for the argv to - * pass into PR_CreateProcessDetached - */ - char **my_argv = (char **)malloc(sizeof(char *) * (count + 2) ); - if (!my_argv) - return NS_ERROR_OUT_OF_MEMORY; - - // copy the args - PRUint32 i; - for (i=0; i < count; i++) - my_argv[i+1] = (char *)args[i]; - - // we need to set argv[0] to the program name. - my_argv[0] = (char *)mPath.get(); - - // null terminate the array - my_argv[count+1] = nsnull; - - PRStatus rv = PR_CreateProcessDetached(mPath.get(), my_argv, nsnull, nsnull); - - // free up our argv - free(my_argv); - - if (rv != PR_SUCCESS) - return NS_ERROR_FILE_EXECUTION_FAILED; - return NS_OK; -} - /* attribute PRBool followLinks; */ NS_IMETHODIMP nsLocalFile::GetFollowLinks(PRBool *aFollowLinks) diff --git a/mozilla/xpcom/io/nsLocalFileWin.cpp b/mozilla/xpcom/io/nsLocalFileWin.cpp index ea9f9f61c2f..549e3e2c5c0 100644 --- a/mozilla/xpcom/io/nsLocalFileWin.cpp +++ b/mozilla/xpcom/io/nsLocalFileWin.cpp @@ -1100,46 +1100,6 @@ nsLocalFile::MoveTo(nsIFile *newParentDir, const char *newName) return CopyMove(newParentDir, newName, PR_FALSE, PR_TRUE); } -NS_IMETHODIMP -nsLocalFile::Spawn(const char **args, PRUint32 count) -{ - PRBool isFile; - nsresult rv = IsFile(&isFile); - - if (NS_FAILED(rv)) - return rv; - - // make sure that when we allocate we have 1 greater than the - // count since we need to null terminate the list for the argv to - // pass into PR_CreateProcessDetached - char **my_argv = NULL; - - my_argv = (char **)nsMemory::Alloc(sizeof(char *) * (count + 2) ); - if (!my_argv) { - return NS_ERROR_OUT_OF_MEMORY; - } - - // copy the args - PRUint32 i; - for (i=0; i < count; i++) { - my_argv[i+1] = (char *)args[i]; - } - // we need to set argv[0] to the program name. - my_argv[0] = NS_CONST_CAST(char*, mResolvedPath.get()); - - // null terminate the array - my_argv[count+1] = NULL; - rv = PR_CreateProcessDetached(mResolvedPath.get(), my_argv, NULL, NULL); - - // free up our argv - nsMemory::Free(my_argv); - - if (PR_SUCCESS == rv) - return NS_OK; - else - return NS_ERROR_FILE_EXECUTION_FAILED; -} - NS_IMETHODIMP nsLocalFile::Load(PRLibrary * *_retval) {