From f577ff3449951c4b4dbeb4bc69518efbf7774f3e Mon Sep 17 00:00:00 2001 From: Oleg Krasilnikov Date: Tue, 17 Apr 2007 10:41:31 +0000 Subject: [PATCH] Bug #179786 C/C++ Project data serialization silently fails for files with the "hidden" status --- .../model/CProjectDescriptionManager.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java index 0da711d1e6d..08f90caf178 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java @@ -1332,7 +1332,6 @@ public class CProjectDescriptionManager { if (projectFile.exists()) { if (projectFile.isReadOnly()) { - // Inform Eclipse that we are intending to modify this file // This will provide the user the opportunity, via UI prompts, to fetch the file from source code control // reset a read-only file protection to write etc. @@ -1353,7 +1352,20 @@ public class CProjectDescriptionManager { //} //} } - projectFile.setContents(new ByteArrayInputStream(utfString.getBytes("UTF-8")), IResource.FORCE, new NullProgressMonitor()); //$NON-NLS-1$ + try { + projectFile.setContents(new ByteArrayInputStream(utfString.getBytes("UTF-8")), IResource.FORCE, new NullProgressMonitor()); //$NON-NLS-1$ + } catch (CoreException e) { + if (projectFile.getLocation().toFile().isHidden()) { + String os = System.getProperty("os.name"); //$NON-NLS-1$ + if (os != null && os.startsWith("Win")) { //$NON-NLS-1$ + projectFile.delete(true, null); + projectFile.create(new ByteArrayInputStream(utfString.getBytes("UTF-8")), IResource.FORCE, new NullProgressMonitor()); //$NON-NLS-1$ + CCorePlugin.log(e.getLocalizedMessage() + + "\n** Error occured because of file status ." + //$NON-NLS-1$ + "\n** This status is disabled now, to allow writing."); //$NON-NLS-1$ + } else throw(e); + } else throw(e); + } } else { projectFile.create(new ByteArrayInputStream(utfString.getBytes("UTF-8")), IResource.FORCE, new NullProgressMonitor()); //$NON-NLS-1$ }