public void close() throws SQLException { try { reader.close(); } catch (IOException e) { throw Message.convertIOException(e, null); } }
private int read() throws SQLException { try { return reader.read(); } catch (IOException e) { throw Message.convertIOException(e, null); } }
public String normalize(String fileName) throws SQLException { fileName = translateFileName(fileName); File f = new File(fileName); try { return f.getCanonicalPath(); } catch (IOException e) { throw Message.convertIOException(e, fileName); } }
public String createTempFile() throws SQLException { try { return FileUtils.createTempFile(databaseName, Constants.SUFFIX_TEMP_FILE, true, false); } catch (IOException e) { throw Message.convertIOException(e, databaseName); } }
public String createTempFile() throws SQLException { try { boolean inTempDir = readOnly; String name = databaseName; if (!persistent) { name = FileSystem.MEMORY_PREFIX + name; } return FileUtils.createTempFile(name, Constants.SUFFIX_TEMP_FILE, true, inTempDir); } catch (IOException e) { throw Message.convertIOException(e, databaseName); } }
public String[] listFiles(String path) throws SQLException { path = translateFileName(path); File f = new File(path); try { String[] list = f.list(); if (list == null) { return new String[0]; } String base = f.getCanonicalPath(); if (!base.endsWith(File.separator)) { base += File.separator; } for (int i = 0; i < list.length; i++) { list[i] = base + list[i]; } return list; } catch (IOException e) { throw Message.convertIOException(e, path); } }
void process(String url, String user, String password, String fileName, String charsetName, boolean continueOnError) throws SQLException { try { org.h2.Driver.load(); Connection conn = DriverManager.getConnection(url, user, password); if (charsetName == null) { charsetName = Constants.UTF8; } try { process(conn, fileName, continueOnError, charsetName); } finally { conn.close(); } } catch (IOException e) { throw Message.convertIOException(e, fileName); } }
public long getFilePointer() throws SQLException { if (SysProperties.CHECK2) { try { if (file.getFilePointer() != filePos) { throw Message.getInternalError(); } } catch (IOException e) { throw Message.convertIOException(e, name); } } return filePos; }
public byte[] getBytesNoCopy() throws SQLException { if (small != null) { return small; } try { return IOUtils.readBytesAndClose(getInputStream(), Integer.MAX_VALUE); } catch (IOException e) { throw Message.convertIOException(e, fileName); } }
public OutputStream openFileOutputStream(String fileName, boolean append) throws SQLException { try { return new FileObjectOutputStream(openFileObject(fileName, "rw"), append); } catch (IOException e) { throw Message.convertIOException(e, fileName); } }
public void seek(long pos) throws SQLException { if (SysProperties.CHECK && pos % Constants.FILE_BLOCK_SIZE != 0) { throw Message.getInternalError("unaligned seek " + name + " pos " + pos); } try { if (pos != filePos) { file.seek(pos); filePos = pos; } } catch (IOException e) { throw Message.convertIOException(e, name); } }
public OutputStream openFileOutputStream(String fileName, boolean append) throws SQLException { fileName = translateFileName(fileName); try { File file = new File(fileName); createDirs(file.getAbsolutePath()); FileOutputStream out = new FileOutputStream(fileName, append); trace("openFileOutputStream", fileName, out); return out; } catch (IOException e) { freeMemoryAndFinalize(); try { return new FileOutputStream(fileName); } catch (IOException e2) { throw Message.convertIOException(e, fileName); } } }
public OutputStream openFileOutputStream(String fileName, boolean append) throws SQLException { try { FileObjectMemory obj = getMemoryFile(fileName); obj.seek(0); return new FileObjectOutputStream(obj, append); } catch (IOException e) { throw Message.convertIOException(e, fileName); } }
public void copy(String original, String copy) throws SQLException { try { OutputStream out = openFileOutputStream(copy, false); InputStream in = openFileInputStream(original); IOUtils.copyAndClose(in, out); } catch (IOException e) { throw Message.convertIOException(e, "Can not copy " + original + " to " + copy); } }
public void delete() throws SQLException { synchronized (database) { try { cache.clear(); file.close(); FileUtils.delete(fileName); } catch (IOException e) { throw Message.convertIOException(e, fileName); } finally { file = null; fileName = null; } } }
public void copy(String original, String copy) throws SQLException { try { OutputStream out = openFileOutputStream(copy, false); InputStream in = openFileInputStream(original); IOUtils.copyAndClose(in, out); } catch (IOException e) { rollback(); throw Message.convertIOException(e, "Can not copy " + original + " to " + copy); } }
public void readFully(byte[] b, int off, int len) throws SQLException { if (SysProperties.CHECK && len < 0) { throw Message.getInternalError("read len " + len); } if (SysProperties.CHECK && len % Constants.FILE_BLOCK_SIZE != 0) { throw Message.getInternalError("unaligned read " + name + " len " + len); } checkPowerOff(); try { file.readFully(b, off, len); } catch (IOException e) { throw Message.convertIOException(e, name); } filePos += len; }
protected FileStore(DataHandler handler, String name, String mode, byte[] magic) throws SQLException { FileSystem fs = FileSystem.getInstance(name); this.handler = handler; this.name = name; this.magic = magic; this.mode = mode; try { fs.createDirs(name); if (fs.exists(name) && !fs.canWrite(name)) { mode = "r"; this.mode = mode; } file = fs.openFileObject(name, mode); if (mode.length() > 2) { synchronousMode = true; } fileLength = file.length(); } catch (IOException e) { throw Message.convertIOException(e, "name: " + name + " mode: " + mode); } }
public void reset() throws SQLException { rowId = -1; currentRow = null; if (session == null) { return; } synchronized (session) { session.checkClosed(); try { session.traceOperation("RESULT_RESET", id); transfer.writeInt(SessionRemote.RESULT_RESET).writeInt(id).flush(); } catch (IOException e) { throw Message.convertIOException(e, null); } } }
public FileStoreInputStream(FileStore store, DataHandler handler, boolean compression, boolean alwaysClose) throws SQLException { this.store = store; this.alwaysClose = alwaysClose; if (compression) { compress = CompressTool.getInstance(); } page = DataPage.create(handler, Constants.FILE_BLOCK_SIZE); try { if (store.length() <= FileStore.HEADER_LENGTH) { close(); } else { fillBuffer(); } } catch (IOException e) { throw Message.convertIOException(e, store.name); } }