1999-10-23 03:28:27 +04:00
|
|
|
#include "stdafx.h"
|
|
|
|
#include "WizardTypes.h"
|
1999-10-23 05:21:09 +04:00
|
|
|
#include "winbase.h" // for CopyDir
|
|
|
|
#include <direct.h>
|
2002-05-07 00:34:26 +04:00
|
|
|
#include <fstream.h>
|
1999-10-23 03:28:27 +04:00
|
|
|
|
|
|
|
__declspec(dllexport) WIDGET GlobalWidgetArray[1000];
|
|
|
|
__declspec(dllexport) int GlobalArrayIndex=0;
|
1999-11-09 00:54:31 +03:00
|
|
|
__declspec(dllexport) BOOL IsSameCache = TRUE;
|
2002-07-02 03:54:05 +04:00
|
|
|
CString strNscpInstaller = "./netscape-installer/";
|
|
|
|
CString strXpi = strNscpInstaller + "xpi/*.xpi";
|
|
|
|
CString strConfigini = strNscpInstaller + "config.ini";
|
1999-11-09 00:54:31 +03:00
|
|
|
|
2002-04-06 02:48:14 +04:00
|
|
|
void ExtractContents(CString rootPath, CString instblobPath,
|
|
|
|
CString instFilename, CString platformInfo,
|
|
|
|
CString platformPath, CString extractPath);
|
2002-07-02 03:54:05 +04:00
|
|
|
void PopulateNscpxpi(CString rootpath, CString platformInfo, CString instFilename, CString instblobPath,
|
|
|
|
CString tarfile, CString nscpxpiPath, CString extractPath);
|
2002-04-06 02:48:14 +04:00
|
|
|
|
2000-01-14 01:10:48 +03:00
|
|
|
extern "C" __declspec(dllexport)
|
|
|
|
int GetAttrib(CString theValue, char* attribArray[MAX_SIZE])
|
|
|
|
{
|
|
|
|
// attribArray= (char**) malloc(MIN_SIZE*MINSIZE);
|
|
|
|
int j = 0;
|
|
|
|
for (int i = 0; i < GlobalArrayIndex; i++)
|
|
|
|
{
|
|
|
|
if (GlobalWidgetArray[i].attrib == theValue)
|
|
|
|
{
|
|
|
|
attribArray[j] = (char*)(LPCTSTR)(GlobalWidgetArray[i].name);
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return j;
|
|
|
|
}
|
|
|
|
|
1999-10-23 03:28:27 +04:00
|
|
|
|
|
|
|
extern "C" __declspec(dllexport)
|
|
|
|
WIDGET* findWidget(CString theName)
|
|
|
|
{
|
|
|
|
|
|
|
|
for (int i = 0; i < GlobalArrayIndex; i++)
|
|
|
|
{
|
|
|
|
if (GlobalWidgetArray[i].name == theName) {
|
|
|
|
return (&GlobalWidgetArray[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" __declspec(dllexport)
|
|
|
|
WIDGET* SetGlobal(CString theName, CString theValue)
|
|
|
|
{
|
|
|
|
WIDGET* w = findWidget(theName);
|
|
|
|
if (w == NULL)
|
|
|
|
{
|
|
|
|
// Make sure we can add this value
|
|
|
|
if (GlobalArrayIndex >= sizeof(GlobalWidgetArray))
|
|
|
|
exit(11);
|
|
|
|
|
|
|
|
GlobalWidgetArray[GlobalArrayIndex].name = theName;
|
|
|
|
GlobalWidgetArray[GlobalArrayIndex].value = theValue;
|
|
|
|
w = &GlobalWidgetArray[GlobalArrayIndex];
|
|
|
|
GlobalArrayIndex++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
w->value = theValue;
|
|
|
|
|
|
|
|
return w;
|
|
|
|
}
|
|
|
|
|
1999-12-21 05:32:25 +03:00
|
|
|
__declspec(dllexport)
|
|
|
|
CString GetGlobal(CString theName)
|
1999-10-23 03:28:27 +04:00
|
|
|
{
|
|
|
|
WIDGET *w = findWidget(theName);
|
|
|
|
|
|
|
|
if (w)
|
1999-12-21 05:32:25 +03:00
|
|
|
return (w->value);
|
1999-10-23 03:28:27 +04:00
|
|
|
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
1999-10-23 05:21:09 +04:00
|
|
|
extern "C" __declspec(dllexport)
|
1999-11-03 04:51:54 +03:00
|
|
|
void CopyDir(CString from, CString to, LPCTSTR extension, int overwrite)
|
1999-10-23 05:21:09 +04:00
|
|
|
{
|
|
|
|
WIN32_FIND_DATA data;
|
|
|
|
HANDLE d;
|
|
|
|
CString dot = ".";
|
|
|
|
CString dotdot = "..";
|
|
|
|
CString fchild, tchild;
|
|
|
|
CString pattern = from + "\\*.*";
|
|
|
|
int found;
|
|
|
|
DWORD tmp;
|
|
|
|
|
|
|
|
|
|
|
|
d = FindFirstFile((const char *) to, &data);
|
|
|
|
if (d == INVALID_HANDLE_VALUE)
|
|
|
|
mkdir(to);
|
|
|
|
|
|
|
|
d = FindFirstFile((const char *) pattern, &data);
|
|
|
|
found = (d != INVALID_HANDLE_VALUE);
|
|
|
|
|
|
|
|
while (found)
|
|
|
|
{
|
|
|
|
if (data.cFileName != dot && data.cFileName != dotdot)
|
|
|
|
{
|
|
|
|
fchild = from + "\\" + data.cFileName;
|
|
|
|
tchild = to + "\\" + data.cFileName;
|
|
|
|
tmp = data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY;
|
|
|
|
if (tmp == FILE_ATTRIBUTE_DIRECTORY)
|
1999-11-03 04:51:54 +03:00
|
|
|
CopyDir(fchild, tchild, NULL, overwrite);
|
1999-10-23 05:21:09 +04:00
|
|
|
else
|
1999-10-28 23:26:35 +04:00
|
|
|
{
|
|
|
|
CString spot=fchild;
|
|
|
|
int loc = fchild.Find('.');
|
|
|
|
if (loc)
|
|
|
|
spot.Delete(0,loc+1);
|
1999-11-03 04:51:54 +03:00
|
|
|
if (!extension || (spot.CompareNoCase((CString)extension)==0))
|
|
|
|
CopyFile((const char *) fchild, (const char *) tchild, !overwrite);
|
1999-10-28 23:26:35 +04:00
|
|
|
}
|
1999-10-23 05:21:09 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
found = FindNextFile(d, &data);
|
|
|
|
}
|
|
|
|
|
|
|
|
FindClose(d);
|
|
|
|
}
|
1999-10-23 03:28:27 +04:00
|
|
|
|
1999-11-03 04:51:54 +03:00
|
|
|
extern "C" __declspec(dllexport)
|
|
|
|
void ExecuteCommand(char *command, int showflag, DWORD wait)
|
|
|
|
{
|
|
|
|
STARTUPINFO startupInfo;
|
|
|
|
PROCESS_INFORMATION processInfo;
|
|
|
|
|
|
|
|
memset(&startupInfo, 0, sizeof(startupInfo));
|
|
|
|
memset(&processInfo, 0, sizeof(processInfo));
|
|
|
|
|
|
|
|
startupInfo.cb = sizeof(STARTUPINFO);
|
|
|
|
startupInfo.dwFlags = STARTF_USESHOWWINDOW;
|
|
|
|
//startupInfo.wShowWindow = SW_SHOW;
|
|
|
|
startupInfo.wShowWindow = showflag;
|
|
|
|
|
|
|
|
BOOL executionSuccessful = CreateProcess(NULL, command, NULL, NULL, TRUE,
|
|
|
|
NORMAL_PRIORITY_CLASS, NULL, NULL,
|
|
|
|
&startupInfo, &processInfo);
|
|
|
|
DWORD error = GetLastError();
|
|
|
|
WaitForSingleObject(processInfo.hProcess, wait);
|
|
|
|
}
|
|
|
|
|
2002-01-18 22:30:05 +03:00
|
|
|
extern "C" __declspec(dllexport)
|
|
|
|
void CopyDirectory(CString source, CString dest, BOOL subdir)
|
|
|
|
// Copy files in subdirectories if the subdir flag is set (equal to 1).
|
|
|
|
{
|
|
|
|
CFileFind finder;
|
|
|
|
CString sFileToFind = source + "\\*.*";
|
|
|
|
BOOL bWorking = finder.FindFile(sFileToFind);
|
|
|
|
while (bWorking)
|
|
|
|
{
|
|
|
|
bWorking = finder.FindNextFile();
|
|
|
|
CString newPath=dest + "\\";
|
|
|
|
|
|
|
|
if (finder.IsDots()) continue;
|
|
|
|
if (finder.IsDirectory())
|
|
|
|
{
|
|
|
|
CString dirPath = finder.GetFilePath();
|
|
|
|
newPath += finder.GetFileName();
|
|
|
|
_mkdir(newPath);
|
|
|
|
if (subdir == TRUE)
|
|
|
|
CopyDirectory(dirPath, newPath, TRUE);
|
|
|
|
if (!CopyFile(dirPath,newPath,0))
|
|
|
|
DWORD e = GetLastError();
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
newPath += finder.GetFileName();
|
|
|
|
CString source = finder.GetFilePath();
|
|
|
|
if (!CopyFile(source,newPath,0))
|
|
|
|
DWORD e = GetLastError();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-12-18 02:07:47 +03:00
|
|
|
extern "C" __declspec(dllexport)
|
|
|
|
void EraseDirectory(CString sPath)
|
|
|
|
{
|
|
|
|
CFileFind finder;
|
|
|
|
CString sFullPath = sPath + "\\*.*";
|
|
|
|
|
|
|
|
BOOL bWorking = finder.FindFile(sFullPath);
|
|
|
|
while (bWorking)
|
|
|
|
{
|
|
|
|
bWorking = finder.FindNextFile();
|
|
|
|
if (finder.IsDots()) continue;
|
|
|
|
if (finder.IsDirectory())
|
|
|
|
{
|
|
|
|
CString dirPath = finder.GetFilePath();
|
|
|
|
EraseDirectory(dirPath);
|
|
|
|
_rmdir(finder.GetFilePath());
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
_unlink( finder.GetFilePath() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-01-18 22:30:05 +03:00
|
|
|
__declspec(dllexport)
|
|
|
|
CString SearchDirectory(CString dirPath, BOOL subDir, CString serachStr)
|
|
|
|
// This function searches all the files in the directory dirPath,
|
|
|
|
// for the file whose name contains the search string serachStr,
|
|
|
|
// searching recursively if subDir is TRUE
|
|
|
|
{
|
|
|
|
CFileFind finder;
|
2002-04-06 02:48:14 +04:00
|
|
|
CString filePath, fileName, retval, sFileToFind;
|
|
|
|
sFileToFind = dirPath + "\\*.*";
|
2002-01-18 22:30:05 +03:00
|
|
|
BOOL found = finder.FindFile(sFileToFind);
|
|
|
|
while (found)
|
|
|
|
{
|
|
|
|
found = finder.FindNextFile();
|
|
|
|
|
|
|
|
if (finder.IsDots()) continue;
|
|
|
|
|
|
|
|
filePath = finder.GetFilePath();
|
|
|
|
fileName = finder.GetFileName();
|
2002-04-06 02:48:14 +04:00
|
|
|
fileName.MakeLower();
|
2002-01-18 22:30:05 +03:00
|
|
|
if (fileName.Find(serachStr) != -1)
|
|
|
|
return fileName;
|
|
|
|
|
|
|
|
if (finder.IsDirectory())
|
|
|
|
{
|
|
|
|
if (subDir == TRUE)
|
|
|
|
retval = SearchDirectory(filePath, TRUE, serachStr);
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return fileName;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" __declspec(dllexport)
|
|
|
|
void CreateDirectories(CString instblobPath)
|
|
|
|
// Create appropriate platform and language directories
|
|
|
|
{
|
2002-04-06 02:48:14 +04:00
|
|
|
CString rootPath, curVersion, instDirname, instFilename, fileExtension,
|
|
|
|
platformInfo, platformPath, extractPath, languageInfo,
|
2002-07-02 03:54:05 +04:00
|
|
|
languagePath, nscpxpiPath, tarfile;
|
2002-04-06 02:48:14 +04:00
|
|
|
int blobPathlen, findfilePos, finddirPos;
|
|
|
|
char oldDir[MAX_SIZE];
|
|
|
|
|
|
|
|
rootPath = GetGlobal("Root");
|
|
|
|
curVersion = GetGlobal("Version");
|
|
|
|
blobPathlen = instblobPath.GetLength();
|
|
|
|
finddirPos = instblobPath.ReverseFind('\\');
|
|
|
|
instDirname = instblobPath.Left(finddirPos);
|
|
|
|
instFilename = instblobPath.Right(blobPathlen - finddirPos - 1);
|
|
|
|
findfilePos = instFilename.Find('.');
|
|
|
|
fileExtension = instFilename.Right(instFilename.GetLength()- findfilePos - 1);
|
2002-07-02 03:54:05 +04:00
|
|
|
findfilePos = instFilename.ReverseFind('.');
|
|
|
|
tarfile = instFilename.Left(findfilePos);
|
2002-04-06 02:48:14 +04:00
|
|
|
|
2002-01-18 22:30:05 +03:00
|
|
|
if (fileExtension == "tar.gz")
|
2002-04-06 02:48:14 +04:00
|
|
|
platformInfo = "Linux";
|
|
|
|
else if (fileExtension == "exe")
|
|
|
|
platformInfo = "Windows";
|
|
|
|
else if (fileExtension == "zip")
|
|
|
|
platformInfo = "Mac OS";
|
|
|
|
|
|
|
|
platformPath = rootPath + "Version\\" + curVersion + "\\" + platformInfo;
|
|
|
|
extractPath = platformPath + "\\" + "temp";
|
|
|
|
|
|
|
|
if (GetFileAttributes(platformPath) == -1)
|
|
|
|
// platform directory does not exist
|
|
|
|
_mkdir(platformPath);
|
|
|
|
_mkdir(extractPath);
|
|
|
|
GetCurrentDirectory(sizeof(oldDir), oldDir);
|
|
|
|
SetCurrentDirectory((char *)(LPCTSTR) instDirname);
|
|
|
|
ExtractContents(rootPath, instblobPath, instFilename, platformInfo,
|
|
|
|
platformPath, extractPath);
|
|
|
|
CString searchStr = "defl";
|
|
|
|
searchStr = SearchDirectory(extractPath, TRUE, searchStr);
|
|
|
|
|
|
|
|
if (searchStr != "")
|
|
|
|
{
|
|
|
|
languageInfo = searchStr.Mid(4,4);
|
|
|
|
languagePath = rootPath + "Version\\" + curVersion + "\\" +
|
|
|
|
platformInfo + "\\" + languageInfo;
|
|
|
|
nscpxpiPath = languagePath + "\\Nscpxpi";
|
|
|
|
_mkdir(languagePath);
|
2002-07-02 03:54:05 +04:00
|
|
|
if (GetFileAttributes(nscpxpiPath) != -1)
|
|
|
|
// directory exists
|
|
|
|
EraseDirectory(nscpxpiPath);
|
|
|
|
else
|
|
|
|
_mkdir(nscpxpiPath);
|
|
|
|
PopulateNscpxpi(rootPath, platformInfo, instFilename, instblobPath, tarfile, nscpxpiPath, extractPath);
|
2002-04-06 02:48:14 +04:00
|
|
|
}
|
|
|
|
EraseDirectory(extractPath);
|
|
|
|
RemoveDirectory(extractPath);
|
|
|
|
SetCurrentDirectory(oldDir);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ExtractContents(CString rootPath, CString instblobPath,
|
|
|
|
CString instFilename, CString platformInfo,
|
|
|
|
CString platformPath, CString extractPath)
|
|
|
|
// Extract contents of blob installer
|
|
|
|
{
|
|
|
|
CString command, quotes = "\"", spaces = " ";
|
|
|
|
char originalDir[MAX_SIZE];
|
|
|
|
|
|
|
|
if (platformInfo == "Linux")
|
|
|
|
{
|
2002-07-02 03:54:05 +04:00
|
|
|
// change path to linux format
|
2002-04-06 02:48:14 +04:00
|
|
|
extractPath.Replace("\\","/");
|
|
|
|
extractPath.Replace(":","");
|
|
|
|
extractPath.Insert(0,"/cygdrive/");
|
2002-07-02 03:54:05 +04:00
|
|
|
// Extract config.ini and .xpi files from tar.gz file
|
|
|
|
command = "tar -zxvf " + instFilename + " -C " + quotes + extractPath +
|
|
|
|
quotes + spaces + strXpi + spaces + strConfigini;
|
2002-04-06 02:48:14 +04:00
|
|
|
ExecuteCommand((char *)(LPCTSTR) command, SW_HIDE, INFINITE);
|
|
|
|
}
|
|
|
|
else if (platformInfo == "Windows")
|
|
|
|
{
|
|
|
|
GetCurrentDirectory(sizeof(originalDir), originalDir);
|
|
|
|
CopyFile(instFilename, extractPath+"\\"+instFilename, FALSE);
|
|
|
|
SetCurrentDirectory((char *)(LPCTSTR) extractPath);
|
|
|
|
command = instFilename + " -u";
|
|
|
|
ExecuteCommand((char *)(LPCTSTR) command, SW_HIDE, INFINITE);
|
|
|
|
DeleteFile(extractPath+"\\"+instFilename);
|
|
|
|
SetCurrentDirectory(originalDir);
|
|
|
|
}
|
|
|
|
else if (platformInfo == "Mac OS")
|
2002-01-18 22:30:05 +03:00
|
|
|
{
|
2002-04-06 02:48:14 +04:00
|
|
|
command = quotes + rootPath + "unzip.exe"+ quotes + "-od" + spaces
|
|
|
|
+ quotes + platformPath + quotes + spaces + quotes + instblobPath
|
|
|
|
+ quotes;
|
2002-01-18 22:30:05 +03:00
|
|
|
ExecuteCommand((char *)(LPCTSTR) command, SW_HIDE, INFINITE);
|
2002-04-06 02:48:14 +04:00
|
|
|
}
|
2002-01-18 22:30:05 +03:00
|
|
|
|
2002-04-06 02:48:14 +04:00
|
|
|
}
|
|
|
|
|
2002-07-02 03:54:05 +04:00
|
|
|
void PopulateNscpxpi(CString rootPath, CString platformInfo, CString instFilename, CString instblobPath,
|
|
|
|
CString tarfile, CString nscpxpiPath, CString extractPath)
|
2002-04-06 02:48:14 +04:00
|
|
|
// Populate Nscpxpi directory with appropriate installer files
|
|
|
|
{
|
|
|
|
CString command,
|
|
|
|
quotes = "\"",
|
|
|
|
spaces = " ",
|
2002-04-30 06:46:51 +04:00
|
|
|
nscpzipFile = nscpxpiPath + "\\NSSetup.zip";
|
2002-07-02 03:54:05 +04:00
|
|
|
|
2002-04-06 02:48:14 +04:00
|
|
|
if (platformInfo == "Linux")
|
|
|
|
{
|
|
|
|
CString strNscpInstaller = "\\netscape-installer";
|
2002-07-02 03:54:05 +04:00
|
|
|
CString tempnscpxpiPath = nscpxpiPath;
|
|
|
|
|
2002-04-06 02:48:14 +04:00
|
|
|
CopyDirectory(extractPath+strNscpInstaller+"\\xpi", nscpxpiPath, TRUE);
|
2002-07-02 03:54:05 +04:00
|
|
|
CopyFile(extractPath+strNscpInstaller+"\\Config.ini", nscpxpiPath+"\\Config.ini", FALSE);
|
|
|
|
CopyFile(instblobPath, nscpxpiPath+"\\"+instFilename, FALSE);
|
|
|
|
|
|
|
|
// change path to linux format
|
|
|
|
tempnscpxpiPath.Replace("\\","/");
|
|
|
|
tempnscpxpiPath.Replace(":","");
|
|
|
|
tempnscpxpiPath.Insert(0,"/cygdrive/");
|
|
|
|
// Decompress tar.gz file
|
|
|
|
CString command = "gzip -d " + quotes + tempnscpxpiPath + "/" + instFilename + quotes;
|
|
|
|
ExecuteCommand((char *)(LPCTSTR) command, SW_HIDE, INFINITE);
|
|
|
|
// Delete .xpi and config.ini files in tar.gz
|
|
|
|
command = "tar --delete -f " + quotes + tempnscpxpiPath + "/" +
|
|
|
|
tarfile + quotes + spaces + strXpi + spaces + strConfigini;
|
|
|
|
ExecuteCommand((char *)(LPCTSTR) command, SW_HIDE, INFINITE);
|
|
|
|
|
2002-04-06 02:48:14 +04:00
|
|
|
}
|
|
|
|
else if (platformInfo == "Windows")
|
|
|
|
{
|
|
|
|
CopyDirectory(extractPath, nscpxpiPath, TRUE);
|
|
|
|
command = quotes + rootPath + "zip.exe" + quotes + " -jm " +
|
|
|
|
quotes + nscpzipFile + quotes + spaces + quotes +
|
|
|
|
nscpxpiPath + "\\*.exe" + quotes + spaces + quotes +
|
|
|
|
nscpxpiPath + "\\*.txt" + quotes + spaces + quotes +
|
|
|
|
nscpxpiPath + "\\*.dll" + quotes + spaces + quotes +
|
|
|
|
nscpxpiPath + "\\install.ini" + quotes;
|
|
|
|
ExecuteCommand((char *)(LPCTSTR) command, SW_HIDE, INFINITE);
|
|
|
|
command = quotes + rootPath + "zip.exe" + quotes + " -j " +
|
|
|
|
quotes + nscpzipFile + quotes + spaces + quotes +
|
|
|
|
nscpxpiPath + "\\config.ini" + quotes;
|
|
|
|
ExecuteCommand((char *)(LPCTSTR) command, SW_HIDE, INFINITE);
|
2002-01-18 22:30:05 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-05-07 00:34:26 +04:00
|
|
|
__declspec(dllexport)
|
|
|
|
CString GetLocaleName(CString localeCode)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
Gets the pretty locale name given the locale code
|
|
|
|
Reads the browser region.properties and language.properties files to
|
|
|
|
get the pretty region name and pretty language name respectively and
|
|
|
|
finally returns the pretty locale name
|
|
|
|
For example, return 'English-United States (enus)' given 'enus'
|
|
|
|
*/
|
|
|
|
|
|
|
|
CString rootPath, languageFile, regionFile, langCode, regCode,
|
2002-05-07 01:32:20 +04:00
|
|
|
langName, regName, localeName, strVersion;
|
2002-05-07 00:34:26 +04:00
|
|
|
int langlen, reglen;
|
|
|
|
char buffer[MIN_SIZE];
|
|
|
|
|
|
|
|
rootPath = GetGlobal("Root");
|
|
|
|
strVersion = GetGlobal("Version");
|
|
|
|
languageFile = rootPath + "Version\\"+strVersion+"\\Windows\\enus\\"
|
|
|
|
"languageNames.properties";
|
|
|
|
regionFile = rootPath + "Version\\"+strVersion+"\\Windows\\enus\\"
|
|
|
|
"regionNames.properties";
|
|
|
|
ifstream languageNames(languageFile);
|
|
|
|
ifstream regionNames(regionFile);
|
|
|
|
|
|
|
|
langCode = (localeCode.Left(2)) + " = ";
|
|
|
|
langlen = langCode.GetLength();
|
|
|
|
regCode = (localeCode.Right(2)) + "\t=\t";
|
|
|
|
reglen = regCode.GetLength();
|
|
|
|
|
|
|
|
if (!languageNames)
|
|
|
|
{
|
|
|
|
AfxMessageBox("Cannot open file", MB_OK);
|
|
|
|
languageNames.close();
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
while (!languageNames.eof())
|
|
|
|
{
|
|
|
|
languageNames.getline(buffer,sizeof(buffer));
|
|
|
|
CString tempstr = buffer;
|
|
|
|
int templen = tempstr.GetLength();
|
|
|
|
if ((tempstr.Find(langCode)) != -1)
|
|
|
|
{
|
|
|
|
langName = tempstr.Right(templen-langlen);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!regionNames)
|
|
|
|
{
|
|
|
|
AfxMessageBox("Cannot open file", MB_OK);
|
|
|
|
languageNames.close();
|
|
|
|
regionNames.close();
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
while (!regionNames.eof())
|
|
|
|
{
|
|
|
|
regionNames.getline(buffer,sizeof(buffer));
|
|
|
|
CString tempstr = buffer;
|
|
|
|
int templen = tempstr.GetLength();
|
|
|
|
if ((tempstr.Find(regCode)) != -1)
|
|
|
|
{
|
|
|
|
regName = tempstr.Right(templen-reglen);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((regName.IsEmpty()) && (!langName.IsEmpty()))
|
|
|
|
localeName = langName + " (" + localeCode + ")";
|
|
|
|
else if ((!regName.IsEmpty()) && (langName.IsEmpty()))
|
|
|
|
localeName = regName + " (" + localeCode + ")";
|
|
|
|
else if ((regName.IsEmpty()) && (langName.IsEmpty()))
|
|
|
|
localeName = "(" + localeCode + ")";
|
|
|
|
else
|
|
|
|
localeName = langName + "-" + regName + " (" + localeCode + ")";
|
|
|
|
|
|
|
|
languageNames.close();
|
|
|
|
regionNames.close();
|
|
|
|
|
|
|
|
return localeName;
|
|
|
|
}
|
|
|
|
|
|
|
|
__declspec(dllexport)
|
|
|
|
CString GetLocaleCode(CString localeName)
|
|
|
|
{
|
|
|
|
// Get the locale code given the pretty locale name
|
|
|
|
// For example, return 'enus' given 'English-United States (enus)'
|
|
|
|
int pos = localeName.Find("(");
|
|
|
|
int localelen = localeName.GetLength();
|
|
|
|
CString localeCode = localeName.Right(localelen-pos-1);
|
|
|
|
localeCode.Remove(')');
|
|
|
|
|
|
|
|
return localeCode;
|
|
|
|
}
|
|
|
|
|
2001-12-18 02:07:47 +03:00
|
|
|
__declspec(dllexport)
|
|
|
|
CString GetModulePath()
|
|
|
|
{
|
|
|
|
char currPath[MID_SIZE];
|
|
|
|
int i,numBytes;
|
|
|
|
|
|
|
|
// Get the path of the file that was executed
|
|
|
|
numBytes = GetModuleFileName(NULL, currPath, MIN_SIZE);
|
|
|
|
|
|
|
|
// get the cmd path
|
|
|
|
// Remove the filename from the path
|
|
|
|
for (i=numBytes-1;i >= 0 && currPath[i] != '\\';i--);
|
|
|
|
// Terminate command line with 0
|
|
|
|
if (i >= 0)
|
|
|
|
currPath[i+1]= '\0';
|
|
|
|
|
|
|
|
return CString(currPath);
|
|
|
|
}
|