当前位置: 首页>>代码示例>>PHP>>正文


PHP Filesystem::free_space方法代码示例

本文整理汇总了PHP中OC\Files\Filesystem::free_space方法的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem::free_space方法的具体用法?PHP Filesystem::free_space怎么用?PHP Filesystem::free_space使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OC\Files\Filesystem的用法示例。


在下文中一共展示了Filesystem::free_space方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: checkQuota

 /**
  * This method is called before any HTTP method and forces users to be authenticated
  *
  * @param string $method
  * @throws Sabre_DAV_Exception
  * @return bool
  */
 public function checkQuota($uri, $data = null)
 {
     $expected = $this->server->httpRequest->getHeader('X-Expected-Entity-Length');
     $length = $expected ? $expected : $this->server->httpRequest->getHeader('Content-Length');
     if ($length) {
         if (substr($uri, 0, 1) !== '/') {
             $uri = '/' . $uri;
         }
         list($parentUri, $newName) = Sabre_DAV_URLUtil::splitPath($uri);
         $freeSpace = \OC\Files\Filesystem::free_space($parentUri);
         if ($freeSpace !== \OC\Files\FREE_SPACE_UNKNOWN && $length > $freeSpace) {
             throw new Sabre_DAV_Exception_InsufficientStorage();
         }
     }
     return true;
 }
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:23,代码来源:quotaplugin.php

示例2: expire

 /**
  * @brief Erase a file's versions which exceed the set quota
  */
 private static function expire($filename, $versionsSize = null, $offset = 0)
 {
     if (\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED) == 'true') {
         list($uid, $filename) = self::getUidAndFilename($filename);
         $versionsFileview = new \OC\Files\View('/' . $uid . '/files_versions');
         // get available disk space for user
         $softQuota = true;
         $quota = \OC_Preferences::getValue($uid, 'files', 'quota');
         if ($quota === null || $quota === 'default') {
             $quota = \OC_Appconfig::getValue('files', 'default_quota');
         }
         if ($quota === null || $quota === 'none') {
             $quota = \OC\Files\Filesystem::free_space('/');
             $softQuota = false;
         } else {
             $quota = \OCP\Util::computerFileSize($quota);
         }
         // make sure that we have the current size of the version history
         if ($versionsSize === null) {
             $versionsSize = self::getVersionsSize($uid);
             if ($versionsSize === false || $versionsSize < 0) {
                 $versionsSize = self::calculateSize($uid);
             }
         }
         // calculate available space for version history
         // subtract size of files and current versions size from quota
         if ($softQuota) {
             $files_view = new \OC\Files\View('/' . $uid . '/files');
             $rootInfo = $files_view->getFileInfo('/');
             $free = $quota - $rootInfo['size'];
             // remaining free space for user
             if ($free > 0) {
                 $availableSpace = $free * self::DEFAULTMAXSIZE / 100 - ($versionsSize + $offset);
                 // how much space can be used for versions
             } else {
                 $availableSpace = $free - $versionsSize - $offset;
             }
         } else {
             $availableSpace = $quota - $offset;
         }
         // with the  probability of 0.1% we reduce the number of all versions not only for the current file
         $random = rand(0, 1000);
         if ($random == 0) {
             $allFiles = true;
         } else {
             $allFiles = false;
         }
         $allVersions = Storage::getVersions($uid, $filename);
         $versionsByFile[$filename] = $allVersions;
         $sizeOfDeletedVersions = self::delOldVersions($versionsByFile, $allVersions, $versionsFileview);
         $availableSpace = $availableSpace + $sizeOfDeletedVersions;
         $versionsSize = $versionsSize - $sizeOfDeletedVersions;
         // if still not enough free space we rearrange the versions from all files
         if ($availableSpace <= 0 || $allFiles) {
             $result = Storage::getAllVersions($uid);
             $versionsByFile = $result['by_file'];
             $allVersions = $result['all'];
             $sizeOfDeletedVersions = self::delOldVersions($versionsByFile, $allVersions, $versionsFileview);
             $availableSpace = $availableSpace + $sizeOfDeletedVersions;
             $versionsSize = $versionsSize - $sizeOfDeletedVersions;
         }
         // Check if enough space is available after versions are rearranged.
         // If not we delete the oldest versions until we meet the size limit for versions,
         // but always keep the two latest versions
         $numOfVersions = count($allVersions) - 2;
         $i = 0;
         while ($availableSpace < 0 && $i < $numOfVersions) {
             $version = current($allVersions);
             $versionsFileview->unlink($version['path'] . '.v' . $version['version']);
             $versionsSize -= $version['size'];
             $availableSpace += $version['size'];
             next($allVersions);
             $i++;
         }
         return $versionsSize;
         // finally return the new size of the version history
     }
     return false;
 }
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:82,代码来源:versions.php

