add mechanism to create custom config files for installed components
This commit is contained in:
dprice%netscape.com 2002-07-03 23:48:06 +00:00
Родитель 431701e468
Коммит 4685d5f74c
4 изменённых файлов: 95 добавлений и 0 удалений

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

@ -6585,6 +6585,19 @@ HRESULT DecryptVariable(LPSTR szVariable, DWORD dwVariableSize)
/* parse for the "c:\Program Files" directory */
GetWinReg(HKEY_LOCAL_MACHINE, szWRMSCurrentVersion, "ProgramFilesDir", szVariable, dwVariableSize);
}
else if(lstrcmpi(szVariable, "PROGRAMFILESPATH") == 0)
{
/* parse for the "\Program Files" directory -- NOTE does not include the drive letter */
GetWinReg(HKEY_LOCAL_MACHINE, szWRMSCurrentVersion, "ProgramFilesDir", szBuf, sizeof(szBuf));
lstrcpy(szVariable, szBuf+2);
}
else if(lstrcmpi(szVariable, "INSTALLDRIVE") == 0)
{
/* parse for "C:" */
szVariable[0] = sgProduct.szPath[0];
szVariable[1] = sgProduct.szPath[1];
szVariable[2] = '\0';
}
else if(lstrcmpi(szVariable, "COMMONFILESDIR") == 0)
{
/* parse for the "c:\Program Files\Common Files" directory */

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

@ -324,6 +324,7 @@ void ProcessFileOpsForAll(DWORD dwTiming)
{
ProcessFileOps(dwTiming, NULL);
ProcessFileOpsForSelectedComponents(dwTiming);
ProcessCreateCustomFiles(dwTiming);
}
int VerifyArchive(LPSTR szArchive)
@ -2075,3 +2076,82 @@ HRESULT ProcessProgramFolderShowCmd()
return(FO_SUCCESS);
}
HRESULT ProcessCreateCustomFiles(DWORD dwTiming)
{
DWORD dwCompIndex;
DWORD dwFileIndex;
DWORD dwSectIndex;
DWORD dwKVIndex;
siC *siCObject = NULL;
char szBufTiny[MAX_BUF_TINY];
char szSection[MAX_BUF_TINY];
char szBuf[MAX_BUF];
char szFileName[MAX_BUF];
char szDefinedSection[MAX_BUF];
char szDefinedKey[MAX_BUF];
char szDefinedValue[MAX_BUF];
dwCompIndex = 0;
siCObject = SiCNodeGetObject(dwCompIndex, TRUE, AC_ALL);
while(siCObject)
{
dwFileIndex = 0;
wsprintf(szSection,"%s-Configuration File%d",siCObject->szReferenceName,dwFileIndex);
siCObject = SiCNodeGetObject(++dwCompIndex, TRUE, AC_ALL);
if(TimingCheck(dwTiming, szSection, szFileIniConfig) == FALSE)
{
continue;
}
GetPrivateProfileString(szSection, "FileName", "", szBuf, sizeof(szBuf), szFileIniConfig);
while (*szBuf != '\0')
{
DecryptString(szFileName, szBuf);
if(FileExists(szFileName))
{
DeleteFile(szFileName);
}
/* TO DO - Support a File Type for something other than .ini */
dwSectIndex = 0;
wsprintf(szBufTiny, "Section%d",dwSectIndex);
GetPrivateProfileString(szSection, szBufTiny, "", szDefinedSection, sizeof(szDefinedSection), szFileIniConfig);
while(*szDefinedSection != '\0')
{
dwKVIndex =0;
wsprintf(szBufTiny,"Section%d-Key%d",dwSectIndex,dwKVIndex);
GetPrivateProfileString(szSection, szBufTiny, "", szDefinedKey, sizeof(szDefinedKey), szFileIniConfig);
while(*szDefinedKey != '\0')
{
wsprintf(szBufTiny,"Section%d-Value%d",dwSectIndex,dwKVIndex);
GetPrivateProfileString(szSection, szBufTiny, "", szBuf, sizeof(szBuf), szFileIniConfig);
DecryptString(szDefinedValue, szBuf);
if(WritePrivateProfileString(szDefinedSection, szDefinedKey, szDefinedValue, szFileName) == 0)
{
char szEWPPS[MAX_BUF];
char szBuf[MAX_BUF];
char szBuf2[MAX_BUF];
if(GetPrivateProfileString("Messages", "ERROR_WRITEPRIVATEPROFILESTRING", "", szEWPPS, sizeof(szEWPPS), szFileIniInstall))
{
wsprintf(szBuf, "%s\n [%s]\n %s=%s", szFileName, szDefinedSection, szDefinedKey, szDefinedValue);
wsprintf(szBuf2, szEWPPS, szBuf);
PrintError(szBuf2, ERROR_CODE_SHOW);
}
return(FO_ERROR_WRITE);
}
wsprintf(szBufTiny,"Section%d-Key%d",dwSectIndex,++dwKVIndex);
GetPrivateProfileString(szSection, szBufTiny, "", szDefinedKey, sizeof(szDefinedKey), szFileIniConfig);
} /* while(*szDefinedKey != '\0') */
wsprintf(szBufTiny, "Section%d",++dwSectIndex);
GetPrivateProfileString(szSection, szBufTiny, "", szDefinedSection, sizeof(szDefinedSection), szFileIniConfig);
} /* while(*szDefinedSection != '\0') */
wsprintf(szSection,"%s-Configuration File%d",siCObject->szReferenceName,++dwFileIndex);
GetPrivateProfileString(szSection, "FileName", "", szBuf, sizeof(szBuf), szFileIniConfig);
} /* while(*szBuf != '\0') */
} /* while(siCObject) */
return (FO_SUCCESS);
}

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

@ -35,6 +35,7 @@ HRESULT ProcessMoveFile(DWORD dwTiming, char *szSectionPrefix);
HRESULT FileCopy(LPSTR szFrom, LPSTR szTo, BOOL bFailIfExists, BOOL bDnu);
HRESULT ProcessCopyFile(DWORD dwTiming, char *szSectionPrefix);
HRESULT ProcessCreateDirectory(DWORD dwTiming, char *szSectionPrefix);
HRESULT ProcessCreateCustomFiles(DWORD dwTiming);
HRESULT FileDelete(LPSTR szDestination);
HRESULT ProcessDeleteFile(DWORD dwTiming, char *szSectionPrefix);
HRESULT DirectoryRemove(LPSTR szDestination, BOOL bRemoveSubdirs);

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

@ -168,6 +168,7 @@ typedef int PRInt32;
#define FO_ERROR_FILE_NOT_FOUND 1
#define FO_ERROR_DESTINATION_CONFLICT 2
#define FO_ERROR_CHANGE_DIR 3
#define FO_ERROR_WRITE 4
/* Mode of Setup to run in */
#define NORMAL 0