James Hawkins : advpack: Implement AddDelBackupEntry.

Alexandre Julliard julliard at wine.codeweavers.com
Tue Feb 21 05:04:25 CST 2006


Module: wine
Branch: refs/heads/master
Commit: 2aa6e2ebd96a34575292a3b02ff8c0cc4d9f059c
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=2aa6e2ebd96a34575292a3b02ff8c0cc4d9f059c

Author: James Hawkins <truiken at gmail.com>
Date:   Mon Feb 20 21:49:27 2006 -0600

advpack: Implement AddDelBackupEntry.

---

 dlls/advpack/files.c       |   39 +++++++++++++++++++++++++++++++++++----
 dlls/advpack/tests/files.c |   30 +++++++++---------------------
 2 files changed, 44 insertions(+), 25 deletions(-)

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 @@ WINE_DEFAULT_DEBUG_CHANNEL(advpack);
  * 
  *   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 @@ static void test_AddDelBackupEntry()
     /* 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 @@ static void test_AddDelBackupEntry()
     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 @@ static void test_AddDelBackupEntry()
     /* 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 */




More information about the wine-cvs mailing list