Takes a path as an argument and returns the total size in bytes of the file
    or directory. If the path is a directory the size will be calculated
    recursively.
338789
def calc(path):
    '''
    
    '''
    total = 0
    err = None
    if os.path.isdir(path):
        try:
            for entry in os.scandir(path):
                try:
                    is_dir = entry.is_dir(follow_symlinks=False)
                except (PermissionError, FileNotFoundError):
                    err = "!"
                    return total, err
                if is_dir:
                    result = calc(entry.path)
                    total += result[0]
                    err = result[1]
                    if err:
                        return total, err
                else:
                    try:
                        total += entry.stat(follow_symlinks=False).st_size
                    except (PermissionError, FileNotFoundError):
                        err = "!"
                        return total, err
        except (PermissionError, FileNotFoundError):
            err = "!"
            return total, err
    else:
        total += os.path.getsize(path)
    return total, err
409738
def _get_file_size(self):
        
        file_size = retry(self._retry_count)(_get_content_length)(
            self._session, self.url, self._timeout
        )
        file_size = int(file_size)
        if file_size == 0:
            with io.open(self._file_path, 'a', encoding='utf-8'):
                pass
        return file_size
669337
def size(self):
        ''''''
        c = self.database.cursor()
        r = c.execute("SELECT sum(size) FROM files")

        try:
            size = int(r.fetchone()[0])
        except TypeError:
            size = 0

        return size
625973
def folder_size(pth, ignore=None):
    
    if not os.path.isdir(pth):
        raise exc.FolderNotFound

    ignore = coerce_to_list(ignore)

    total = 0
    for root, _, names in os.walk(pth):
        paths = [os.path.realpath(os.path.join(root, nm)) for nm in names]
        for pth in paths[::-1]:
            if not os.path.exists(pth):
                paths.remove(pth)
            elif match_pattern(pth, ignore):
                paths.remove(pth)
        total += sum(os.stat(pth).st_size for pth in paths)

    return total
1062463
def size(self):
        
        dir_size = 0
        for f in self.iterfiles(abspath=True):
            dir_size += os.path.getsize(f)
        return dir_size
55055
function getFileSize(filepath, options) {
			var stats = fs.statSync(filepath);
			return filesize(stats.size, options);
		}
1009305
def _file_size(file_path, uncompressed=False):
    """"""
    _, ext = os.path.splitext(file_path)

    if uncompressed:
        if ext in {".gz", ".gzip"}:
            with gzip.GzipFile(file_path, mode="rb") as fp:
                try:
                    fp.seek(0, os.SEEK_END)
                    return fp.tell()
                except ValueError:
                    # on python2, cannot seek from end and must instead read to end
                    fp.seek(0)
                    while len(fp.read(8192)) != 0:
                        pass
                    return fp.tell()
        elif ext in {".bz", ".bz2", ".bzip", ".bzip2"}:
            with bz2.BZ2File(file_path, mode="rb") as fp:
                fp.seek(0, os.SEEK_END)
                return fp.tell()

    return os.path.getsize(file_path)
882049
def getFileSystemSize(dirPath):
    
    assert os.path.exists(dirPath)
    diskStats = os.statvfs(dirPath)
    freeSpace = diskStats.f_frsize * diskStats.f_bavail
    diskSize = diskStats.f_frsize * diskStats.f_blocks
    return freeSpace, diskSize
781051
function getFileSize(filePath, callback) {
  try {
    isDirectory(filePath, function (err, data) {
      if (data) {
        callback(null, -1);
      } else {
        fs.stat(filePath, function (err, data) {
          if (err) {
            callback(null, -1);
          } else {
            callback(null, data.size);
          }
        });
      }
    });
  } catch (error) {
    callback(null, -1);
  }
}
101519
def file_size(self):
        
        stream = self.get_file_stream()
        stream.seek(0, os.SEEK_END)
        return stream.tell()
1250044
def size(self):
        
        if hasattr(self._stream, 'len'):
            return len(self._stream)
        elif hasattr(self._stream, 'fileno'):
            return os.fstat(self._stream.fileno()).st_size
        else:
            cur_pos = self._stream.tell()
            size = self._stream.seek(0, os.SEEK_END)
            self._stream.seek(cur_pos)
            return size
3424
def size(f, unit='B', fileStore=None):
    
    divisor = return_bytes(unit)
    fileID = process_infile(f, fileStore)[0]
    return fileID.size / divisor
678616
def fileSize(f):
    ''''''
    offset = f.tell()

    f.seek(0, 2)
    size = f.tell()

    f.seek(offset)  # return to the previous position in the file
    return size
1102877
def path_size(p: tcod.path.AStar) -> int:
    
    return int(lib.TCOD_path_size(p._path_c))
210418
def _calc_dir_size(path):
    
    dir_size = 0
    for (root, dirs, files) in os.walk(path):
        for fn in files:
            full_fn = os.path.join(root, fn)
            dir_size += os.path.getsize(full_fn)

    return dir_size
1224667
def get_disk_space(start_path='.'):
    
    total_size = 0
    for root, dname_list, fname_list in os.walk(start_path):
        for fname in fname_list:
            fpath = os.path.join(root, fname)
            try:
                total_size += os.path.getsize(fpath)
            except OSError:
                pass
    return total_size
209216
public static function size(string $path) : ?int
    {
        $size = filesize($path);
        return $size === false ? null : $size;
    }