示例3: freeSpace

 /**
  * Calculate free space left within user quota
  *
  * @param string $dir the current folder where the user currently operates
  * @return int number of bytes representing
  */
 public static function freeSpace($dir)
 {
     $freeSpace = \OC\Files\Filesystem::free_space($dir);
     if ($freeSpace !== \OCP\Files\FileInfo::SPACE_UNKNOWN) {
         $freeSpace = max($freeSpace, 0);
         return $freeSpace;
     } else {
         return INF > 0 ? INF : PHP_INT_MAX;
         // work around https://bugs.php.net/bug.php?id=69188
     }
 }
开发者ID:kenwi,项目名称:core,代码行数:17,代码来源:helper.php

示例4: calculateFreeSpace

 /**
  * calculate remaining free space for trash bin
  *
  * @param integer $trashbinSize current size of the trash bin
  * @param string $user
  * @return int available free space for trash bin
  */
 private static function calculateFreeSpace($trashbinSize, $user)
 {
     $softQuota = true;
     $quota = \OC_Preferences::getValue($user, 'files', 'quota');
     $view = new \OC\Files\View('/' . $user);
     if ($quota === null || $quota === 'default') {
         $quota = \OC::$server->getAppConfig()->getValue('files', 'default_quota');
     }
     if ($quota === null || $quota === 'none') {
         $quota = \OC\Files\Filesystem::free_space('/');
         $softQuota = false;
     } else {
         $quota = \OCP\Util::computerFileSize($quota);
     }
     // calculate available space for trash bin
     // subtract size of files and current trash bin size from quota
     if ($softQuota) {
         $rootInfo = $view->getFileInfo('/files/', false);
         $free = $quota - $rootInfo['size'];
         // remaining free space for user
         if ($free > 0) {
             $availableSpace = $free * self::DEFAULTMAXSIZE / 100 - $trashbinSize;
             // how much space can be used for versions
         } else {
             $availableSpace = $free - $trashbinSize;
         }
     } else {
         $availableSpace = $quota;
     }
     return $availableSpace;
 }
开发者ID:Combustible,项目名称:core,代码行数:38,代码来源:trashbin.php

