Get the number of tiles that can be stored on the file system.

@param directory where the cache will reside
@param fileSize  average size of tile to be cached
@return number of tiles that can be stored without running out of space
765637
@SuppressWarnings("deprecation")
    @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
    public static long getAvailableCacheSlots(String directory, int fileSize) {
        StatFs statfs = new StatFs(directory);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
            return statfs.getAvailableBytes() / fileSize;
        }
        // problem is overflow with devices with large storage, so order is important here
        // additionally avoid division by zero in devices with a large block size
        int blocksPerFile = Math.max(fileSize / statfs.getBlockSize(), 1);
        return statfs.getAvailableBlocks() / blocksPerFile;
    }
1176986
public static double zoomLevelOfTileSize(double tileSize) {
		double tilesPerSide = (2 * ProjectionConstants.WEB_MERCATOR_HALF_WORLD_WIDTH)
				/ tileSize;
		double zoom = Math.log(tilesPerSide) / Math.log(2);
		return zoom;
	}
1177250
public synchronized int getPartitionStoreCount() {
        int count = 0;
        for (String store : storeToPartitionIds.keySet()) {
            count += storeToPartitionIds.get(store).size();
        }
        return count;
    }
3853
public static Map<String,byte[]> storeDirectoryResourcesAsBytes( File directory ) throws IOException {
		return storeDirectoryResourcesAsBytes( directory, new ArrayList<String>( 0 ));
	}
1278465
def filesize(self):
        
        if self.from_stdin:
            return None
        if not self._filesize:
            self._calculate_bounds()
        return self._filesize
1066210
public long size() throws FileLockException, IOException {
        long size = 0L;
        for (int bucketId = 0; bucketId < hashFunction.getNumberOfBuckets(); bucketId++) {
            HeaderIndexFile<Data> headerIndexFile = new HeaderIndexFile<Data>(gp.DATABASE_DIRECTORY + "/"
                    + hashFunction.getFilename(bucketId), gp.HEADER_FILE_LOCK_RETRY, gp);
            size += headerIndexFile.getFilledUpFromContentStart() / gp.getElementSize();
            headerIndexFile.close();
        }
        return size;
    }
625358
@GuardedBy("mLock")
  private boolean maybeUpdateFileCacheSize() {
    long now = mClock.now();
    if ((!mCacheStats.isInitialized()) ||
        mCacheSizeLastUpdateTime == UNINITIALIZED ||
        (now - mCacheSizeLastUpdateTime) > FILECACHE_SIZE_UPDATE_PERIOD_MS) {
      return maybeUpdateFileCacheSizeAndIndex();
    }
    return false;
  }
634527
public static function directory_size($dir)
    {
        $size = 0;
        foreach(new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dir, \FilesystemIterator::CURRENT_AS_FILEINFO | \FilesystemIterator::SKIP_DOTS)) as $file => $key) {
            if ($key->isFile()) {
                $size += $key->getSize();
            }
        }
        return $size;
    }
95183
public static function dirSize($directory)
    {
        $size = 0;
        foreach (new \RecursiveIteratorIterator(
                     new RecursiveDirectoryIterator($directory, \FilesystemIterator::KEY_AS_PATHNAME)
                 ) as $file) {
            $size += $file->getSize();
        }

        return $size;
    }
983091
public int allocateSpace(final int iSize) throws IOException {
    final int offset = getFilledUpTo();
    final int size = getFileSize();

    if (getFreeSpace() < iSize) {
      if (maxSize > 0 && maxSize - size < iSize)
        throw new IllegalArgumentException("Cannot enlarge file since the configured max size ("
            + OFileUtils.getSizeAsString(maxSize) + ") was reached! " + toString());

      // MAKE ROOM
      int newFileSize = size;

      if (newFileSize == 0)
        // PROBABLY HAS BEEN LOST WITH HARD KILLS
        newFileSize = DEFAULT_SIZE;

      // GET THE STEP SIZE IN BYTES
      int stepSizeInBytes = incrementSize > 0 ? incrementSize : -1 * size / 100 * incrementSize;

      // FIND THE BEST SIZE TO ALLOCATE (BASED ON INCREMENT-SIZE)
      while (newFileSize - offset <= iSize) {
        newFileSize += stepSizeInBytes;

        if (newFileSize == 0)
          // EMPTY FILE: ALLOCATE REQUESTED SIZE ONLY
          newFileSize = iSize;
        if (newFileSize > maxSize && maxSize > 0)
          // TOO BIG: ROUND TO THE MAXIMUM FILE SIZE
          newFileSize = maxSize;
      }

      setSize(newFileSize);
    }

    // THERE IS SPACE IN FILE: RETURN THE UPPER BOUND OFFSET AND UPDATE THE FILLED THRESHOLD
    setFilledUpTo(offset + iSize);

    return offset;
  }
