+ /**
+ * Delete the given {@link Story} from this {@link Library}.
+ *
+ * @param luid
+ * the LUID of the target {@link Story}
+ *
+ * @return TRUE if it was deleted
+ */
+ public synchronized boolean delete(String luid) {
+ boolean ok = false;
+
+ MetaData meta = getInfo(luid);
+ File file = getStories(null).get(meta);
+
+ if (file != null) {
+ if (file.delete()) {
+ String readerExt = getOutputType(meta)
+ .getDefaultExtension(true);
+ String fileExt = getOutputType(meta).getDefaultExtension(false);
+
+ String path = file.getAbsolutePath();
+ if (readerExt != null && !readerExt.equals(fileExt)) {
+ path = path
+ .substring(0, path.length() - readerExt.length())
+ + fileExt;
+ file = new File(path);
+ IOUtils.deltree(file);
+ }
+
+ File infoFile = new File(path + ".info");
+ if (!infoFile.exists()) {
+ infoFile = new File(path.substring(0, path.length()
+ - fileExt.length())
+ + ".info");
+ }
+ infoFile.delete();
+
+ String coverExt = "."
+ + Instance.getConfig().getString(
+ Config.IMAGE_FORMAT_COVER);
+ File coverFile = new File(path + coverExt);
+ if (!coverFile.exists()) {
+ coverFile = new File(path.substring(0, path.length()
+ - fileExt.length()));
+ }
+ coverFile.delete();
+
+ ok = true;
+ }
+
+ // clear cache
+ stories.clear();
+ }
+
+ return ok;
+ }
+