From 00ca1279881e5f76c63e7efe32ab5de39f4e23a5 Mon Sep 17 00:00:00 2001 From: "sspitzer%mozilla.org" Date: Sat, 20 Jan 2007 01:28:33 +0000 Subject: [PATCH] supplimental fix for bug #364599: some newly created profile files are write protected, for example bookmarks.html in addtion to fixing the permissions of bookmarks.html, we need to fix the permissions of the bookmark.html.moztmp file, otherwise we'll still fail to modify bookmarks. r=dveditz git-svn-id: svn://10.0.0.236/trunk@218692 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/xpcom/io/nsLocalFileWin.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/mozilla/xpcom/io/nsLocalFileWin.cpp b/mozilla/xpcom/io/nsLocalFileWin.cpp index aa5b8826b27..661279b0583 100644 --- a/mozilla/xpcom/io/nsLocalFileWin.cpp +++ b/mozilla/xpcom/io/nsLocalFileWin.cpp @@ -1441,10 +1441,19 @@ nsLocalFile::CopySingleFile(nsIFile *sourceFile, nsIFile *destParent, backup.Append(destPath); backup.Append(L".moztmp"); + // we are about to remove the .moztmp file, + // so attempt to make sure the file is writable + // (meaning: the "read only" attribute is not set) + // _wchmod can silently fail (return -1) if + // the file doesn't exist but that's ok, because + // _wremove() will also silently fail if the file + // doesn't exist. + (void)_wchmod(backup.get(), _S_IREAD | _S_IWRITE); + // remove any existing backup file that we may already have. // maybe we should be doing some kind of unique naming here, // but why bother. - _wremove(backup.get()); + (void)_wremove(backup.get()); // move destination file to backup file copyOK = ::MoveFileW(destPath.get(), backup.get());