@Override public long save(Coll<?> coll, String id, JsonElement data) { File file = fileFromId(coll, id); String content = coll.getGson().toJson(data); if (DiscUtil.writeCatch(file, content) == false) return 0; return file.lastModified(); }
public JsonElement loadFileJson(File file) { String content = DiscUtil.readCatch(file); if (content == null) return null; content = content.trim(); if (content.length() == 0) return null; return new JsonParser().parse(content); }
@Override public boolean dropDb(Db db) { if (!(db instanceof DbFlatfile)) throw new IllegalArgumentException("db"); DbFlatfile dbFlatfile = (DbFlatfile) db; try { return DiscUtil.deleteRecursive(dbFlatfile.directory); } catch (Exception e) { return false; } }