1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-17 22:15:23 +02:00

[199854] Fix regressions in unit tests

This commit is contained in:
Martin Oberhuber 2008-05-07 06:40:17 +00:00
parent 2699735729
commit e00d3e5182
2 changed files with 35 additions and 19 deletions

View file

@ -875,24 +875,21 @@ public class LocalFileService extends AbstractFileService implements ILocalServi
try try
{ {
fileToCreate.createNewFile(); fileToCreate.createNewFile();
if (ArchiveHandlerManager.getInstance().isArchive(fileToCreate)) }
catch (IOException e)
{ {
throw new RemoteFileSecurityException(e);
}
if (ArchiveHandlerManager.getInstance().isArchive(fileToCreate)) {
try { try {
ArchiveHandlerManager.getInstance().createEmptyArchive(fileToCreate); ArchiveHandlerManager.getInstance().createEmptyArchive(fileToCreate);
} catch (SystemMessageException e) { } catch (SystemMessageException e) {
SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID, SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID, ILocalMessageIds.FILEMSG_ARCHIVE_CORRUPTED, IStatus.ERROR,
ILocalMessageIds.FILEMSG_ARCHIVE_CORRUPTED,
IStatus.ERROR,
LocalServiceResources.FILEMSG_ARCHIVE_CORRUPTED, e); LocalServiceResources.FILEMSG_ARCHIVE_CORRUPTED, e);
throw new SystemMessageException(msg); throw new SystemMessageException(msg);
} }
} }
} }
catch (Exception e)
{
throw new RemoteFileSecurityException(e);
}
}
} }
else else
{ {
@ -1195,6 +1192,7 @@ public class LocalFileService extends AbstractFileService implements ILocalServi
// for 192705, we need to throw an exception when rename fails // for 192705, we need to throw an exception when rename fails
String msgTxt = NLS.bind(LocalServiceResources.FILEMSG_RENAME_FILE_FAILED, child.fullName); String msgTxt = NLS.bind(LocalServiceResources.FILEMSG_RENAME_FILE_FAILED, child.fullName);
//String msgDetails = LocalServiceResources.FILEMSG_RENAME_FILE_FAILED_DETAILS; //String msgDetails = LocalServiceResources.FILEMSG_RENAME_FILE_FAILED_DETAILS;
e.printStackTrace();
throw new SystemMessageException(new SimpleSystemMessage(Activator.PLUGIN_ID, throw new SystemMessageException(new SimpleSystemMessage(Activator.PLUGIN_ID,
ILocalMessageIds.FILEMSG_RENAME_FILE_FAILED, ILocalMessageIds.FILEMSG_RENAME_FILE_FAILED,
IStatus.ERROR, IStatus.ERROR,
@ -1413,6 +1411,7 @@ public class LocalFileService extends AbstractFileService implements ILocalServi
IStatus.ERROR, IStatus.ERROR,
msgTxt, e)); msgTxt, e));
} }
return true;
} }
if (null != monitor) if (null != monitor)

View file

@ -124,7 +124,19 @@ public class SystemZipHandler implements ISystemArchiveHandler
{ {
_file = file; _file = file;
_vfsLastModified = _file.lastModified(); _vfsLastModified = _file.lastModified();
if (openZipFile())
//ignore error opening non-existing zipfile in constructor,
//because we might want to be creating the zipfile
boolean zipFileOpen = false;
if (_file.exists()) {
try {
openZipFile();
zipFileOpen = true;
} catch (IOException e) {
// ignore
}
}
if (zipFileOpen)
{ {
buildTree(); buildTree();
closeZipFile(); closeZipFile();
@ -1678,8 +1690,12 @@ public class SystemZipHandler implements ISystemArchiveHandler
String oldName = _file.getAbsolutePath(); String oldName = _file.getAbsolutePath();
_zipfile.close(); _zipfile.close();
File oldFile = new File(oldName + "old"); //$NON-NLS-1$ File oldFile = new File(oldName + "old"); //$NON-NLS-1$
System.out.println(_file.renameTo(oldFile)); if (!_file.renameTo(oldFile)) {
System.out.println(outputTempFile.renameTo(_file)); throw new IOException("Failed to rename " + oldFile); //$NON-NLS-1$
}
if (!outputTempFile.renameTo(_file)) {
throw new IOException("Failed to rename " + _file); //$NON-NLS-1$
}
_vfsLastModified = _file.lastModified(); _vfsLastModified = _file.lastModified();
_zipfile = new ZipFile(_file); _zipfile = new ZipFile(_file);
oldFile.delete(); oldFile.delete();
@ -2114,11 +2130,12 @@ public class SystemZipHandler implements ISystemArchiveHandler
if (i == -1) if (i == -1)
{ {
fullRename(fullVirtualName, newName, archiveOperationMonitor); fullRename(fullVirtualName, newName, archiveOperationMonitor);
} } else {
String fullNewName = fullVirtualName.substring(0, i+1) + newName; String fullNewName = fullVirtualName.substring(0, i+1) + newName;
fullRename(fullVirtualName, fullNewName, archiveOperationMonitor); fullRename(fullVirtualName, fullNewName, archiveOperationMonitor);
setArchiveOperationMonitorStatusDone(archiveOperationMonitor); setArchiveOperationMonitorStatusDone(archiveOperationMonitor);
} }
}
/* (non-Javadoc) /* (non-Javadoc)