Get free disk space

@param string $dir
@param string $type = 'free'

@return float
490904
public static function disk(String $dir, String $type = 'free') : Float
    {
        $dir = self::rpath($dir);

        if( ! is_dir($dir) )
        {
            throw new Exception\FolderNotFoundException(NULL, $dir);
        }

        if( $type === 'free' )
        {
            return disk_free_space($dir);
        }
        else
        {
            return disk_total_space($dir);
        }
    }
854280
public function unshiftClassContentDir($dir)
    {
        File::resolveFilepath($dir);

        $classcontentdir = $this->getClassContentDir();
        array_unshift($classcontentdir, $dir);

        $this->classcontentDir = array_unique($classcontentdir);

        return $this;
    }
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
741442
public static function dirSize($path, array $exclude = [])
    {
        if (!is_dir($path)) {
            return 0;
        }

        $size = 0;
        $exclude = array_merge(['.', '..'], $exclude);
        $items = array_diff(scandir($path), $exclude);
        foreach ($items as $item) {
            $inner_item = static::join($path, $item);
            $size += is_file($inner_item) ? filesize($inner_item) : static::dirSize($inner_item, $exclude);
        }

        return $size;
    }
876477
public function createDir($dir, $type='sandbox')
	{
		$url = 'https://api.dropbox.com/1/fileops/create_folder';
		$result = $this->doOAuthCall($url, 'POST', array('path'=>$dir), $type);
		$result_body = json_decode($result['body'], true);
		if (!array_key_exists('error', $result_body)) {
			return $result_body;
		} else {
			trigger_error(sprintf(self::E_APIERROR, $result_body['error']));
			return false;
		}
	}
539962
public function getLength($type = null) {
		$findConf = [
			'conditions' => [
				'completed IS' => null,
			],
		];
		if ($type !== null) {
			$findConf['conditions']['job_type'] = $type;
		}

		return $this->find('all', $findConf)->count();
	}
196512
private static function folderSize($dir)
    {
        $size = 0;
        foreach (glob(rtrim($dir, '/').'/*', GLOB_NOSORT) as $each) {
            $size += is_file($each) ? filesize($each) : self::folderSize($each);
        }
        return $size;
    }
530148
public function dirSize($directory = '.', $recursive = true)
    {
        $items = $this->scanDir($directory, $recursive);
        $size  = 0;

        foreach ($items as $item) {
            $size += (int) $item['size'];
        }

        return $size;
    }
1069603
public function total_disk_space($path = '/')
    {
        $ds = 0;
        if ($this->host_os === 'WINDOWS') {
            $wmi = new \COM("winmgmts:\\\\.\\root\\cimv2");
            $disks =  $wmi->ExecQuery("Select * from Win32_LogicalDisk");

            foreach ($disks as $d) {
                if ($d->Name == $path) {
                    $ds = $d->Size;
                }
            }
        } else {
            $ds = disk_total_space($path);
        }
        return $ds;
    }
1190859
public static function assumeFreeDiskSpace($directory, $available = null, $message = ''): void
    {
        if ($available === null) {
            assumeThat(disk_free_space($directory), is(not(false)), $message);
        } else {
            assumeThat(disk_free_space($directory), is(greaterThanOrEqualTo($available)), $message);
        }
    }
388628
public static function size($path)
    {
        $path = Normalize::diskFullPath($path);

        if (!self::exist($path)) {
            return 0;
        }

        return filesize($path);
    }
514682
public function getPackageDownloads($type)
    {
        $statsType = 'get' . ucfirst($type);
        if (($download = $this->getDownloads()) && $download instanceof \Packagist\Api\Result\Package\Downloads) {
            return $download->{$statsType}();
        }
    }
1359496
public function getDefaultTypeSize($type)
    {
        $sizes = $this->getDefaultTypeSizes();

        return isset($sizes[strtolower($type)]) ? $sizes[strtolower($type)] : null;
    }
90997
public function getStorages($type = null)
    {
        if ($type === null) {
            return $this->get('/storage');
        }

        $supportedTypes = array(
            'lvm',
            'nfs',
            'dir',
            'zfs',
            'rbd',
            'iscsi',
            'sheepdog',
            'glusterfs',
            'iscsidirect',
        );

        if (in_array($type, $supportedTypes)) {
            return $this->get('/storage', array(
                'type' => $type,
            ));
        }

        /* If type not found returns null */
        return null;
    }
1043779
public function chmod($type) {
		
		if(false !== $this -> directory -> getExists()) {
			return chmod($this -> directory -> getPath(), $type);
		}

		return false;
	}
123054
public function directoryLength($directory = '')
    {
        if ($items = glob($this->rootDir .'/'. trim($directory, '/') .'/*')) {
            return count($items);
        }

        return 0;
    }
997352
public function searchDir($type, $directory = '')
    {
        $dirs = $this->search($type, $directory, 'path');
        $files = array();
        foreach ($dirs as $dir) {
            $this->_searchDirFiles($dir, $files);
        }

        return $files;
    }