예제 #1
0
 @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();
 }
예제 #2
0
  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);
  }
예제 #3
0
  @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;
    }
  }