fixing bug 103228 - Fix xpinstall engine so InstallTrigger.compareVersion() works. r=syd, sr=dveditz.

This commit is contained in:
ssu%netscape.com 2001-10-08 21:24:19 +00:00
Родитель 6cb223322f
Коммит 4477f5a169
5 изменённых файлов: 82 добавлений и 10 удалений

Просмотреть файл

@ -27,26 +27,29 @@ function deleteThisFile(dirKey, file)
var fFileToDelete;
fFileToDelete = getFolder(dirKey, file);
logComment(file + " file: " + fFileToDelete);
if(File.exists(fFileToDelete))
logComment("File to delete: " + fFileToDelete);
if(File.isFile(fFileToDelete))
{
fileDelete(fFileToDelete);
File.remove(fFileToDelete);
return(true);
}
else
return(false);
}
// this function deletes a folder (recursively) if it exists
function deleteThisFolder(dirKey, folder)
// this function deletes a folder if it exists
function deleteThisFolder(dirKey, folder, recursiveDelete)
{
var fToDelete;
if(typeof recursiveDelete == "undefined")
recursiveDelete = true;
fToDelete = getFolder(dirKey, folder);
logComment(folder + " folder: " + fToDelete);
if(File.exists(fToDelete))
logComment("folder to delete: " + fToDelete);
if(File.isDirectory(fToDelete))
{
File.dirRemove(fToDelete, true);
File.dirRemove(fToDelete, recursiveDelete);
return(true);
}
else

Просмотреть файл

@ -118,6 +118,7 @@ OBJS = \
WIN_LIBS= \
ole32.lib \
version.lib \
$(NULL)
include <$(DEPTH)\config\rules.mak>

Просмотреть файл

@ -22,6 +22,7 @@
* Daniel Veditz <dveditz@netscape.com>
* Douglas Turner <dougt@netscape.com>
* Pierre Phaneuf <pp@ludusdesign.com>
* Sean Su <ssu@netscape.com>
*/
@ -1813,10 +1814,75 @@ nsInstall::FileOpFileExists(nsInstallFolder& aTarget, PRBool* aReturn)
return NS_OK;
}
#ifdef XP_WIN
#include <winver.h>
#endif
PRInt32
nsInstall::FileOpFileGetNativeVersion(nsInstallFolder& aTarget, nsString* aReturn)
{
return NS_OK;
PRInt32 rv = NS_OK;
#ifdef XP_WIN
PRBool flagExists;
nsCOMPtr<nsIFile> localTarget(aTarget.GetFileSpec());
UINT uLen;
UINT dwLen;
DWORD dwHandle;
LPVOID lpData;
LPVOID lpBuffer;
VS_FIXEDFILEINFO *lpBuffer2;
DWORD dwMajor = 0;
DWORD dwMinor = 0;
DWORD dwRelease = 0;
DWORD dwBuild = 0;
nsXPIDLCString nativeTargetPath;
char *nativeVersionString = nsnull;
if(localTarget == nsnull)
return(rv);
flagExists = PR_FALSE;
localTarget->Exists(&flagExists);
if(flagExists)
{
localTarget->GetPath(getter_Copies(nativeTargetPath));
uLen = 0;
/* GetFileVersionInfoSize() requires a char *, but the api doesn't
* indicate that it will modify it */
dwLen = GetFileVersionInfoSize((char *)nativeTargetPath.get(), &dwHandle);
lpData = (LPVOID)PR_Malloc(sizeof(long)*dwLen);
if(!lpData)
return(nsInstall::OUT_OF_MEMORY);
/* GetFileVersionInfo() requires a char *, but the api doesn't
* indicate that it will modify it */
if(GetFileVersionInfo((char *)nativeTargetPath.get(), dwHandle, dwLen, lpData) != 0)
{
if(VerQueryValue(lpData, "\\", &lpBuffer, &uLen) != 0)
{
lpBuffer2 = (VS_FIXEDFILEINFO *)lpBuffer;
dwMajor = HIWORD(lpBuffer2->dwFileVersionMS);
dwMinor = LOWORD(lpBuffer2->dwFileVersionMS);
dwRelease = HIWORD(lpBuffer2->dwFileVersionLS);
dwBuild = LOWORD(lpBuffer2->dwFileVersionLS);
}
}
nativeVersionString = PR_smprintf("%d.%d.%d.%d", dwMajor, dwMinor, dwRelease, dwBuild);
if(!nativeVersionString)
rv = nsInstall::OUT_OF_MEMORY;
else
{
aReturn->Assign(NS_ConvertASCIItoUCS2(nativeVersionString));
PR_smprintf_free(nativeVersionString);
}
PR_FREEIF(lpData);
}
#endif
return(rv);
}
PRInt32

Просмотреть файл

@ -189,7 +189,8 @@ nsInstallTrigger::UpdateEnabled(PRBool* aReturn)
}
else
{
*aReturn = PR_FALSE; /* no prefs manager. set to false */
// no prefs manager: we're in the install wizard and always work
*aReturn = PR_TRUE;
}
return NS_OK;

Просмотреть файл

@ -1483,6 +1483,7 @@ static JSFunctionSpec FileOpMethods[] =
{"exists", InstallFileOpFileExists, 1},
{"execute", InstallFileOpFileExecute, 2},
{"nativeVersion", InstallFileOpFileGetNativeVersion, 1},
{"windowsVersion", InstallFileOpFileGetNativeVersion, 1},
{"diskSpaceAvailable", InstallFileOpFileGetDiskSpaceAvailable,1},
{"modDate", InstallFileOpFileGetModDate, 1},
{"size", InstallFileOpFileGetSize, 1},