b=477727; WinCE doesn't have DELETE_ON_CLOSE; r=dougt
authorVladimir Vukicevic <vladimir@pobox.com>
Tue, 10 Feb 2009 15:10:08 -0800
changeset 24898 cb3832f7c448d77f89f2d40c471a94507b5cbad1
parent 24897 0ce096d6b9dfcfa360d94123c9a5a1455bd39b9f
child 24899 4151690668c7554aa7c78212508df13a2000c44b
push idunknown
push userunknown
push dateunknown
reviewersdougt
bugs477727
milestone1.9.2a1pre
b=477727; WinCE doesn't have DELETE_ON_CLOSE; r=dougt
profile/dirserviceprovider/src/nsProfileLock.cpp
--- a/profile/dirserviceprovider/src/nsProfileLock.cpp
+++ b/profile/dirserviceprovider/src/nsProfileLock.cpp
@@ -568,22 +568,33 @@ nsresult nsProfileLock::Lock(nsILocalFil
         rv = LockWithSymlink(oldFilePath, PR_FALSE);
     }
 
 #elif defined(XP_WIN)
     nsAutoString filePath;
     rv = lockFile->GetPath(filePath);
     if (NS_FAILED(rv))
         return rv;
+#ifdef WINCE
+    // WinCE doesn't have FILE_FLAG_DELETE_ON_CLOSE, so let's just try
+    // to delete the file first before creating it.  This will fail
+    // if it's already open.
+    DeleteFileW(filePath.get());
+#endif
+
     mLockFileHandle = CreateFileW(filePath.get(),
                                   GENERIC_READ | GENERIC_WRITE,
                                   0, // no sharing - of course
                                   nsnull,
                                   OPEN_ALWAYS,
+#ifndef WINCE
                                   FILE_FLAG_DELETE_ON_CLOSE,
+#else
+                                  FILE_ATTRIBUTE_NORMAL,
+#endif
                                   nsnull);
     if (mLockFileHandle == INVALID_HANDLE_VALUE) {
         // XXXbsmedberg: provide a profile-unlocker here!
         return NS_ERROR_FILE_ACCESS_DENIED;
     }
 #elif defined(XP_OS2)
     nsCAutoString filePath;
     rv = lockFile->GetNativePath(filePath);