advpack: Implement AddDelBackupEntry.
diff --git a/dlls/advpack/files.c b/dlls/advpack/files.c
index fc37839..cd13c6a 100644
--- a/dlls/advpack/files.c
+++ b/dlls/advpack/files.c
@@ -55,16 +55,47 @@
*
* If lpcszBackupDir is NULL, the INI file is assumed to exist in
* c:\windows or created there if it does not exist.
- *
- * BUGS
- * Unimplemented.
*/
HRESULT WINAPI AddDelBackupEntry(LPCSTR lpcszFileList, LPCSTR lpcszBackupDir,
LPCSTR lpcszBaseName, DWORD dwFlags)
{
- FIXME("(%p, %p, %p, %ld) stub\n", lpcszFileList, lpcszBackupDir,
+ CHAR szIniPath[MAX_PATH];
+ LPSTR szString = NULL;
+
+ const char szBackupEntry[] = "-1,0,0,0,0,0,-1";
+
+ TRACE("(%p, %p, %p, %ld)\n", lpcszFileList, lpcszBackupDir,
lpcszBaseName, dwFlags);
+ if (!lpcszFileList || !*lpcszFileList)
+ return S_OK;
+
+ if (lpcszBackupDir)
+ lstrcpyA(szIniPath, lpcszBackupDir);
+ else
+ GetWindowsDirectoryA(szIniPath, MAX_PATH);
+
+ lstrcatA(szIniPath, "\\");
+ lstrcatA(szIniPath, lpcszBaseName);
+ lstrcatA(szIniPath, ".ini");
+
+ SetFileAttributesA(szIniPath, FILE_ATTRIBUTE_NORMAL);
+
+ if (dwFlags & AADBE_ADD_ENTRY)
+ szString = (LPSTR)szBackupEntry;
+ else if (dwFlags & AADBE_DEL_ENTRY)
+ szString = NULL;
+
+ /* add or delete the INI entries */
+ while (*lpcszFileList)
+ {
+ WritePrivateProfileStringA("backup", lpcszFileList, szString, szIniPath);
+ lpcszFileList += lstrlenA(lpcszFileList) + 1;
+ }
+
+ /* hide the INI file */
+ SetFileAttributesA(szIniPath, FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_HIDDEN);
+
return S_OK;
}
diff --git a/dlls/advpack/tests/files.c b/dlls/advpack/tests/files.c
index d113877..8a62b4c 100644
--- a/dlls/advpack/tests/files.c
+++ b/dlls/advpack/tests/files.c
@@ -163,12 +163,9 @@
/* create the INF file */
res = pAddDelBackupEntry("one\0two\0three", "c:\\", "basename", AADBE_ADD_ENTRY);
ok(res == S_OK, "Expected S_OK, got %ld\n", res);
- todo_wine
- {
- ok(check_ini_file_attr(path), "Expected ini file to be hidden\n");
- ok(check_ini_contents(path, TRUE), "Expected ini contents to match\n");
- ok(DeleteFileA(path), "Expected path to exist\n");
- }
+ ok(check_ini_file_attr(path), "Expected ini file to be hidden\n");
+ ok(check_ini_contents(path, TRUE), "Expected ini contents to match\n");
+ ok(DeleteFileA(path), "Expected path to exist\n");
lstrcpyA(path, CURR_DIR);
lstrcatA(path, "\\backup\\basename.INI");
@@ -185,12 +182,9 @@
CreateDirectoryA("backup", NULL);
res = pAddDelBackupEntry("one\0two\0three", "backup", "basename", AADBE_ADD_ENTRY);
ok(res == S_OK, "Expected S_OK, got %ld\n", res);
- todo_wine
- {
- ok(check_ini_file_attr(path), "Expected ini file to be hidden\n");
- ok(check_ini_contents(path, TRUE), "Expected ini contents to match\n");
- ok(DeleteFileA(path), "Expected path to exist\n");
- }
+ ok(check_ini_file_attr(path), "Expected ini file to be hidden\n");
+ ok(check_ini_contents(path, TRUE), "Expected ini contents to match\n");
+ ok(DeleteFileA(path), "Expected path to exist\n");
RemoveDirectoryA("backup");
lstrcpyA(path, "c:\\windows\\basename.INI");
@@ -198,21 +192,15 @@
/* try a NULL backup dir, INI is created in c:\windows */
res = pAddDelBackupEntry("one\0two\0three", NULL, "basename", AADBE_ADD_ENTRY);
ok(res == S_OK, "Expected S_OK, got %ld\n", res);
- todo_wine
- {
- ok(check_ini_contents(path, TRUE), "Expected ini contents to match\n");
- }
+ ok(check_ini_contents(path, TRUE), "Expected ini contents to match\n");
/* remove the entries with AADBE_DEL_ENTRY */
SetFileAttributesA(path, FILE_ATTRIBUTE_NORMAL);
res = pAddDelBackupEntry("one\0three", NULL, "basename", AADBE_DEL_ENTRY);
SetFileAttributesA(path, FILE_ATTRIBUTE_NORMAL);
ok(res == S_OK, "Expected S_OK, got %ld\n", res);
- todo_wine
- {
- ok(check_ini_contents(path, FALSE), "Expected ini contents to match\n");
- ok(DeleteFileA(path), "Expected path to exist\n");
- }
+ ok(check_ini_contents(path, FALSE), "Expected ini contents to match\n");
+ ok(DeleteFileA(path), "Expected path to exist\n");
}
/* the FCI callbacks */