added file operation functionality to the javascript Install object

This commit is contained in:
ssu%netscape.com 1999-06-03 18:19:14 +00:00
parent 4b0ff2c414
commit e499c6dfc9
5 changed files with 1201 additions and 0 deletions

View File

@ -52,6 +52,7 @@ CPPSRCS = \
nsTopProgressNotifier.cpp \
nsLoggingProgressNotifier \
ScheduledTasks.cpp \
nsInstallFileOpItem.cpp \
$(NULL)
INCLUDES += -I$(srcdir)/../public

View File

@ -94,6 +94,7 @@ OBJS = \
.\$(OBJDIR)\nsWinProfile.obj \
.\$(OBJDIR)\nsJSWinProfile.obj \
.\$(OBJDIR)\nsWinProfileItem.obj \
.\$(OBJDIR)\nsInstallFileOpItem.obj \
$(NULL)
include <$(DEPTH)\config\rules.mak>

View File

@ -59,6 +59,9 @@
#include "nsWinProfile.h"
#endif
#include "nsInstallFileOpEnums.h"
#include "nsInstallFileOpItem.h"
#ifdef XP_MAC
#include "Gestalt.h"
#endif
@ -1046,6 +1049,249 @@ nsInstall::GetPatch(nsHashKey *aKey, nsFileSpec* fileName)
}
}
PRInt32
nsInstall::FileOpDirCreate(nsFileSpec& aTarget, PRInt32* aReturn)
{
nsInstallFileOpItem* ifop = new nsInstallFileOpItem(this, NS_FOP_DIR_CREATE, aTarget, aReturn);
if (*aReturn == nsInstall::SUCCESS)
{
*aReturn = ScheduleForInstall( ifop );
}
if (*aReturn == nsInstall::FILE_DOES_NOT_EXIST)
{
*aReturn = nsInstall::SUCCESS;
}
SaveError(*aReturn);
return NS_OK;
}
PRInt32
nsInstall::FileOpDirGetParent(nsFileSpec& aTarget, nsFileSpec* aReturn)
{
// nsInstallFileOpItem ifop(this, aTarget, aReturn);
aTarget.GetParent(*aReturn);
return NS_OK;
}
PRInt32
nsInstall::FileOpDirRemove(nsFileSpec& aTarget, PRInt32 aFlags, PRInt32* aReturn)
{
nsInstallFileOpItem* ifop = new nsInstallFileOpItem(this, NS_FOP_DIR_REMOVE, aTarget, aFlags, aReturn);
if (*aReturn == nsInstall::SUCCESS)
{
*aReturn = ScheduleForInstall( ifop );
}
if (*aReturn == nsInstall::FILE_DOES_NOT_EXIST)
{
*aReturn = nsInstall::SUCCESS;
}
SaveError(*aReturn);
return NS_OK;
}
PRInt32
nsInstall::FileOpDirRename(nsFileSpec& aSrc, nsFileSpec& aTarget, PRInt32* aReturn)
{
nsInstallFileOpItem* ifop = new nsInstallFileOpItem(this, NS_FOP_DIR_RENAME, aSrc, aTarget, aReturn);
if (*aReturn == nsInstall::SUCCESS)
{
*aReturn = ScheduleForInstall( ifop );
}
if (*aReturn == nsInstall::FILE_DOES_NOT_EXIST)
{
*aReturn = nsInstall::SUCCESS;
}
SaveError(*aReturn);
return NS_OK;
}
PRInt32
nsInstall::FileOpFileCopy(nsFileSpec& aSrc, nsFileSpec& aTarget, PRInt32* aReturn)
{
nsInstallFileOpItem* ifop = new nsInstallFileOpItem(this, NS_FOP_FILE_COPY, aSrc, aTarget, aReturn);
if (*aReturn == nsInstall::SUCCESS)
{
*aReturn = ScheduleForInstall( ifop );
}
if (*aReturn == nsInstall::FILE_DOES_NOT_EXIST)
{
*aReturn = nsInstall::SUCCESS;
}
SaveError(*aReturn);
return NS_OK;
}
PRInt32
nsInstall::FileOpFileDelete(nsFileSpec& aTarget, PRInt32 aFlags, PRInt32* aReturn)
{
nsInstallFileOpItem* ifop = new nsInstallFileOpItem(this, NS_FOP_FILE_DELETE, aTarget, aFlags, aReturn);
if (*aReturn == nsInstall::SUCCESS)
{
*aReturn = ScheduleForInstall( ifop );
}
if (*aReturn == nsInstall::FILE_DOES_NOT_EXIST)
{
*aReturn = nsInstall::SUCCESS;
}
SaveError(*aReturn);
return NS_OK;
}
PRInt32
nsInstall::FileOpFileExecute(nsFileSpec& aTarget, nsString& aParams, PRInt32* aReturn)
{
nsInstallFileOpItem* ifop = new nsInstallFileOpItem(this, NS_FOP_FILE_EXECUTE, aTarget, aParams, aReturn);
if (*aReturn == nsInstall::SUCCESS)
{
*aReturn = ScheduleForInstall( ifop );
}
if (*aReturn == nsInstall::FILE_DOES_NOT_EXIST)
{
*aReturn = nsInstall::SUCCESS;
}
SaveError(*aReturn);
return NS_OK;
}
PRInt32
nsInstall::FileOpFileExists(nsFileSpec& aTarget, PRBool* aReturn)
{
*aReturn = aTarget.Exists();
return NS_OK;
}
PRInt32
nsInstall::FileOpFileGetNativeVersion(nsFileSpec& aTarget, nsString* aReturn)
{
return NS_OK;
}
PRInt32
nsInstall::FileOpFileGetDiskSpaceAvailable(nsFileSpec& aTarget, PRUint32* aReturn)
{
*aReturn = aTarget.GetDiskSpaceAvailable();
return NS_OK;
}
PRInt32
nsInstall::FileOpFileGetModDate(nsFileSpec& aTarget, nsFileSpec::TimeStamp* aReturn)
{
aTarget.GetModDate(*aReturn);
return NS_OK;
}
PRInt32
nsInstall::FileOpFileGetSize(nsFileSpec& aTarget, PRUint32* aReturn)
{
*aReturn = aTarget.GetFileSize();
return NS_OK;
}
PRInt32
nsInstall::FileOpFileIsDirectory(nsFileSpec& aTarget, PRBool* aReturn)
{
*aReturn = aTarget.IsDirectory();
return NS_OK;
}
PRInt32
nsInstall::FileOpFileIsFile(nsFileSpec& aTarget, PRBool* aReturn)
{
*aReturn = aTarget.IsFile();
return NS_OK;
}
PRInt32
nsInstall::FileOpFileModDateChanged(nsFileSpec& aTarget, nsFileSpec::TimeStamp& aOldStamp, PRBool* aReturn)
{
*aReturn = aTarget.ModDateChanged(aOldStamp);
return NS_OK;
}
PRInt32
nsInstall::FileOpFileMove(nsFileSpec& aSrc, nsFileSpec& aTarget, PRInt32* aReturn)
{
nsInstallFileOpItem* ifop = new nsInstallFileOpItem(this, NS_FOP_FILE_MOVE, aSrc, aTarget, aReturn);
if (*aReturn == nsInstall::SUCCESS)
{
*aReturn = ScheduleForInstall( ifop );
}
if (*aReturn == nsInstall::FILE_DOES_NOT_EXIST)
{
*aReturn = nsInstall::SUCCESS;
}
SaveError(*aReturn);
return NS_OK;
}
PRInt32
nsInstall::FileOpFileRename(nsFileSpec& aSrc, nsFileSpec& aTarget, PRInt32* aReturn)
{
nsInstallFileOpItem* ifop = new nsInstallFileOpItem(this, NS_FOP_FILE_RENAME, aSrc, aTarget, aReturn);
if (*aReturn == nsInstall::SUCCESS)
{
*aReturn = ScheduleForInstall( ifop );
}
if (*aReturn == nsInstall::FILE_DOES_NOT_EXIST)
{
*aReturn = nsInstall::SUCCESS;
}
SaveError(*aReturn);
return NS_OK;
}
PRInt32
nsInstall::FileOpFileWinShortcutCreate(nsFileSpec& aTarget, PRInt32 aFlags, PRInt32* aReturn)
{
return NS_OK;
}
PRInt32
nsInstall::FileOpFileMacAliasCreate(nsFileSpec& aTarget, PRInt32 aFlags, PRInt32* aReturn)
{
return NS_OK;
}
PRInt32
nsInstall::FileOpFileUnixLinkCreate(nsFileSpec& aTarget, PRInt32 aFlags, PRInt32* aReturn)
{
return NS_OK;
}
/////////////////////////////////////////////////////////////////////////
// Private Methods
/////////////////////////////////////////////////////////////////////////

