b=112515, r=douft, sr=jst
remove spawn method from nsIFile. /** Warning nsIFile API change */ --pete
This commit is contained in:
Родитель
8dfd22ad44
Коммит
e3f793389c
|
@ -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.");
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "nsIURL.h"
|
||||
#include "nsIMIMEInfo.h"
|
||||
#include "nsILocalFile.h"
|
||||
#include "nsProcess.h"
|
||||
|
||||
#include <os2.h>
|
||||
|
||||
|
@ -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<nsIProcess> 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
|
||||
{
|
||||
|
|
|
@ -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<nsIProcess> 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
|
||||
{
|
||||
|
|
|
@ -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 <windows.h>
|
||||
|
@ -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<nsIProcess> 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
|
||||
{
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче