@Override public OutputStream newOutputStream(boolean append) throws IOException { try { File file = new File(name); File parent = file.getParentFile(); if (parent != null) { FileUtils.createDirectories(parent.getAbsolutePath()); } FileOutputStream out = new FileOutputStream(name, append); IOUtils.trace("openFileOutputStream", name, out); return out; } catch (IOException e) { freeMemoryAndFinalize(); return new FileOutputStream(name); } }
RedoLog(Map<String, String> config) { this.config = config; if (config.containsKey("log_chunk_size")) logChunkSize = Long.parseLong(config.get("log_chunk_size")); else logChunkSize = DEFAULT_LOG_CHUNK_SIZE; String baseDir = config.get("base_dir"); String logDir = config.get("redo_log_dir"); String storagePath = baseDir + File.separator + logDir; config.put("storagePath", storagePath); if (!FileUtils.exists(storagePath)) FileUtils.createDirectories(storagePath); List<Integer> ids = getAllChunkIds(); int lastId; if (!ids.isEmpty()) lastId = ids.get(ids.size() - 1); else lastId = 0; currentChunk = new RedoLogChunk(lastId, config); }
@Override public FilePath createTempFile(String suffix, boolean deleteOnExit, boolean inTempDir) throws IOException { String fileName = name + "."; String prefix = new File(fileName).getName(); File dir; if (inTempDir) { dir = new File(System.getProperty("java.io.tmpdir", ".")); } else { dir = new File(fileName).getAbsoluteFile().getParentFile(); } FileUtils.createDirectories(dir.getAbsolutePath()); while (true) { File f = new File(dir, prefix + getNextTempFileNamePart(false) + suffix); if (f.exists() || !f.createNewFile()) { // in theory, the random number could collide getNextTempFileNamePart(true); continue; } if (deleteOnExit) { try { f.deleteOnExit(); } catch (Throwable e) { // sometimes this throws a NullPointerException // at java.io.DeleteOnExitHook.add(DeleteOnExitHook.java:33) // we can ignore it } } return get(f.getCanonicalPath()); } }
if (packageName != null) { dir = new File(dir, packageName.replace('.', '/')); FileUtils.createDirectories(dir.getAbsolutePath());
AOStorage(Map<String, Object> config) { super(config); this.db = (IDatabase) config.get("db"); String storagePath = getStoragePath(); DataUtils.checkArgument(storagePath != null, "The storage path may not be null"); if (!FileUtils.exists(storagePath)) FileUtils.createDirectories(storagePath); FilePath dir = FilePath.get(storagePath); for (FilePath fp : dir.newDirectoryStream()) { String mapFullName = fp.getName(); if (mapFullName.startsWith(TEMP_NAME_PREFIX)) { fp.delete(); } } }
private boolean openWriter() { if (printWriter == null) { try { FileUtils.createDirectories(FileUtils.getParent(fileName)); if (FileUtils.exists(fileName) && !FileUtils.canWrite(fileName)) { // read only database: don't log error if the trace file // can't be opened return false; } fileWriter = IOUtils.getBufferedWriter(FileUtils.newOutputStream(fileName, true)); printWriter = new PrintWriter(fileWriter, true); } catch (Exception e) { logWritingError(e); return false; } } return true; }
/** * Create the directory and all required parent directories. * * @param dir the directory name */ public static void createDirectories(String dir) { if (dir != null) { if (exists(dir)) { if (!isDirectory(dir)) { // this will fail createDirectory(dir); } } else { String parent = getParent(dir); createDirectories(parent); createDirectory(dir); } } }
mode = "r"; } else { FileUtils.createDirectories(FileUtils.getParent(name));
FileUtils.createDirectories(btreeStoragePath); else { for (int id : getAllChunkIds()) {