示例5: expire

 /**
  * Expire versions which exceed the quota
  *
  * @param string $filename
  * @return bool|int|null
  */
 public static function expire($filename)
 {
     $config = \OC::$server->getConfig();
     $expiration = self::getExpiration();
     if ($config->getSystemValue('files_versions', Storage::DEFAULTENABLED) == 'true' && $expiration->isEnabled()) {
         if (!Filesystem::file_exists($filename)) {
             return false;
         }
         list($uid, $filename) = self::getUidAndFilename($filename);
         if (empty($filename)) {
             // file maybe renamed or deleted
             return false;
         }
         $versionsFileview = new View('/' . $uid . '/files_versions');
         // get available disk space for user
         $user = \OC::$server->getUserManager()->get($uid);
         $softQuota = true;
         $quota = $user->getQuota();
         if ($quota === null || $quota === 'none') {
             $quota = Filesystem::free_space('/');
             $softQuota = false;
         } else {
             $quota = \OCP\Util::computerFileSize($quota);
         }
         // make sure that we have the current size of the version history
         $versionsSize = self::getVersionsSize($uid);
         // calculate available space for version history
         // subtract size of files and current versions size from quota
         if ($quota >= 0) {
             if ($softQuota) {
                 $files_view = new View('/' . $uid . '/files');
                 $rootInfo = $files_view->getFileInfo('/', false);
                 $free = $quota - $rootInfo['size'];
                 // remaining free space for user
                 if ($free > 0) {
                     $availableSpace = $free * self::DEFAULTMAXSIZE / 100 - $versionsSize;
                     // how much space can be used for versions
                 } else {
                     $availableSpace = $free - $versionsSize;
                 }
             } else {
                 $availableSpace = $quota;
             }
         } else {
             $availableSpace = PHP_INT_MAX;
         }
         $allVersions = Storage::getVersions($uid, $filename);
         $time = time();
         list($toDelete, $sizeOfDeletedVersions) = self::getExpireList($time, $allVersions, $availableSpace <= 0);
         $availableSpace = $availableSpace + $sizeOfDeletedVersions;
         $versionsSize = $versionsSize - $sizeOfDeletedVersions;
         // if still not enough free space we rearrange the versions from all files
         if ($availableSpace <= 0) {
             $result = Storage::getAllVersions($uid);
             $allVersions = $result['all'];
             foreach ($result['by_file'] as $versions) {
                 list($toDeleteNew, $size) = self::getExpireList($time, $versions, $availableSpace <= 0);
                 $toDelete = array_merge($toDelete, $toDeleteNew);
                 $sizeOfDeletedVersions += $size;
             }
             $availableSpace = $availableSpace + $sizeOfDeletedVersions;
             $versionsSize = $versionsSize - $sizeOfDeletedVersions;
         }
         foreach ($toDelete as $key => $path) {
             \OC_Hook::emit('\\OCP\\Versions', 'preDelete', array('path' => $path, 'trigger' => self::DELETE_TRIGGER_QUOTA_EXCEEDED));
             self::deleteVersion($versionsFileview, $path);
             \OC_Hook::emit('\\OCP\\Versions', 'delete', array('path' => $path, 'trigger' => self::DELETE_TRIGGER_QUOTA_EXCEEDED));
             unset($allVersions[$key]);
             // update array with the versions we keep
             \OCP\Util::writeLog('files_versions', "Expire: " . $path, \OCP\Util::DEBUG);
         }
         // Check if enough space is available after versions are rearranged.
         // If not we delete the oldest versions until we meet the size limit for versions,
         // but always keep the two latest versions
         $numOfVersions = count($allVersions) - 2;
         $i = 0;
         // sort oldest first and make sure that we start at the first element
         ksort($allVersions);
         reset($allVersions);
         while ($availableSpace < 0 && $i < $numOfVersions) {
             $version = current($allVersions);
             \OC_Hook::emit('\\OCP\\Versions', 'preDelete', array('path' => $version['path'] . '.v' . $version['version'], 'trigger' => self::DELETE_TRIGGER_QUOTA_EXCEEDED));
             self::deleteVersion($versionsFileview, $version['path'] . '.v' . $version['version']);
             \OC_Hook::emit('\\OCP\\Versions', 'delete', array('path' => $version['path'] . '.v' . $version['version'], 'trigger' => self::DELETE_TRIGGER_QUOTA_EXCEEDED));
             \OCP\Util::writeLog('files_versions', 'running out of space! Delete oldest version: ' . $version['path'] . '.v' . $version['version'], \OCP\Util::DEBUG);
             $versionsSize -= $version['size'];
             $availableSpace += $version['size'];
             next($allVersions);
             $i++;
         }
         return $versionsSize;
         // finally return the new size of the version history
     }
     return false;
//.........这里部分代码省略.........
开发者ID:gvde,项目名称:core,代码行数:101,代码来源:storage.php

示例6: calculateFreeSpace

 /**
  * calculate remaining free space for trash bin
  *
  * @param integer $trashbinSize current size of the trash bin
  * @param string $user
  * @return int available free space for trash bin
  */
 private static function calculateFreeSpace($trashbinSize, $user)
 {
     $softQuota = true;
     $userObject = \OC::$server->getUserManager()->get($user);
     if (is_null($userObject)) {
         return 0;
     }
     $quota = $userObject->getQuota();
     if ($quota === null || $quota === 'none') {
         $quota = Filesystem::free_space('/');
         $softQuota = false;
         // inf or unknown free space
         if ($quota < 0) {
             $quota = PHP_INT_MAX;
         }
     } else {
         $quota = \OCP\Util::computerFileSize($quota);
     }
     // calculate available space for trash bin
     // subtract size of files and current trash bin size from quota
     if ($softQuota) {
         $userFolder = \OC::$server->getUserFolder($user);
         if (is_null($userFolder)) {
             return 0;
         }
         $free = $quota - $userFolder->getSize();
         // remaining free space for user
         if ($free > 0) {
             $availableSpace = $free * self::DEFAULTMAXSIZE / 100 - $trashbinSize;
             // how much space can be used for versions
         } else {
             $availableSpace = $free - $trashbinSize;
         }
     } else {
         $availableSpace = $quota;
     }
     return $availableSpace;
 }
开发者ID:GitHubUser4234,项目名称:core,代码行数:45,代码来源:Trashbin.php

示例7: array

    //dont load anything if we need to upgrade the cache
    $needUpgrade = true;
    $freeSpace = 0;
} else {
    if ($isIE8) {
        // after the redirect above, the URL will have a format
        // like "files#?dir=path" which means that no path was given
        // (dir is not set). In that specific case, we don't return any
        // files because the client will take care of switching the dir
        // to the one from the hash, then ajax-load the initial file list
        $files = array();
        $ajaxLoad = true;
    } else {
        $files = \OCA\Files\Helper::getFiles($dir);
    }
    $freeSpace = \OC\Files\Filesystem::free_space($dir);
    $needUpgrade = false;
}
// Make breadcrumb
$breadcrumb = \OCA\Files\Helper::makeBreadcrumb($dir);
// make breadcrumb und filelist markup
$list = new OCP\Template('files', 'part.list', '');
$list->assign('files', $files);
$list->assign('baseURL', OCP\Util::linkTo('files', 'index.php') . '?dir=');
$list->assign('downloadURL', OCP\Util::linkToRoute('download', array('file' => '/')));
$list->assign('isPublic', false);
$breadcrumbNav = new OCP\Template('files', 'part.breadcrumb', '');
$breadcrumbNav->assign('breadcrumb', $breadcrumb);
$breadcrumbNav->assign('baseURL', OCP\Util::linkTo('files', 'index.php') . '?dir=');
$permissions = \OCA\Files\Helper::getDirPermissions($dir);
if ($needUpgrade) {
开发者ID:omusico,项目名称:isle-web-framework,代码行数:31,代码来源:index.php

示例8: freeSpace

	/**
	 * Calculate free space left within user quota
	 *
	 * @param string $dir the current folder where the user currently operates
	 * @return int number of bytes representing
	 */
	public static function freeSpace($dir) {
		$freeSpace = \OC\Files\Filesystem::free_space($dir);
		if ($freeSpace !== \OCP\Files\FileInfo::SPACE_UNKNOWN) {
			$freeSpace = max($freeSpace, 0);
			return $freeSpace;
		} else {
			return INF;
		}
	}
开发者ID:pombredanne,项目名称:ArcherSys,代码行数:15,代码来源:helper.php

示例9: expire

 /**
  * Erase a file's versions which exceed the set quota
  */
 private static function expire($filename, $versionsSize = null, $offset = 0)
 {
     if (\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED) == 'true') {
         list($uid, $filename) = self::getUidAndFilename($filename);
         $versionsFileview = new \OC\Files\View('/' . $uid . '/files_versions');
         // get available disk space for user
         $softQuota = true;
         $quota = \OC_Preferences::getValue($uid, 'files', 'quota');
         if ($quota === null || $quota === 'default') {
             $quota = \OC::$server->getAppConfig()->getValue('files', 'default_quota');
         }
         if ($quota === null || $quota === 'none') {
             $quota = \OC\Files\Filesystem::free_space('/');
             $softQuota = false;
         } else {
             $quota = \OCP\Util::computerFileSize($quota);
         }
         // make sure that we have the current size of the version history
         if ($versionsSize === null) {
             $versionsSize = self::getVersionsSize($uid);
         }
         // calculate available space for version history
         // subtract size of files and current versions size from quota
         if ($softQuota) {
             $files_view = new \OC\Files\View('/' . $uid . '/files');
             $rootInfo = $files_view->getFileInfo('/', false);
             $free = $quota - $rootInfo['size'];
             // remaining free space for user
             if ($free > 0) {
                 $availableSpace = $free * self::DEFAULTMAXSIZE / 100 - ($versionsSize + $offset);
                 // how much space can be used for versions
             } else {
                 $availableSpace = $free - $versionsSize - $offset;
             }
         } else {
             $availableSpace = $quota - $offset;
         }
         $allVersions = Storage::getVersions($uid, $filename);
         $time = time();
         list($toDelete, $sizeOfDeletedVersions) = self::getExpireList($time, $allVersions);
         $availableSpace = $availableSpace + $sizeOfDeletedVersions;
         $versionsSize = $versionsSize - $sizeOfDeletedVersions;
         // if still not enough free space we rearrange the versions from all files
         if ($availableSpace <= 0) {
             $result = Storage::getAllVersions($uid);
             $allVersions = $result['all'];
             foreach ($result['by_file'] as $versions) {
                 list($toDeleteNew, $size) = self::getExpireList($time, $versions);
                 $toDelete = array_merge($toDelete, $toDeleteNew);
                 $sizeOfDeletedVersions += $size;
             }
             $availableSpace = $availableSpace + $sizeOfDeletedVersions;
             $versionsSize = $versionsSize - $sizeOfDeletedVersions;
         }
         foreach ($toDelete as $key => $path) {
             \OC_Hook::emit('\\OCP\\Versions', 'preDelete', array('path' => $path));
             self::deleteVersion($versionsFileview, $path);
             \OC_Hook::emit('\\OCP\\Versions', 'delete', array('path' => $path));
             unset($allVersions[$key]);
             // update array with the versions we keep
             \OCP\Util::writeLog('files_versions', "Expire: " . $path, \OCP\Util::DEBUG);
         }
         // Check if enough space is available after versions are rearranged.
         // If not we delete the oldest versions until we meet the size limit for versions,
         // but always keep the two latest versions
         $numOfVersions = count($allVersions) - 2;
         $i = 0;
         while ($availableSpace < 0 && $i < $numOfVersions) {
             $version = current($allVersions);
             \OC_Hook::emit('\\OCP\\Versions', 'preDelete', array('path' => $version['path'] . '.v' . $version['version']));
             self::deleteVersion($versionsFileview, $version['path'] . '.v' . $version['version']);
             \OC_Hook::emit('\\OCP\\Versions', 'delete', array('path' => $version['path'] . '.v' . $version['version']));
             \OCP\Util::writeLog('files_versions', 'running out of space! Delete oldest version: ' . $version['path'] . '.v' . $version['version'], \OCP\Util::DEBUG);
             $versionsSize -= $version['size'];
             $availableSpace += $version['size'];
             next($allVersions);
             $i++;
         }
         return $versionsSize;
         // finally return the new size of the version history
     }
     return false;
 }
