本文整理汇总了PHP中OC_Filesystem类的典型用法代码示例。如果您正苦于以下问题:PHP OC_Filesystem类的具体用法?PHP OC_Filesystem怎么用?PHP OC_Filesystem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OC_Filesystem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getThumbnail
public function getThumbnail($path)
{
$gallery_path = \OCP\Config::getSystemValue('datadirectory') . '/' . \OC_User::getUser() . '/gallery';
if (file_exists($gallery_path . $path)) {
return new \OC_Image($gallery_path . $path);
}
if (!\OC_Filesystem::file_exists($path)) {
\OC_Log::write(self::TAG, 'File ' . $path . ' don\'t exists', \OC_Log::WARN);
return false;
}
$image = new \OC_Image();
$image->loadFromFile(\OC_Filesystem::getLocalFile($path));
if (!$image->valid()) {
return false;
}
$image->fixOrientation();
$ret = $image->preciseResize(floor(150 * $image->width() / $image->height()), 150);
if (!$ret) {
\OC_Log::write(self::TAG, 'Couldn\'t resize image', \OC_Log::ERROR);
unset($image);
return false;
}
$image->save($gallery_path . '/' . $path);
return $image;
}
示例2: getThumbnail
public static function getThumbnail($image_name, $owner = null)
{
if (!$owner) {
$owner = OCP\USER::getUser();
}
$save_dir = OCP\Config::getSystemValue("datadirectory") . '/' . $owner . '/gallery/';
$save_dir .= dirname($image_name) . '/';
$image_path = $image_name;
$thumb_file = $save_dir . basename($image_name);
if (!is_dir($save_dir)) {
mkdir($save_dir, 0777, true);
}
if (file_exists($thumb_file)) {
$image = new OC_Image($thumb_file);
} else {
$image_path = OC_Filesystem::getLocalFile($image_path);
if (!file_exists($image_path)) {
return null;
}
$image = new OC_Image($image_path);
if ($image->valid()) {
$image->centerCrop(200);
$image->fixOrientation();
$image->save($thumb_file);
}
}
if ($image->valid()) {
return $image;
} else {
$image->destroy();
}
return null;
}
示例3: search
function search($query)
{
$files = OC_Filesystem::search($query);
$results = array();
foreach ($files as $file) {
if (OC_Filesystem::is_dir($file)) {
$results[] = new OC_Search_Result(basename($file), '', OC_Helper::linkTo('files', 'index.php?dir=' . $file), 'Files');
} else {
$mime = OC_Filesystem::getMimeType($file);
$mimeBase = substr($mime, 0, strpos($mime, '/'));
switch ($mimeBase) {
case 'audio':
break;
case 'text':
$results[] = new OC_Search_Result(basename($file), '', OC_Helper::linkTo('files', 'download.php?file=' . $file), 'Text');
break;
case 'image':
$results[] = new OC_Search_Result(basename($file), '', OC_Helper::linkTo('files', 'download.php?file=' . $file), 'Images');
break;
default:
if ($mime == 'application/xml') {
$results[] = new OC_Search_Result(basename($file), '', OC_Helper::linkTo('files', 'download.php?file=' . $file), 'Text');
} else {
$results[] = new OC_Search_Result(basename($file), '', OC_Helper::linkTo('files', 'download.php?file=' . $file), 'Files');
}
}
}
}
return $results;
}
开发者ID:Teino1978-Corp,项目名称:Teino1978-Corp-owncloud_.htaccess-,代码行数:30,代码来源:owncloud_lib_search_provider_file.php
示例4: create_execution_env
/**
*
* @param type $study_name the name of the study directory
* @return the job id
*/
function create_execution_env($study_name, $script_name)
{
include 'config.inc.php';
$jobid = create_job_id($study_name, $script_name);
$job_dir = get_job_exec_dir($jobid);
while (is_dir($job_dir)) {
// the sandbox directory is already existing, sleep 1 second and generate another ID
sleep(1);
$jobid = create_job_id($study_name, $script_name);
$job_dir = get_job_exec_dir($jobid);
}
mkdir($job_dir, 0777, true);
// [job_root_dir]/[job_id]/data --> ../../data/[fs_root]/[study_name]/data
$datadir = $NC_CONFIG["symlink_prefix"] . "/" . $study_name . "/data";
$pipelinedir = get_absolute_path($study_name . "/pipeline");
$resultsdir = $NC_CONFIG["symlink_prefix"] . "/" . $study_name . "/results/" . $jobid;
OC_Filesystem::mkdir("{$study_name}/results/{$jobid}");
# le dir /data e /results sono link simbolici alle vere directory del caso di studio
mkdir($job_dir . "/pipeline");
symlink($datadir, $job_dir . "/data");
symlink($resultsdir, $job_dir . "/results");
# creo il file in cui verrà rediretto lo standard output
$date = date("Y-m-d H:i:s");
OC_Filesystem::file_put_contents(get_job_output_file($study_name, $jobid), "Standard output for job {$jobid}, run at {$date}\n");
$jobinfo = array("jobid" => $jobid, "study" => $study_name);
save_job_info($study_name, $jobid, $jobinfo);
# copia gli script del caso di studio nella pipeline
copy_dir($pipelinedir, $job_dir . "/pipeline");
return $jobid;
}
示例5: compressTarget
/**
* Compress File or Folder
* @param $target The target to compress
* @return Boolean
*/
public static function compressTarget($target)
{
$oc_target = OC::$CONFIG_DATADIRECTORY . $target;
if (OC_Filesystem::is_file($target)) {
$fileinfo = pathinfo($oc_target);
$archiveName = $fileinfo['filename'];
$dirTarget = $fileinfo['dirname'];
} else {
$archiveName = basename($oc_target);
$dirTarget = dirname($oc_target);
}
$archiveName .= '.zip';
if (file_exists($dirTarget . '/' . $archiveName)) {
$archiveName = md5(rand()) . '_' . $archiveName;
}
$zip = new ZipArchive();
if ($zip->open($dirTarget . '/' . $archiveName, ZipArchive::CREATE) === TRUE) {
if (!is_dir($oc_target)) {
$zip->addFile($oc_target, basename($oc_target));
} else {
self::addFolderToZip($oc_target, $zip, basename($oc_target) . '/');
}
}
$zip->close();
}
示例6: thumb
function thumb($path)
{
$thumb_path = \OCP\Config::getSystemValue('datadirectory') . '/' . \OC_User::getUser() . '/reader';
if (file_exists($thumb_path . $path)) {
return new \OC_Image($thumb_path . $path);
}
if (!\OC_Filesystem::file_exists($path)) {
return false;
}
}
示例7: testSimple
public function testSimple()
{
$file = OC::$SERVERROOT . '/3rdparty/MDB2.php';
$original = file_get_contents($file);
OC_Filesystem::file_put_contents('/file', $original);
OC_FileProxy::$enabled = false;
$stored = OC_Filesystem::file_get_contents('/file');
OC_FileProxy::$enabled = true;
$fromFile = OC_Filesystem::file_get_contents('/file');
$this->assertNotEqual($original, $stored);
$this->assertEqual($original, $fromFile);
}
示例8: getPresentations
public static function getPresentations()
{
$presentations = array();
$list = \OC_FileCache::searchByMime('application', 'zip');
foreach ($list as $l) {
$info = pathinfo($l);
$size = \OC_Filesystem::filesize($l);
$mtime = \OC_Filesystem::filemtime($l);
$entry = array('url' => $l, 'name' => $info['filename'], 'size' => $size, 'mtime' => $mtime);
$presentations[] = $entry;
}
return $presentations;
}
示例9: 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);
if ($length > OC_Filesystem::free_space($parentUri)) {
throw new Sabre_DAV_Exception('Quota exceeded. File is too big.');
}
}
return true;
}
示例10: createDataScope
public static function createDataScope($appUrl, $userAddress, $dataScope)
{
$token = uniqid();
self::addToken($token, $appUrl, $userAddress, $dataScope);
//TODO: input checking on $userAddress and $dataScope
list($userName, $userHost) = explode('@', $userAddress);
OC_Util::setupFS(OC_User::getUser());
$scopePathParts = array('remoteStorage', 'webdav', $userHost, $userName, $dataScope);
for ($i = 0; $i <= count($scopePathParts); $i++) {
$thisPath = '/' . implode('/', array_slice($scopePathParts, 0, $i));
if (!OC_Filesystem::file_exists($thisPath)) {
OC_Filesystem::mkdir($thisPath);
}
}
return $token;
}
开发者ID:Teino1978-Corp,项目名称:Teino1978-Corp-owncloud_.htaccess-,代码行数:16,代码来源:owncloud_apps_remoteStorage_lib_remoteStorage.php
示例11: getID
function getID($path)
{
// use the share table from the db to find the item source if the file was reshared because shared files
//are not stored in the file cache.
if (substr(OC_Filesystem::getMountPoint($path), -7, 6) == "Shared") {
$path_parts = explode('/', $path, 5);
$user = $path_parts[1];
$intPath = '/' . $path_parts[4];
$query = \OC_DB::prepare('SELECT `item_source` FROM `*PREFIX*share` WHERE `uid_owner` = ? AND `file_target` = ? ');
$result = $query->execute(array($user, $intPath));
$row = $result->fetchRow();
$fileSource = $row['item_source'];
} else {
$fileSource = OC_Filecache::getId($path, '');
}
return $fileSource;
}
示例12: createCategories
public static function createCategories($appUrl, $categories)
{
$token = uniqid();
OC_Util::setupFS(OC_User::getUser());
self::addToken($token, $appUrl, $categories);
foreach (explode(',', $categories) as $category) {
//TODO: input checking on $category
$scopePathParts = array('remoteStorage', $category);
for ($i = 0; $i <= count($scopePathParts); $i++) {
$thisPath = '/' . implode('/', array_slice($scopePathParts, 0, $i));
if (!OC_Filesystem::file_exists($thisPath)) {
OC_Filesystem::mkdir($thisPath);
}
}
}
return base64_encode('remoteStorage:' . $token);
}
示例13: getFolderContent
/**
* get all files and folders in a folder
* @param string path
* @param string root (optional)
* @return array
*
* returns an array of assiciative arrays with the following keys:
* - path
* - name
* - size
* - mtime
* - ctime
* - mimetype
* - encrypted
* - versioned
*/
public static function getFolderContent($path, $root = false, $mimetype_filter = '')
{
if ($root === false) {
$root = OC_Filesystem::getRoot();
}
$parent = OC_FileCache::getId($path, $root);
if ($parent == -1) {
return array();
}
$query = OC_DB::prepare('SELECT `id`,`path`,`name`,`ctime`,`mtime`,`mimetype`,`size`,`encrypted`,`versioned`,`writable` FROM `*PREFIX*fscache` WHERE `parent`=? AND (`mimetype` LIKE ? OR `mimetype` = ?)');
$result = $query->execute(array($parent, $mimetype_filter . '%', 'httpd/unix-directory'))->fetchAll();
if (is_array($result)) {
return $result;
} else {
OC_Log::write('files', 'getFolderContent(): file not found in cache (' . $path . ')', OC_Log::DEBUG);
return false;
}
}
示例14: handleStoreSettings
function handleStoreSettings($root, $order)
{
if (!OC_Filesystem::file_exists($root)) {
OCP\JSON::error(array('cause' => 'No such file or directory'));
return;
}
if (!OC_Filesystem::is_dir($root)) {
OCP\JSON::error(array('cause' => $root . ' is not a directory'));
return;
}
$current_root = OCP\Config::getUserValue(OCP\USER::getUser(), 'gallery', 'root', '/');
$root = trim($root);
$root = rtrim($root, '/') . '/';
$rescan = $current_root == $root ? 'no' : 'yes';
OCP\Config::setUserValue(OCP\USER::getUser(), 'gallery', 'root', $root);
OCP\Config::setUserValue(OCP\USER::getUser(), 'gallery', 'order', $order);
OCP\JSON::success(array('rescan' => $rescan));
}
示例15: getFreeSpace
/**
* get the free space in the path's owner home folder
* @param path
* @return int
*/
private function getFreeSpace($path)
{
$storage = OC_Filesystem::getStorage($path);
$owner = $storage->getOwner($path);
$totalSpace = $this->getQuota($owner);
if ($totalSpace == -1) {
return -1;
}
$rootInfo = OC_FileCache::get('', "/" . $owner . "/files");
// TODO Remove after merge of share_api
if (OC_FileCache::inCache('/Shared', "/" . $owner . "/files")) {
$sharedInfo = OC_FileCache::get('/Shared', "/" . $owner . "/files");
} else {
$sharedInfo = null;
}
$usedSpace = isset($rootInfo['size']) ? $rootInfo['size'] : 0;
$usedSpace = isset($sharedInfo['size']) ? $usedSpace - $sharedInfo['size'] : $usedSpace;
return $totalSpace - $usedSpace;
}