本文整理汇总了PHP中OC\Files\Filesystem::is_file方法的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem::is_file方法的具体用法?PHP Filesystem::is_file怎么用?PHP Filesystem::is_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC\Files\Filesystem
的用法示例。
在下文中一共展示了Filesystem::is_file方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addDirRecursive
/**
* Stream directory recursively
* @param string $dir
* @param string $internalDir
*/
public function addDirRecursive($dir, $internalDir = '')
{
$dirname = basename($dir);
$rootDir = $internalDir . $dirname;
if (!empty($rootDir)) {
$this->streamerInstance->addEmptyDir($rootDir);
}
$internalDir .= $dirname . '/';
// prevent absolute dirs
$internalDir = ltrim($internalDir, '/');
$files = \OC\Files\Filesystem::getDirectoryContent($dir);
foreach ($files as $file) {
$filename = $file['name'];
$file = $dir . '/' . $filename;
if (\OC\Files\Filesystem::is_file($file)) {
$filesize = \OC\Files\Filesystem::filesize($file);
$fh = \OC\Files\Filesystem::fopen($file, 'r');
$this->addFileFromStream($fh, $internalDir . $filename, $filesize);
fclose($fh);
} elseif (\OC\Files\Filesystem::is_dir($file)) {
$this->addDirRecursive($file, $internalDir);
}
}
}
示例2: zipAddDir
/**
* @param string $dir
* @param ZipStreamer $zip
* @param string $internalDir
*/
public static function zipAddDir($dir, ZipStreamer $zip, $internalDir = '')
{
$dirname = basename($dir);
$rootDir = $internalDir . $dirname;
if (!empty($rootDir)) {
$zip->addEmptyDir($rootDir);
}
$internalDir .= $dirname .= '/';
// prevent absolute dirs
$internalDir = ltrim($internalDir, '/');
$files = \OC\Files\Filesystem::getDirectoryContent($dir);
foreach ($files as $file) {
$filename = $file['name'];
$file = $dir . '/' . $filename;
if (\OC\Files\Filesystem::is_file($file)) {
$fh = \OC\Files\Filesystem::fopen($file, 'r');
$zip->addFileFromStream($fh, $internalDir . $filename);
fclose($fh);
} elseif (\OC\Files\Filesystem::is_dir($file)) {
self::zipAddDir($file, $zip, $internalDir);
}
}
}
示例3: get
/**
* return the content of a file or return a zip file containing multiple files
*
* @param string $dir
* @param string $files ; separated list of files to download
* @param boolean $onlyHeader ; boolean to only send header of the request
*/
public static function get($dir, $files, $onlyHeader = false)
{
$view = \OC\Files\Filesystem::getView();
$getType = self::FILE;
$filename = $dir;
try {
if (is_array($files) && count($files) === 1) {
$files = $files[0];
}
if (!is_array($files)) {
$filename = $dir . '/' . $files;
if (!$view->is_dir($filename)) {
self::getSingleFile($view, $dir, $files, $onlyHeader);
return;
}
}
$name = 'download';
if (is_array($files)) {
$getType = self::ZIP_FILES;
$basename = basename($dir);
if ($basename) {
$name = $basename;
}
$filename = $dir . '/' . $name;
} else {
$filename = $dir . '/' . $files;
$getType = self::ZIP_DIR;
// downloading root ?
if ($files !== '') {
$name = $files;
}
}
$streamer = new Streamer();
OC_Util::obEnd();
self::lockFiles($view, $dir, $files);
$streamer->sendHeaders($name);
$executionTime = intval(OC::$server->getIniWrapper()->getNumeric('max_execution_time'));
set_time_limit(0);
if ($getType === self::ZIP_FILES) {
foreach ($files as $file) {
$file = $dir . '/' . $file;
if (\OC\Files\Filesystem::is_file($file)) {
$fileSize = \OC\Files\Filesystem::filesize($file);
$fh = \OC\Files\Filesystem::fopen($file, 'r');
$streamer->addFileFromStream($fh, basename($file), $fileSize);
fclose($fh);
} elseif (\OC\Files\Filesystem::is_dir($file)) {
$streamer->addDirRecursive($file);
}
}
} elseif ($getType === self::ZIP_DIR) {
$file = $dir . '/' . $files;
$streamer->addDirRecursive($file);
}
$streamer->finalize();
set_time_limit($executionTime);
self::unlockAllTheFiles($dir, $files, $getType, $view, $filename);
} catch (\OCP\Lock\LockedException $ex) {
self::unlockAllTheFiles($dir, $files, $getType, $view, $filename);
OC::$server->getLogger()->logException($ex);
$l = \OC::$server->getL10N('core');
$hint = method_exists($ex, 'getHint') ? $ex->getHint() : '';
\OC_Template::printErrorPage($l->t('File is currently busy, please try again later'), $hint);
} catch (\OCP\Files\ForbiddenException $ex) {
self::unlockAllTheFiles($dir, $files, $getType, $view, $filename);
OC::$server->getLogger()->logException($ex);
$l = \OC::$server->getL10N('core');
\OC_Template::printErrorPage($l->t('Can\'t read file'), $ex->getMessage());
} catch (\Exception $ex) {
self::unlockAllTheFiles($dir, $files, $getType, $view, $filename);
OC::$server->getLogger()->logException($ex);
$l = \OC::$server->getL10N('core');
$hint = method_exists($ex, 'getHint') ? $ex->getHint() : '';
\OC_Template::printErrorPage($l->t('Can\'t read file'), $hint);
}
}
示例4: copy
/**
* Copies a file or directory.
*
* This method must work recursively and delete the destination
* if it exists
*
* @param string $source
* @param string $destination
* @return void
*/
public function copy($source, $destination)
{
if (Filesystem::is_file($source)) {
Filesystem::copy($source, $destination);
} else {
Filesystem::mkdir($destination);
$dh = Filesystem::opendir($source);
if (is_resource($dh)) {
while (($subnode = readdir($dh)) !== false) {
if ($subnode == '.' || $subnode == '..') {
continue;
}
$this->copy($source . '/' . $subnode, $destination . '/' . $subnode);
}
}
}
list($destinationDir, ) = \Sabre_DAV_URLUtil::splitPath($destination);
$this->markDirty($destinationDir);
}
示例5: zipAddDir
public static function zipAddDir($dir, $zip, $internalDir = '')
{
$dirname = basename($dir);
$zip->addEmptyDir($internalDir . $dirname);
$internalDir .= $dirname .= '/';
$files = OC_Files::getDirectoryContent($dir);
foreach ($files as $file) {
$filename = $file['name'];
$file = $dir . '/' . $filename;
if (\OC\Files\Filesystem::is_file($file)) {
$tmpFile = \OC\Files\Filesystem::toTmpFile($file);
OC_Files::$tmpFiles[] = $tmpFile;
$zip->addFile($tmpFile, $internalDir . $filename);
} elseif (\OC\Files\Filesystem::is_dir($file)) {
self::zipAddDir($file, $zip, $internalDir);
}
}
}
示例6: getInternalFileAttachment
private static function getInternalFileAttachment($attachment) {
$path = urldecode($attachment['path']);
$path = substr($path, strpos($path, "/")+1 ); //remove root folder "files/"
$userId = OC_User::getUser();
if ( $attachment['owner'] == $userId ) {
// file-owner can use own path
$path = \OC\Files\Filesystem::getPath($attachment['fileid']);
} else {
$item_shared = OCP\Share::getItemSharedWithBySource('file', $attachment['fileid']);
if ( $item_shared != false ) { // if item is direct shared use shared-file target
$path = $item_shared['file_target'];
} else {
// else search shared parent folder
$path = "/" . self::getInheritedSharedPath( urldecode($attachment['path']), $userId, $attachment['owner'] );
}
$ocVersion = OCP\Util::getVersion();
if ( $ocVersion[0] < 7 ) {
$path = "/Shared" . $path;
}
}
$view = new \OC\Files\View('/' . $userId . '/files');
$fileinfo = $view->getFileInfo($path);
$download_url = OCP\Util::linkToRoute('download', array('file' => $path));
// File not found
if ( \OC\Files\Filesystem::is_file( $path ) == false ) {
$fileinfo['name'] = "File not found.";
$download_url = "#";
}
$result = array(
"type" => $attachment['type'],
"mimetype" => $fileinfo['mimetype'],
"name" => $fileinfo['name'],
"path" => $path,
"download_url" => $download_url
);
return $result;
}
示例7: header
header('WWW-Authenticate: Basic realm="ownCloud Server"');
header('HTTP/1.0 401 Unauthorized');
echo 'Valid credentials must be supplied';
exit;
} else {
if (!OC_User::login($_SERVER["PHP_AUTH_USER"], $_SERVER["PHP_AUTH_PW"])) {
exit;
}
}
}
list($type, $file) = explode('/', substr($path_info, 1 + strlen($service) + 1), 2);
if ($type != 'oc_chunked') {
OC_Response::setStatus(OC_Response::STATUS_NOT_FOUND);
die;
}
if (!\OC\Files\Filesystem::is_file($file)) {
OC_Response::setStatus(OC_Response::STATUS_NOT_FOUND);
die;
}
switch ($_SERVER['REQUEST_METHOD']) {
case 'PUT':
$input = fopen("php://input", "r");
$org_file = \OC\Files\Filesystem::fopen($file, 'rb');
$info = array('name' => basename($file));
$sync = new OC_FileChunking($info);
$result = $sync->signature_split($org_file, $input);
echo json_encode($result);
break;
default:
OC_Response::setStatus(OC_Response::STATUS_NOT_FOUND);
}
示例8: is_file
/**
* @deprecated OC_Filesystem is replaced by \OC\Files\Filesystem
*/
public static function is_file($path)
{
return \OC\Files\Filesystem::is_file($path);
}
示例9: get
/**
* return the content of a file or return a zip file containing multiple files
*
* @param string $dir
* @param string $files ; separated list of files to download
* @param boolean $onlyHeader ; boolean to only send header of the request
*/
public static function get($dir, $files, $onlyHeader = false)
{
$view = \OC\Files\Filesystem::getView();
if (is_array($files) && count($files) === 1) {
$files = $files[0];
}
if (is_array($files)) {
$getType = self::ZIP_FILES;
$basename = basename($dir);
if ($basename) {
$name = $basename;
} else {
$name = 'download';
}
$filename = $dir . '/' . $name;
} else {
$filename = $dir . '/' . $files;
if (\OC\Files\Filesystem::is_dir($dir . '/' . $files)) {
$getType = self::ZIP_DIR;
// downloading root ?
if ($files === '') {
$name = 'download';
} else {
$name = $files;
}
} else {
$getType = self::FILE;
$name = $files;
}
}
if ($getType === self::FILE) {
$streamer = false;
} else {
$streamer = new Streamer();
}
OC_Util::obEnd();
try {
if ($getType === self::FILE) {
$view->lockFile($filename, ILockingProvider::LOCK_SHARED);
}
if ($streamer) {
$streamer->sendHeaders($name);
} elseif (\OC\Files\Filesystem::isReadable($filename)) {
self::sendHeaders($filename, $name);
} elseif (!\OC\Files\Filesystem::file_exists($filename)) {
header("HTTP/1.0 404 Not Found");
$tmpl = new OC_Template('', '404', 'guest');
$tmpl->printPage();
exit;
} else {
header("HTTP/1.0 403 Forbidden");
die('403 Forbidden');
}
if ($onlyHeader) {
return;
}
if ($streamer) {
$executionTime = intval(ini_get('max_execution_time'));
set_time_limit(0);
if ($getType === self::ZIP_FILES) {
foreach ($files as $file) {
$file = $dir . '/' . $file;
if (\OC\Files\Filesystem::is_file($file)) {
$fileSize = \OC\Files\Filesystem::filesize($file);
$fh = \OC\Files\Filesystem::fopen($file, 'r');
$streamer->addFileFromStream($fh, basename($file), $fileSize);
fclose($fh);
} elseif (\OC\Files\Filesystem::is_dir($file)) {
$streamer->addDirRecursive($file);
}
}
} elseif ($getType === self::ZIP_DIR) {
$file = $dir . '/' . $files;
$streamer->addDirRecursive($file);
}
$streamer->finalize();
set_time_limit($executionTime);
} else {
\OC\Files\Filesystem::readfile($filename);
}
if ($getType === self::FILE) {
$view->unlockFile($filename, ILockingProvider::LOCK_SHARED);
}
} catch (\OCP\Lock\LockedException $ex) {
$l = \OC::$server->getL10N('core');
$hint = method_exists($ex, 'getHint') ? $ex->getHint() : '';
\OC_Template::printErrorPage($l->t('File is currently busy, please try again later'), $hint);
} catch (\Exception $ex) {
$l = \OC::$server->getL10N('core');
$hint = method_exists($ex, 'getHint') ? $ex->getHint() : '';
\OC_Template::printErrorPage($l->t('Can\'t read file'), $hint);
}
}
示例10: array
if ($path) {
$room = OC_Conversations::getRoom();
$userId = OC_User::getUser();
\OC_Util::setupFS($userId);
\OC\Files\Filesystem::initMountPoints($userId);
$view = new \OC\Files\View('/' . $userId . '/files');
$fileinfo = $view->getFileInfo($path);
$owner = $view->getOwner($path);
if (strpos($fileinfo['mimetype'], "image") !== false) {
$type = 'internal_image';
} else {
$type = 'internal_file';
}
$download_url = OCP\Util::linkToRoute('download', array('file' => $path));
// File not found
if (\OC\Files\Filesystem::is_file($path) == false) {
$fileinfo['name'] = "File not found.";
$download_url = "#";
}
// array for attachment template
$tmpl_arr = array("type" => $type, "mimetype" => $fileinfo['mimetype'], "path" => $path, "name" => $fileinfo['name'], "download_url" => $download_url);
// result array for new comment attachment data
$data = array("type" => $type, "fileid" => $fileinfo['fileid'], "path" => urlencode($fileinfo['path']), "owner" => $owner);
$room_arr = explode(":", $room);
$l = OC_L10N::get('conversations');
// store attachment template into variable
$tmpl = new OCP\Template('conversations', 'part.attachment');
$tmpl->assign('attachment', $tmpl_arr);
ob_start();
$tmpl->printPage();
if ($room_arr[0] == "group") {