开发者ID:olucao,项目名称:owncloud-core,代码行数:86,代码来源:versions.php

示例10: getStorageInfo

 /**
  * Calculate the disc space
  */
 public static function getStorageInfo()
 {
     $rootInfo = \OC\Files\Filesystem::getFileInfo('/');
     $used = $rootInfo['size'];
     if ($used < 0) {
         $used = 0;
     }
     $free = \OC\Files\Filesystem::free_space();
     $total = $free + $used;
     if ($total == 0) {
         $total = 1;
         // prevent division by zero
     }
     $relative = round($used / $total * 10000) / 100;
     return array('free' => $free, 'used' => $used, 'total' => $total, 'relative' => $relative);
 }
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:19,代码来源:helper.php

示例11: getStorageInfo

 /**
  * Calculate the disc space for the given path
  *
  * @param string $path
  * @return array
  */
 public static function getStorageInfo($path)
 {
     // return storage info without adding mount points
     $rootInfo = \OC\Files\Filesystem::getFileInfo($path, false);
     $used = $rootInfo['size'];
     if ($used < 0) {
         $used = 0;
     }
     $free = \OC\Files\Filesystem::free_space($path);
     if ($free >= 0) {
         $total = $free + $used;
     } else {
         $total = $free;
         //either unknown or unlimited
     }
     if ($total > 0) {
         // prevent division by zero or error codes (negative values)
         $relative = round($used / $total * 10000) / 100;
     } else {
         $relative = 0;
     }
     return array('free' => $free, 'used' => $used, 'total' => $total, 'relative' => $relative);
 }
