* @exception CannotWriteException
* if anything went wrong
*/
public synchronized void delete(AudioFile f) throws CannotWriteException {
if (!f.canWrite())
throw new CannotWriteException("Can't write to file \""
+ f.getAbsolutePath() + "\"");
if (f.length() <= 150)
throw new CannotWriteException("Less than 150 byte \""
+ f.getAbsolutePath() + "\"");
RandomAccessFile raf = null;
RandomAccessFile rafTemp = null;
File tempF = null;
// Will be set to true on VetoException, causing the finally block to
// discard
// the tempfile.
boolean revert = false;
try {
tempF = File.createTempFile("entagged", ".tmp", f.getParentFile());
rafTemp = new RandomAccessFile(tempF, "rw");
raf = new RandomAccessFile(f, "rw");
raf.seek(0);
rafTemp.seek(0);
try {
if (this.modificationListener != null) {
this.modificationListener.fileWillBeModified(f, true);
}
deleteTag(raf, rafTemp);
if (this.modificationListener != null) {
this.modificationListener.fileModified(f, tempF);
}
} catch (ModifyVetoException veto) {
throw new CannotWriteException(veto);
}
} catch (Exception e) {
revert = true;
throw new CannotWriteException("\"" + f.getAbsolutePath() + "\" :"
+ e, e);
} finally {
// will be set to the remaining file.
File result = f;
try {