View File

@ -179,6 +179,26 @@ class nsInstall
PRInt32 StartInstall(const nsString& aUserPackageName, const nsString& aPackageName, const nsString& aVersion, PRInt32* aReturn);
PRInt32 Uninstall(const nsString& aPackageName, PRInt32* aReturn);
PRInt32 FileOpDirCreate(nsFileSpec& aTarget, PRInt32* aReturn);
PRInt32 FileOpDirGetParent(nsFileSpec& aTarget, nsFileSpec* aReturn);
PRInt32 FileOpDirRemove(nsFileSpec& aTarget, PRInt32 aFlags, PRInt32* aReturn);
PRInt32 FileOpDirRename(nsFileSpec& aSrc, nsFileSpec& aTarget, PRInt32* aReturn);
PRInt32 FileOpFileCopy(nsFileSpec& aSrc, nsFileSpec& aTarget, PRInt32* aReturn);
PRInt32 FileOpFileDelete(nsFileSpec& aTarget, PRInt32 aFlags, PRInt32* aReturn);
PRInt32 FileOpFileExists(nsFileSpec& aTarget, PRBool* aReturn);
PRInt32 FileOpFileExecute(nsFileSpec& aTarget, nsString& aParams, PRInt32* aReturn);
PRInt32 FileOpFileGetNativeVersion(nsFileSpec& aTarget, nsString* aReturn);
PRInt32 FileOpFileGetDiskSpaceAvailable(nsFileSpec& aTarget, PRUint32* aReturn);
PRInt32 FileOpFileGetModDate(nsFileSpec& aTarget, nsFileSpec::TimeStamp* aReturn);
PRInt32 FileOpFileGetSize(nsFileSpec& aTarget, PRUint32* aReturn);
PRInt32 FileOpFileIsDirectory(nsFileSpec& aTarget, PRBool* aReturn);
PRInt32 FileOpFileIsFile(nsFileSpec& aTarget, PRBool* aReturn);
PRInt32 FileOpFileModDateChanged(nsFileSpec& aTarget, nsFileSpec::TimeStamp& aOldStamp, PRBool* aReturn);
PRInt32 FileOpFileMove(nsFileSpec& aSrc, nsFileSpec& aTarget, PRInt32* aReturn);
PRInt32 FileOpFileRename(nsFileSpec& aSrc, nsFileSpec& aTarget, PRInt32* aReturn);
PRInt32 FileOpFileWinShortcutCreate(nsFileSpec& aTarget, PRInt32 aFlags, PRInt32* aReturn);
PRInt32 FileOpFileMacAliasCreate(nsFileSpec& aTarget, PRInt32 aFlags, PRInt32* aReturn);
PRInt32 FileOpFileUnixLinkCreate(nsFileSpec& aTarget, PRInt32 aFlags, PRInt32* aReturn);
PRInt32 ExtractFileFromJar(const nsString& aJarfile, nsFileSpec* aSuggestedName, nsFileSpec** aRealName);
void AddPatch(nsHashKey *aKey, nsFileSpec* fileName);

