Community
Participate
Working Groups
If a TextFileChange is invoked which changes a non-existent file, then an underlying bug in org.eclipse.core.filebuffers means a file will be created outside the workspace. (See bug 118199, which incompletely describes the issue -- it's not just that java.io.File writes the file, but that the workspace-relative path is used as an absolute path.) It looks like a workaround (in TextFileChange) could be either to throw a CoreException from #acquireDocument if a file doesn't exist yet (thus indicating that you shouldn't "change" a nonexistent file), or check for file non-existence and compensate for the bug by passing a resolved filesystem IPath to the IFileBufferManager APIs that take IPath. I noticed that NLSPropertyFileModifier seems to avoid this with a custom CreateTextFileChange() when the target file does not exist. Was that another workaround for this?
BTW, there's a simpler workaround (though it's not undoable), along the lines of: TextFileChange tfc = new TextFileChange(...) { protected IDocument acquireDocument(IProgressMonitor pm) throws CoreException { if (!getFile().exists()) { getFile().create(new ByteArrayInputStream(new byte[0]), false, pm); } return super.acquireDocument(pm); } };
I don't think should implement workarounds, but wait for a better solution by the IFileBufferManager along the lines of bug 118199 comment 2
As of now 'LATER' and 'REMIND' resolutions are no longer supported. Please reopen this bug if it is still valid for you.