Ejemplo n.º 1
0
  /** Closes the source file and deletes it if it is not read-only. */
  void purge() throws HsqlException {

    if (rFile == null) {
      return;
    }

    try {
      if (readOnly) {
        close();
      } else {
        rFile.close();

        rFile = null;

        FileUtil.delete(sName);
      }
    } catch (Exception e) {
      throw Trace.error(
          Trace.FILE_IO_ERROR, Trace.TextCache_purging_file_error, new Object[] {sName, e});
    }
  }
Ejemplo n.º 2
0
  /**
   * Writes newly created rows to disk. In the current implentation, such rows have already been
   * saved, so this method just removes a source file that has no rows.
   */
  void close() throws HsqlException {

    if (rFile == null) {
      return;
    }

    try {
      saveAll();

      boolean empty = (rFile.length() <= NL.length());

      rFile.close();

      rFile = null;

      if (empty && !readOnly) {
        FileUtil.delete(sName);
      }
    } catch (Exception e) {
      throw Trace.error(
          Trace.FILE_IO_ERROR, Trace.TextCache_closing_file_error, new Object[] {sName, e});
    }
  }