开发者ID:omusico,项目名称:isle-web-framework,代码行数:29,代码来源:helper.php

示例12: free_space

 /**
  * @deprecated OC_Filesystem is replaced by \OC\Files\Filesystem
  */
 public static function free_space($path = '/')
 {
     return \OC\Files\Filesystem::free_space($path);
 }
开发者ID:omusico,项目名称:isle-web-framework,代码行数:7,代码来源:filesystem.php

示例13: calculateFreeSpace

 /**
  * calculate remaining free space for trash bin
  *
  * @param integer $trashbinSize current size of the trash bin
  * @param string $user
  * @return int available free space for trash bin
  */
 private static function calculateFreeSpace($trashbinSize, $user)
 {
     $config = \OC::$server->getConfig();
     $softQuota = true;
     $quota = \OC::$server->getUserManager()->get($user)->getQuota();
     $view = new \OC\Files\View('/' . $user);
     if ($quota === null || $quota === 'none') {
         $quota = \OC\Files\Filesystem::free_space('/');
         $softQuota = false;
         // inf or unknown free space
         if ($quota < 0) {
             $quota = PHP_INT_MAX;
         }
     } else {
         $quota = \OCP\Util::computerFileSize($quota);
     }
     // calculate available space for trash bin
     // subtract size of files and current trash bin size from quota
     if ($softQuota) {
         $rootInfo = $view->getFileInfo('/files/', false);
         $free = $quota - $rootInfo['size'];
         // remaining free space for user
         if ($free > 0) {
             $availableSpace = $free * self::DEFAULTMAXSIZE / 100 - $trashbinSize;
             // how much space can be used for versions
         } else {
             $availableSpace = $free - $trashbinSize;
         }
     } else {
         $availableSpace = $quota;
     }
     return $availableSpace;
 }
开发者ID:ZverAleksey,项目名称:core,代码行数:40,代码来源:trashbin.php

示例14: getQuotaInfo

 /**
  * Returns available diskspace information
  *
  * @return array
  */
 public function getQuotaInfo()
 {
     $rootInfo = \OC\Files\Filesystem::getFileInfo('');
     return array($rootInfo['size'], \OC\Files\Filesystem::free_space());
 }
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:10,代码来源:directory.php


注:本文中的OC\Files\Filesystem::free_space方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。