484479
public Long getFileSizeAvg() {
        Long fileSizeAvg = 0L;
        if (items.size() != 0) {
            for (TableStat item : items) {
                if (item.getEndTime().equals(item.getStartTime())) {
                    fileSizeAvg += item.getFileSize();
                } else {
                    fileSizeAvg += item.getFileSize() * 1000
                                   / (item.getEndTime().getTime() - item.getStartTime().getTime());
                }
            }
            fileSizeAvg = fileSizeAvg / items.size();
        }
        return fileSizeAvg;
    }
1087825
@Override
    public int size(boolean includeDiskCache) {
        int mappings = 0;

        mappings = cache.getNumberCacheEntries();

        if (includeDiskCache) {
            if (cache instanceof CacheProviderWrapper) {
                CacheProviderWrapper cpw = (CacheProviderWrapper) cache;
                if (cpw.featureSupport.isDiskCacheSupported())
                    mappings = mappings + cache.getIdsSizeDisk();
            } else {
                mappings = mappings + cache.getIdsSizeDisk();
            }
        }
        return mappings;
    }
644158
def number_of_sub_file_entries(self):
    """"""
    if self._directory is None:
      self._directory = self._GetDirectory()

    if self._directory is None:
      return 0

    # We cannot use len(self._directory.entries) since entries is a generator.
    return sum(1 for path_spec in self._directory.entries)
903014
@Override
    public int capacity() {
        if (isFCEnabled()) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "FileChannel capacity: " + this.fcSize);
            }
            return this.fcSize;
        }
        return super.capacity();
    }
866847
@Override
	public int getMaximumNumberOfSubtasks() {
		if (!(this.format instanceof FileOutputFormat<?>)) {
			return -1;
		}
		
		final FileOutputFormat<?> fileOutputFormat = (FileOutputFormat<?>) this.format;
		
		// ----------------- This code applies only to file inputs ------------------
		
		final Path path = fileOutputFormat.getOutputFilePath();
		final WriteMode writeMode = fileOutputFormat.getWriteMode();
		final OutputDirectoryMode outDirMode = fileOutputFormat.getOutputDirectoryMode();

		// Prepare output path and determine max DOP		
		try {
			
			int dop = getTaskConfiguration().getInteger(DEGREE_OF_PARALLELISM_KEY, -1);
			final FileSystem fs = path.getFileSystem();
			
			if(dop == 1 && outDirMode == OutputDirectoryMode.PARONLY) {
				// output is not written in parallel and should be written to a single file.
				
				if(fs.isDistributedFS()) {
					// prepare distributed output path
					if(!fs.initOutPathDistFS(path, writeMode, false)) {
						// output preparation failed! Cancel task.
						throw new IOException("Output path could not be initialized.");
					}
				}
				
				return 1;
				
			} else {
				// output should be written to a directory
				
				if(fs.isDistributedFS()) {
					// only distributed file systems can be initialized at start-up time.
					if(!fs.initOutPathDistFS(path, writeMode, true)) {
						throw new IOException("Output directory could not be created.");
					}
				}
				
				return -1;
				
			}
		}
		catch (IOException e) {
			LOG.error("Could not access the file system to detemine the status of the output.", e);
			throw new RuntimeException("I/O Error while accessing file", e);
		}
	}
81928
public static function getSize($filename) {
        if (false === file_exists($filename)) {
            throw new FileNotFoundException($filename);
        }
        clearstatcache();
        return filesize($filename);
    }
123054
public function directoryLength($directory = '')
    {
        if ($items = glob($this->rootDir .'/'. trim($directory, '/') .'/*')) {
            return count($items);
        }

        return 0;
    }