Michael Karcher : kernel32: Fix profile sharing mode.

Alexandre Julliard julliard at winehq.org
Mon Aug 18 10:46:59 CDT 2008


Module: wine
Branch: master
Commit: 33ca67dcab8e99d2fddbd2d3a11d73b21ba0ef41
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=33ca67dcab8e99d2fddbd2d3a11d73b21ba0ef41

Author: Michael Karcher <wine at mkarcher.dialup.fu-berlin.de>
Date:   Sun Aug 17 19:03:14 2008 +0200

kernel32: Fix profile sharing mode.

Based on a patch from Austin English.

---

 dlls/kernel32/profile.c       |    2 +-
 dlls/kernel32/tests/profile.c |   22 ++++++++++++++++++++++
 2 files changed, 23 insertions(+), 1 deletions(-)

diff --git a/dlls/kernel32/profile.c b/dlls/kernel32/profile.c
index 74622ad..ac983ff 100644
--- a/dlls/kernel32/profile.c
+++ b/dlls/kernel32/profile.c
@@ -755,7 +755,7 @@ static BOOL PROFILE_Open( LPCWSTR filename, BOOL write_access )
     TRACE("path: %s\n", debugstr_w(buffer));
 
     hFile = CreateFileW(buffer, GENERIC_READ | (write_access ? GENERIC_WRITE : 0),
-                        FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
+                        FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL,
                         OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
 
     if ((hFile == INVALID_HANDLE_VALUE) && (GetLastError() != ERROR_FILE_NOT_FOUND))
diff --git a/dlls/kernel32/tests/profile.c b/dlls/kernel32/tests/profile.c
index 2ea3955..47b1ac1 100644
--- a/dlls/kernel32/tests/profile.c
+++ b/dlls/kernel32/tests/profile.c
@@ -348,6 +348,27 @@ static void test_profile_existing(void)
     ok( DeleteFile(testfile2), "delete failed\n" );
 }
 
+static void test_profile_delete_on_close()
+{
+    static CHAR testfile[] = ".\\testwine5.ini";
+    HANDLE h;
+    DWORD size, res;
+    static const char contents[] = "[" SECTION "]\n" KEY "=123\n";
+
+    h = CreateFile(testfile, GENERIC_WRITE, FILE_SHARE_READ, NULL,
+                    CREATE_ALWAYS, FILE_FLAG_DELETE_ON_CLOSE, NULL);
+    ok( WriteFile( h, contents, sizeof contents - 1, &size, NULL ),
+                    "Cannot write test file: %x\n", GetLastError() );
+    ok( size == sizeof contents - 1, "Test file: partial write\n");
+
+    res = GetPrivateProfileInt(SECTION, KEY, 0, testfile);
+
+    ok( res == 123, "Got %d instead of 123\n", res);
+
+    /* This also deletes the file */
+    CloseHandle(h);
+}
+
 static void create_test_file(LPCSTR name, LPCSTR data, DWORD size)
 {
     HANDLE hfile;
@@ -615,5 +636,6 @@ START_TEST(profile)
     test_profile_sections();
     test_profile_sections_names();
     test_profile_existing();
+    test_profile_delete_on_close();
     test_GetPrivateProfileString();
 }




More information about the wine-cvs mailing list