List of usage examples for org.apache.commons.io FileUtils sizeOfDirectory
public static long sizeOfDirectory(File directory)
From source file:org.opencastproject.archive.storage.FileSystemElementStore.java
@Override public Option<Long> getUsedSpace() { return Option.some(FileUtils.sizeOfDirectory(new File(rootDirectory))); }
From source file:org.opencastproject.episode.filesystem.FileSystemElementStore.java
public Option<Long> getUsedSpace() { return Option.some(FileUtils.sizeOfDirectory(new File(rootDirectory))); }
From source file:org.opencastproject.workingfilerepository.impl.WorkingFileRepositoryImpl.java
/** * {@inheritDoc}//from w w w . ja v a 2s. c o m * * @see org.opencastproject.workingfilerepository.api.WorkingFileRepository#getUsedSpace() */ @Override public Option<Long> getUsedSpace() { return Option.some(FileUtils.sizeOfDirectory(new File(rootDirectory))); }
From source file:org.opencastproject.workspace.impl.WorkspaceImpl.java
/** * {@inheritDoc}/*from w w w. j a va 2s. c o m*/ * * @see org.opencastproject.workspace.api.Workspace#getUsedSpace() */ @Override public Option<Long> getUsedSpace() { return Option.some(FileUtils.sizeOfDirectory(new File(wsRoot))); }
From source file:org.openmicroscopy.shoola.agents.fsimporter.chooser.FileElement.java
/** * Returns the length of the file//from ww w .j a v a 2s .co m * * @return See above. */ long getFileLength() { if (length > 0) return length; if (file.isFile()) { length = file.length(); } else { length = FileUtils.sizeOfDirectory(file); //determineLength(file, ImporterAgent.getScanningDepth(), 0); } return length; }
From source file:org.openmicroscopy.shoola.env.data.model.FileObject.java
/** * Returns the size of the file//from w w w.j a v a 2 s . c om * * @return See above. */ public long getLength() { File f; if (file instanceof File) { f = (File) file; if (f.isFile()) return f.length(); return FileUtils.sizeOfDirectory(f); } else if (file instanceof ImagePlus) { f = getTrueFile(); if (f != null) return f.length(); } return 0; }
From source file:org.openmrs.module.dhisconnector.api.impl.DHISConnectorServiceImpl.java
@Override public String uploadDHIS2APIBackup(MultipartFile dhis2APIBackup) { String msg = ""; String outputFolder = OpenmrsUtil.getApplicationDataDirectory() + DHISCONNECTOR_TEMP_FOLDER; File temp = new File(outputFolder); File dhis2APIBackupRootDir = new File( OpenmrsUtil.getApplicationDataDirectory() + DHISCONNECTOR_DHIS2BACKUP_FOLDER); if (!temp.exists()) { temp.mkdirs();/*from w w w .j av a 2s . co m*/ } File dest = new File(outputFolder + File.separator + dhis2APIBackup.getOriginalFilename()); if (!dhis2APIBackup.isEmpty() && dhis2APIBackup.getOriginalFilename().endsWith(".zip")) { try { dhis2APIBackup.transferTo(dest); if (dest.exists() && dest.isFile()) { File unzippedAt = new File(outputFolder + File.separator + "api"); File api = new File(dhis2APIBackupRootDir.getPath() + File.separator + "api"); unZipDHIS2APIBackupToTemp(dest.getCanonicalPath()); if ((new File(outputFolder)).list().length > 0 && unzippedAt.exists()) { if (!dhis2APIBackupRootDir.exists()) { dhis2APIBackupRootDir.mkdirs(); } if (FileUtils.sizeOfDirectory(dhis2APIBackupRootDir) > 0 && unzippedAt.exists() && unzippedAt.isDirectory()) { if (checkIfDirContainsFile(dhis2APIBackupRootDir, "api")) { FileUtils.deleteDirectory(api); api.mkdir(); msg = Context.getMessageSourceService() .getMessage("dhisconnector.dhis2backup.replaceSuccess"); } else { msg = Context.getMessageSourceService() .getMessage("dhisconnector.dhis2backup.import.success"); } FileUtils.copyDirectory(unzippedAt, api); FileUtils.deleteDirectory(temp); } } } } catch (IllegalStateException e) { msg = Context.getMessageSourceService().getMessage("dhisconnector.dhis2backup.failure"); e.printStackTrace(); } catch (IOException e) { msg = Context.getMessageSourceService().getMessage("dhisconnector.dhis2backup.failure"); e.printStackTrace(); } } else { msg = Context.getMessageSourceService().getMessage("dhisconnector.dhis2backup.failure"); } return msg; }
From source file:org.polymap.core.runtime.recordstore.lucene.LuceneRecordStore.java
/** * Creates a new store for the given filesystem directory. * /*from w w w .j a va 2 s . c o m*/ * @param indexDir The directory to hold the store files. * @param clean * @throws IOException */ public LuceneRecordStore(File indexDir, boolean clean) throws IOException { if (!indexDir.exists()) { indexDir.mkdirs(); } directory = null; // limit mmap memory to 1GB // seems that bigger mmap indexes slow down performance long dbSize = FileUtils.sizeOfDirectory(indexDir); long mmapLimit = Long.parseLong(System.getProperty("org.polymap.core.LuceneRecordStore.mmaplimit", "1000")) * 1000000; if (dbSize > mmapLimit) { directory = Constants.WINDOWS ? new SimpleFSDirectory(indexDir, null) : new NIOFSDirectory(indexDir, null); open(clean); } // use mmap on 32bit Linux of index size < 100MB // more shared memory results in system stall under rare conditions else if (Constants.LINUX && !Constants.JRE_IS_64BIT && MMapDirectory.UNMAP_SUPPORTED && dbSize < 100 * 1024 * 1024) { try { directory = new MMapDirectory(indexDir, null); open(clean); } catch (OutOfMemoryError e) { log.info("Unable to mmap index: falling back to default."); } } // default if (searcher == null) { directory = FSDirectory.open(indexDir); open(clean); } log.info("Database: " + indexDir.getAbsolutePath() + "\n size: " + FileUtils.sizeOfDirectory(indexDir) + "\n using: " + directory.getClass().getSimpleName() + "\n files in directry: " + Arrays.asList(directory.listAll())); }
From source file:org.polymap.recordstore.lucene.LuceneRecordStore.java
public LuceneRecordStore(Configuration config) throws IOException { this.config = config; File indexDir = config.indexDir.get(); if (!indexDir.exists()) { indexDir.mkdirs();/*from w w w. j a v a 2 s.c om*/ } directory = null; // use mmap on 32bit Linux of index size < 100MB // more shared memory results in system stall under rare conditions if (Constants.LINUX && !Constants.JRE_IS_64BIT && MMapDirectory.UNMAP_SUPPORTED && FileUtils.sizeOfDirectory(indexDir) < 100 * 1024 * 1024) { try { directory = new MMapDirectory(indexDir, null); open(config.clean.get()); } catch (OutOfMemoryError e) { log.info("Unable to mmap index: falling back to default."); } } if (searcher == null) { directory = FSDirectory.open(indexDir); open(config.clean.get()); } // init cache (if configured) CacheManager cacheManager = config.documentCache.get(); if (cacheManager != null) { cache = cacheManager.createCache("LuceneRecordStore-" + hashCode(), new MutableConfiguration().setReadThrough(true).setCacheLoaderFactory(() -> loader)); } // init ExecutorService executor = Optional.ofNullable(config.executor.get()).orElse(defaultExecutor); log.info("Database: " + indexDir.getAbsolutePath() + "\n size: " + FileUtils.sizeOfDirectory(indexDir) + "\n using: " + directory.getClass().getSimpleName() + "\n files in directry: " + Arrays.asList(directory.listAll()) + "\n cache: " + (cache != null ? cache.getClass().getSimpleName() : "none") + "\n executor: " + executor.getClass().getSimpleName()); }
From source file:org.silverpeas.core.io.temp.TemporaryWorkspaceTranslation.java
/** * Indicates if the workspace is empty./*from w w w. j a v a 2s. c o m*/ * @return true if it is empty, false otherwise. */ public boolean empty() { synchronized (lock) { return exists() && FileUtils.sizeOfDirectory(workspace) == 0; } }