View File

@ -1297,6 +1297,919 @@ InstallTRACE(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
/*END HACK FOR DEBUGGING UNTIL ALERTS WORK*/
//
// Native method DirCreate
//
PR_STATIC_CALLBACK(JSBool)
InstallFileOpDirCreate(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsInstall *nativeThis = (nsInstall*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
PRInt32 nativeRet;
nsAutoString b0;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if(nsnull == nativeThis)
{
return JS_TRUE;
}
if(argc >= 1)
{
// public int DirCreate (String aNativeFolderPath);
ConvertJSValToStr(b0, cx, argv[0]);
nsFileSpec fsB0(b0);
if(NS_OK != nativeThis->FileOpDirCreate(fsB0, &nativeRet))
{
return JS_FALSE;
}
*rval = INT_TO_JSVAL(nativeRet);
}
else
{
JS_ReportError(cx, "Function DirCreate requires 1 parameter");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method DirGetParent
//
PR_STATIC_CALLBACK(JSBool)
InstallFileOpDirGetParent(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsInstall* nativeThis = (nsInstall*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
nsFileSpec nativeRet;
nsAutoString b0;
nsString nativeRetNSStr;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if(nsnull == nativeThis)
{
return JS_TRUE;
}
if(argc >= 1)
{
// public int DirGetParent (String NativeFolderPath);
ConvertJSValToStr(b0, cx, argv[0]);
nsFileSpec fsB0(b0);
if(NS_OK != nativeThis->FileOpDirGetParent(fsB0, &nativeRet))
{
return JS_FALSE;
}
nativeRetNSStr = nativeRet.GetNativePathCString();
*rval = STRING_TO_JSVAL(JS_NewUCStringCopyN(cx, nativeRetNSStr.GetUnicode(), nativeRetNSStr.Length()));
}
else
{
JS_ReportError(cx, "Function DirGetParent requires 1 parameter");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method DirRemove
//
PR_STATIC_CALLBACK(JSBool)
InstallFileOpDirRemove(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsInstall *nativeThis = (nsInstall*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
PRInt32 nativeRet;
nsAutoString b0;
PRBool b1;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if(nsnull == nativeThis)
{
return JS_TRUE;
}
if(argc >= 2)
{
// public int DirRemove (String aNativeFolderPath,
// Bool aRecursive);
ConvertJSValToStr(b0, cx, argv[0]);
nsFileSpec fsB0(b0);
if(!ConvertJSValToBool(&b1, cx, argv[1]))
{
JS_ReportError(cx, "2nd parameter needs to be a Boolean value");
return JS_FALSE;
}
if(NS_OK != nativeThis->FileOpDirRemove(fsB0, b1, &nativeRet))
{
return JS_FALSE;
}
*rval = INT_TO_JSVAL(nativeRet);
}
else
{
JS_ReportError(cx, "Function DirRemove requires 2 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method DirRename
//
PR_STATIC_CALLBACK(JSBool)
InstallFileOpDirRename(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsInstall *nativeThis = (nsInstall*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
PRInt32 nativeRet;
nsAutoString b0;
nsAutoString b1;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if(nsnull == nativeThis)
{
return JS_TRUE;
}
if(argc >= 2)
{
// public int DirRename (String aSourceFolder,
// String aTargetFolder);
ConvertJSValToStr(b0, cx, argv[0]);
ConvertJSValToStr(b1, cx, argv[1]);
nsFileSpec fsB0(b0);
nsFileSpec fsB1(b1);
if(NS_OK != nativeThis->FileOpDirRename(fsB0, fsB1, &nativeRet))
{
return JS_FALSE;
}
*rval = INT_TO_JSVAL(nativeRet);
}
else
{
JS_ReportError(cx, "Function DirRename requires 2 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method FileCopy
//
PR_STATIC_CALLBACK(JSBool)
InstallFileOpFileCopy(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsInstall *nativeThis = (nsInstall*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
PRInt32 nativeRet;
nsAutoString b0;
nsAutoString b1;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if(nsnull == nativeThis)
{
return JS_TRUE;
}
if(argc >= 2)
{
// public int FileCopy (String aSourceFolder,
// String aTargetFolder);
ConvertJSValToStr(b0, cx, argv[0]);
ConvertJSValToStr(b1, cx, argv[1]);
nsFileSpec fsB0(b0);
nsFileSpec fsB1(b1);
if(NS_OK != nativeThis->FileOpFileCopy(fsB0, fsB1, &nativeRet))
{
return JS_FALSE;
}
*rval = INT_TO_JSVAL(nativeRet);
}
else
{
JS_ReportError(cx, "Function FileCopy requires 2 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method FileDelete
//
PR_STATIC_CALLBACK(JSBool)
InstallFileOpFileDelete(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsInstall *nativeThis = (nsInstall*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
PRInt32 nativeRet;
nsAutoString b0;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if(nsnull == nativeThis)
{
return JS_TRUE;
}
if(argc >= 1)
{
// public int FileDelete (String aSourceFolder);
ConvertJSValToStr(b0, cx, argv[0]);
nsFileSpec fsB0(b0);
if(NS_OK != nativeThis->FileOpFileDelete(fsB0, PR_FALSE, &nativeRet))
{
return JS_FALSE;
}
*rval = INT_TO_JSVAL(nativeRet);
}
else
{
JS_ReportError(cx, "Function FileDelete requires 1 parameter");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method FileExists
//
PR_STATIC_CALLBACK(JSBool)
InstallFileOpFileExists(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsInstall *nativeThis = (nsInstall*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
PRInt32 nativeRet;
nsAutoString b0;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if(nsnull == nativeThis)
{
return JS_TRUE;
}
if(argc >= 1)
{
// public int FileExists (String NativeFolderPath);
ConvertJSValToStr(b0, cx, argv[0]);
nsFileSpec fsB0(b0);
if(NS_OK != nativeThis->FileOpFileExists(fsB0, &nativeRet))
{
return JS_FALSE;
}
*rval = INT_TO_JSVAL(nativeRet);
}
else
{
JS_ReportError(cx, "Function FileExists requires 1 parameter");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method FileExecute
//
PR_STATIC_CALLBACK(JSBool)
InstallFileOpFileExecute(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsInstall *nativeThis = (nsInstall*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
PRInt32 nativeRet;
nsAutoString b0;
nsAutoString b1;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if(nsnull == nativeThis)
{
return JS_TRUE;
}
if(argc >= 2)
{
// public int FileExecute (String aSourceFolder,
// String aParameters);
ConvertJSValToStr(b0, cx, argv[0]);
ConvertJSValToStr(b1, cx, argv[1]);
nsFileSpec fsB0(b0);
if(NS_OK != nativeThis->FileOpFileExecute(fsB0, b1, &nativeRet))
{
return JS_FALSE;
}
*rval = INT_TO_JSVAL(nativeRet);
}
else
{
JS_ReportError(cx, "Function FileExecute requires 2 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method FileGetNativeVersion
//
PR_STATIC_CALLBACK(JSBool)
InstallFileOpFileGetNativeVersion(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsInstall* nativeThis = (nsInstall*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
nsAutoString nativeRet;
nsAutoString b0;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if(nsnull == nativeThis)
{
return JS_TRUE;
}
if(argc >= 1)
{
// public int FileGetNativeVersion (String NativeFolderPath);
ConvertJSValToStr(b0, cx, argv[0]);
nsFileSpec fsB0(b0);
if(NS_OK != nativeThis->FileOpFileGetNativeVersion(fsB0, &nativeRet))
{
return JS_FALSE;
}
*rval = STRING_TO_JSVAL(JS_NewUCStringCopyN(cx, nativeRet.GetUnicode(), nativeRet.Length()));
}
else
{
JS_ReportError(cx, "Function FileGetNativeVersion requires 1 parameter");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method FileGetDiskSpaceAvailable
//
PR_STATIC_CALLBACK(JSBool)
InstallFileOpFileGetDiskSpaceAvailable(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsInstall* nativeThis = (nsInstall*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
PRUint32 nativeRet;
nsAutoString b0;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if(nsnull == nativeThis)
{
return JS_TRUE;
}
if(argc >= 1)
{
// public int FileGetDiskSpaceAvailable (String NativeFolderPath);
ConvertJSValToStr(b0, cx, argv[0]);
nsFileSpec fsB0(b0);
if(NS_OK != nativeThis->FileOpFileGetDiskSpaceAvailable(fsB0, &nativeRet))
{
return JS_FALSE;
}
if ( nativeRet <= JSVAL_INT_MAX )
*rval = INT_TO_JSVAL(nativeRet);
else
{
JSInt64 l;
jsdouble d;
JSLL_UI2L( l, nativeRet );
JSLL_L2D( d, l );
JS_NewDoubleValue( cx, d, rval );
}
}
else
{
JS_ReportError(cx, "Function FileGetDiskSpaceAvailable requires 1 parameter");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method FileGetModDate
//
PR_STATIC_CALLBACK(JSBool)
InstallFileOpFileGetModDate(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsInstall* nativeThis = (nsInstall*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
PRUint32 nativeRet;
nsAutoString b0;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if(nsnull == nativeThis)
{
return JS_TRUE;
}
if(argc >= 1)
{
// public int FileGetModDate (String NativeFolderPath);
ConvertJSValToStr(b0, cx, argv[0]);
nsFileSpec fsB0(b0);
if(NS_OK != nativeThis->FileOpFileGetModDate(fsB0, &nativeRet))
{
return JS_FALSE;
}
if ( nativeRet <= JSVAL_INT_MAX )
*rval = INT_TO_JSVAL(nativeRet);
else
{
JSInt64 l;
jsdouble d;
JSLL_UI2L( l, nativeRet );
JSLL_L2D( d, l );
JS_NewDoubleValue( cx, d, rval );
}
}
else
{
JS_ReportError(cx, "Function FileGetModDate requires 1 parameter");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method FileGetSize
//
PR_STATIC_CALLBACK(JSBool)
InstallFileOpFileGetSize(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsInstall* nativeThis = (nsInstall*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
PRUint32 nativeRet;
nsAutoString b0;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if(nsnull == nativeThis)
{
return JS_TRUE;
}
if(argc >= 1)
{
// public int FileGetSize (String NativeFolderPath);
ConvertJSValToStr(b0, cx, argv[0]);
nsFileSpec fsB0(b0);
if(NS_OK != nativeThis->FileOpFileGetSize(fsB0, &nativeRet))
{
return JS_FALSE;
}
if ( nativeRet <= JSVAL_INT_MAX )
*rval = INT_TO_JSVAL(nativeRet);
else
{
JSInt64 l;
jsdouble d;
JSLL_UI2L( l, nativeRet );
JSLL_L2D( d, l );
JS_NewDoubleValue( cx, d, rval );
}
}
else
{
JS_ReportError(cx, "Function FileGetSize requires 1 parameter");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method FileIsDirectory
//
PR_STATIC_CALLBACK(JSBool)
InstallFileOpFileIsDirectory(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsInstall *nativeThis = (nsInstall*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
PRInt32 nativeRet;
nsAutoString b0;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if(nsnull == nativeThis)
{
return JS_TRUE;
}
if(argc >= 1)
{
// public int FileIsDirectory (String NativeFolderPath);
ConvertJSValToStr(b0, cx, argv[0]);
nsFileSpec fsB0(b0);
if(NS_OK != nativeThis->FileOpFileIsDirectory(fsB0, &nativeRet))
{
return JS_FALSE;
}
*rval = INT_TO_JSVAL(nativeRet);
}
else
{
JS_ReportError(cx, "Function FileIsDirectory requires 1 parameter");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method FileIsFile
//
PR_STATIC_CALLBACK(JSBool)
InstallFileOpFileIsFile(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsInstall *nativeThis = (nsInstall*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
PRInt32 nativeRet;
nsAutoString b0;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if(nsnull == nativeThis)
{
return JS_TRUE;
}
if(argc >= 1)
{
// public int FileIsFile (String NativeFolderPath);
ConvertJSValToStr(b0, cx, argv[0]);
nsFileSpec fsB0(b0);
if(NS_OK != nativeThis->FileOpFileIsFile(fsB0, &nativeRet))
{
return JS_FALSE;
}
*rval = INT_TO_JSVAL(nativeRet);
}
else
{
JS_ReportError(cx, "Function FileIsFile requires 1 parameter");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method FileModDateChanged
//
PR_STATIC_CALLBACK(JSBool)
InstallFileOpFileModDateChanged(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsInstall* nativeThis = (nsInstall*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
PRInt32 nativeRet;
nsAutoString b0;
PRUint32 b1;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if(nsnull == nativeThis)
{
return JS_TRUE;
}
if(argc >= 2)
{
// public int FileModDateChanged (String aSourceFolder,
// Number aOldDate);
ConvertJSValToStr(b0, cx, argv[0]);
b1 = JSVAL_TO_INT(argv[1]);
nsFileSpec fsB0(b0);
if(NS_OK != nativeThis->FileOpFileModDateChanged(fsB0, b1, &nativeRet))
{
return JS_FALSE;
}
*rval = INT_TO_JSVAL(nativeRet);
}
else
{
JS_ReportError(cx, "Function FileModDateChanged requires 2 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method FileMove
//
PR_STATIC_CALLBACK(JSBool)
InstallFileOpFileMove(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsInstall *nativeThis = (nsInstall*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
PRInt32 nativeRet;
nsAutoString b0;
nsAutoString b1;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if(nsnull == nativeThis)
{
return JS_TRUE;
}
if(argc >= 2)
{
// public int FileMove (String aSourceFolder,
// String aTargetFolder);
ConvertJSValToStr(b0, cx, argv[0]);
ConvertJSValToStr(b1, cx, argv[1]);
nsFileSpec fsB0(b0);
nsFileSpec fsB1(b1);
if(NS_OK != nativeThis->FileOpFileMove(fsB0, fsB1, &nativeRet))
{
return JS_FALSE;
}
*rval = INT_TO_JSVAL(nativeRet);
}
else
{
JS_ReportError(cx, "Function FileMove requires 2 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method FileRename
//
PR_STATIC_CALLBACK(JSBool)
InstallFileOpFileRename(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsInstall *nativeThis = (nsInstall*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
PRInt32 nativeRet;
nsAutoString b0;
nsAutoString b1;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if(nsnull == nativeThis)
{
return JS_TRUE;
}
if(argc >= 2)
{
// public int FileRename (String aSourceFolder,
// String aTargetFolder);
ConvertJSValToStr(b0, cx, argv[0]);
ConvertJSValToStr(b1, cx, argv[1]);
nsFileSpec fsB0(b0);
nsFileSpec fsB1(b1);
if(NS_OK != nativeThis->FileOpFileRename(fsB0, fsB1, &nativeRet))
{
return JS_FALSE;
}
*rval = INT_TO_JSVAL(nativeRet);
}
else
{
JS_ReportError(cx, "Function FileRename requires 2 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method FileWinShortcutCreate
//
PR_STATIC_CALLBACK(JSBool)
InstallFileOpFileWinShortcutCreate(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsInstall *nativeThis = (nsInstall*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
PRInt32 nativeRet;
nsAutoString b0;
PRInt32 b1;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if(nsnull == nativeThis)
{
return JS_TRUE;
}
if(argc >= 2)
{
// public int FileWinShortcutCreate (String aSourceFolder,
// Number aFlags);
ConvertJSValToStr(b0, cx, argv[0]);
b1 = JSVAL_TO_INT(argv[1]);
nsFileSpec fsB0(b0);
if(NS_OK != nativeThis->FileOpFileWinShortcutCreate(fsB0, b1, &nativeRet))
{
return JS_FALSE;
}
*rval = INT_TO_JSVAL(nativeRet);
}
else
{
JS_ReportError(cx, "Function FileWinShortcutCreate requires 2 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method FileMacAliasCreate
//
PR_STATIC_CALLBACK(JSBool)
InstallFileOpFileMacAliasCreate(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsInstall *nativeThis = (nsInstall*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
PRInt32 nativeRet;
nsAutoString b0;
PRInt32 b1;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if(nsnull == nativeThis)
{
return JS_TRUE;
}
if(argc >= 2)
{
// public int FileMacAliasCreate (String aSourceFolder,
// Number aFlags);
ConvertJSValToStr(b0, cx, argv[0]);
b1 = JSVAL_TO_INT(argv[1]);
nsFileSpec fsB0(b0);
if(NS_OK != nativeThis->FileOpFileMacAliasCreate(fsB0, b1, &nativeRet))
{
return JS_FALSE;
}
*rval = INT_TO_JSVAL(nativeRet);
}
else
{
JS_ReportError(cx, "Function FileMacAliasCreate requires 2 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method FileUnixLinkCreate
//
PR_STATIC_CALLBACK(JSBool)
InstallFileOpFileUnixLinkCreate(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsInstall *nativeThis = (nsInstall*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
PRInt32 nativeRet;
nsAutoString b0;
PRInt32 b1;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if(nsnull == nativeThis)
{
return JS_TRUE;
}
if(argc >= 2)
{
// public int FileUnixLinkCreate (String aSourceFolder,
// Number aFlags);
ConvertJSValToStr(b0, cx, argv[0]);
b1 = JSVAL_TO_INT(argv[1]);
nsFileSpec fsB0(b0);
if(NS_OK != nativeThis->FileOpFileUnixLinkCreate(fsB0, b1, &nativeRet))
{
return JS_FALSE;
}
*rval = INT_TO_JSVAL(nativeRet);
}
else
{
JS_ReportError(cx, "Function FileUnixLinkCreate requires 2 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
/***********************************************************************/
//
// class for Install
@ -1391,6 +2304,26 @@ static JSFunctionSpec InstallMethods[] =
/*START HACK FOR DEBUGGING UNTIL ALERTS WORK*/
{"TRACE", InstallTRACE, 1},
/*END HACK FOR DEBUGGING UNTIL ALERTS WORK*/
{"DirCreate", InstallFileOpDirCreate, 1},
{"DirGetParent", InstallFileOpDirGetParent, 1},
{"DirRemove", InstallFileOpDirRemove, 2},
{"DirRename", InstallFileOpDirRename, 2},
{"FileCopy", InstallFileOpFileCopy, 2},
{"FileDelete", InstallFileOpFileDelete, 2},
{"FileExists", InstallFileOpFileExists, 1},
{"FileExecute", InstallFileOpFileExecute, 2},
{"FileGetNativeVersion", InstallFileOpFileGetNativeVersion, 1},
{"FileGetDiskSpaceAvailable", InstallFileOpFileGetDiskSpaceAvailable,1},
{"FileGetModDate", InstallFileOpFileGetModDate, 1},
{"FileGetSize", InstallFileOpFileGetSize, 1},
{"FileIsDirectory", InstallFileOpFileIsDirectory, 1},
{"FileIsFile", InstallFileOpFileIsFile, 1},
{"FileModDateChanged", InstallFileOpFileModDateChanged, 2},
{"FileMove", InstallFileOpFileMove, 2},
{"FileRename", InstallFileOpFileRename, 2},
{"FileWinShortcutCreate", InstallFileOpFileWinShortcutCreate, 2},
{"FileMacAliasCreate", InstallFileOpFileMacAliasCreate, 2},
{"FileUnixLinkCreate", InstallFileOpFileUnixLinkCreate, 2},
{0}
};