本文整理汇总了PHP中OC_Filesystem::is_file方法的典型用法代码示例。如果您正苦于以下问题:PHP OC_Filesystem::is_file方法的具体用法?PHP OC_Filesystem::is_file怎么用?PHP OC_Filesystem::is_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC_Filesystem
的用法示例。
在下文中一共展示了OC_Filesystem::is_file方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: scanFolder
/**
* scan a folder for music
* @param string $path
* @return int the number of songs found
*/
public static function scanFolder($path)
{
if (OC_Filesystem::is_dir($path)) {
$songs = 0;
if ($dh = OC_Filesystem::opendir($path)) {
while (($filename = readdir($dh)) !== false) {
if ($filename != '.' and $filename != '..' and substr($filename, 0, 1) != '.') {
$file = $path . '/' . $filename;
if (OC_Filesystem::is_dir($file)) {
$songs += self::scanFolder($file);
} elseif (OC_Filesystem::is_file($file)) {
$data = self::scanFile($file);
if ($data) {
$songs++;
}
}
}
}
}
} elseif (OC_Filesystem::is_file($path)) {
$songs = 1;
self::scanFile($path);
} else {
$songs = 0;
}
return $songs;
}
开发者ID:Teino1978-Corp,项目名称:Teino1978-Corp-owncloud_.htaccess-,代码行数:32,代码来源:owncloud_apps_media_lib_scanner.php
示例2: 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();
}
示例3: 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 .= '.tar';
if (file_exists($dirTarget . '/' . $archiveName)) {
$archiveName = md5(rand()) . '_' . $archiveName;
}
require_once '../config/config.php';
exec($_CompressConf['tar_bin_path'] . " cf " . $dirTarget . '/' . $archiveName . " " . $oc_target);
exec($_CompressConf['gzip_bin_path'] . " -9 " . $dirTarget . '/' . $archiveName);
}
示例4: 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_Filesystem::is_file($file)) {
$tmpFile = OC_Filesystem::toTmpFile($file);
OC_Files::$tmpFiles[] = $tmpFile;
$zip->addFile($tmpFile, $internalDir . $filename);
} elseif (OC_Filesystem::is_dir($file)) {
self::zipAddDir($file, $zip, $internalDir);
}
}
}
示例5: 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_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_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);
}
示例6: fread
*
* Copyright 2013 EnginSoft S.p.A.
* All rights reserved
*/
$filename = $_POST['filename'];
$json = false;
if (isset($_POST['json'])) {
$json = (bool) $_POST["json"];
}
/*
* max size of output file, to avoid reading a very big output and clogging the network
*/
$MAX_SIZE = 1024 * 512;
# "512k of memory should be enough for everyone"
$content = "";
if (OC_Filesystem::is_file($filename) && OC_Filesystem::is_readable($filename)) {
if (OC_Filesystem::filesize($filename) > $MAX_SIZE) {
$handle = OC_Filesystem::fopen($filename, "r");
if ($handle) {
$content = fread($handle, $MAX_SIZE);
fclose($handle);
}
} else {
$content = OC_Filesystem::file_get_contents($filename);
}
} else {
echo "ERROR: Cannot read " . $filename;
}
if ($json) {
$json_obj = json_decode($content);
foreach ($json_obj as $key => $value) {
示例7: get_job_info
/**
* Returns an associative array with the info associated with a running job
* the array contains the keys:
* status (either RUNNING, KILLED, FINISHED)
* pid (numeric)
* start_date
*
* if the $study parameter does not represent a valid case study, or if $jobid does not exist
* or if the
*
* @param type $study
* @param type $jobid
* @return array an array with the job info, containing the key "pid", "job_id"
*/
function get_job_info($study, $jobid)
{
$path = get_job_info_file($study, $jobid);
if (OC_Filesystem::is_file($path)) {
$json = OC_Filesystem::file_get_contents($path);
return json_decode($json, true);
// true for returning an associative array
} else {
return false;
}
}