}
File backup = determineBackupName(dest);
boolean backupCreated = backup != null && dest.renameTo(backup);
FileOutputStream fwrite = null;
try {
try {
MacCompatibility.setFileCreatorAndType(dest, "LGSM", "circ");
} catch (IOException e) { }
fwrite = new FileOutputStream(dest);
file.write(fwrite, this);
file.setName(toProjectName(dest));
File oldFile = getMainFile();
setMainFile(dest);
LibraryManager.instance.fileSaved(this, dest, oldFile, file);
} catch (IOException e) {
if (backupCreated) recoverBackup(backup, dest);
if (dest.exists() && dest.length() == 0) dest.delete();
JOptionPane.showMessageDialog(parent,
StringUtil.format(Strings.get("fileSaveError"),
e.toString()),
Strings.get("fileSaveErrorTitle"),
JOptionPane.ERROR_MESSAGE);
return false;
} finally {
if (fwrite != null) {
try {
fwrite.close();
} catch (IOException e) {
if (backupCreated) recoverBackup(backup, dest);
if (dest.exists() && dest.length() == 0) dest.delete();
JOptionPane.showMessageDialog(parent,
StringUtil.format(Strings.get("fileSaveCloseError"),