本文整理汇总了PHP中Espo\Core\Utils\Util::getSeparator方法的典型用法代码示例。如果您正苦于以下问题:PHP Util::getSeparator方法的具体用法?PHP Util::getSeparator怎么用?PHP Util::getSeparator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Espo\Core\Utils\Util
的用法示例。
在下文中一共展示了Util::getSeparator方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getFileList
/**
* Get a list of files in specified directory
*
* @param string $path string - Folder path, Ex. myfolder
* @param bool | int $recursively - Find files in subfolders
* @param string $filter - Filter for files. Use regular expression, Ex. \.json$
* @param bool $onlyFileType [null, true, false] - Filter for type of files/directories. If TRUE - returns only file list, if FALSE - only directory list
* @param bool $isReturnSingleArray - if need to return a single array of file list
*
* @return array
*/
public function getFileList($path, $recursively = false, $filter = '', $onlyFileType = null, $isReturnSingleArray = false)
{
$path = $this->concatPaths($path);
$result = array();
if (!file_exists($path) || !is_dir($path)) {
return $result;
}
$cdir = scandir($path);
foreach ($cdir as $key => $value) {
if (!in_array($value, array(".", ".."))) {
$add = false;
if (is_dir($path . Utils\Util::getSeparator() . $value)) {
if ($recursively || is_int($recursively) && $recursively != 0) {
$nextRecursively = is_int($recursively) ? $recursively - 1 : $recursively;
$result[$value] = $this->getFileList($path . Utils\Util::getSeparator() . $value, $nextRecursively, $filter, $onlyFileType);
} else {
if (!isset($onlyFileType) || !$onlyFileType) {
/*save only directories*/
$add = true;
}
}
} else {
if (!isset($onlyFileType) || $onlyFileType) {
/*save only files*/
$add = true;
}
}
if ($add) {
if (!empty($filter)) {
if (preg_match('/' . $filter . '/i', $value)) {
$result[] = $value;
}
} else {
$result[] = $value;
}
}
}
}
if ($isReturnSingleArray) {
return $this->getSingeFileList($result, $onlyFileType);
}
return $result;
}
示例2: getFileList
/**
* Get a list of files in specified directory
*
* @param string $path string - Folder path, Ex. myfolder
* @param bool | int $recursively - Find files in subfolders
* @param string $filter - Filter for files. Use regular expression, Ex. \.json$
* @param string $fileType [all, file, dir] - Filter for type of files/directories.
* @param bool $isReturnSingleArray - if need to return a single array of file list
*
* @return array
*/
public function getFileList($path, $recursively = false, $filter = '', $fileType = 'all', $isReturnSingleArray = false)
{
if (!file_exists($path)) {
return false;
}
$result = array();
$cdir = scandir($path);
foreach ($cdir as $key => $value) {
if (!in_array($value, array(".", ".."))) {
$add = false;
if (is_dir($path . Utils\Util::getSeparator() . $value)) {
if ($recursively || is_int($recursively) && $recursively != 0) {
$nextRecursively = is_int($recursively) ? $recursively - 1 : $recursively;
$result[$value] = $this->getFileList($path . Utils\Util::getSeparator() . $value, $nextRecursively, $filter, $fileType);
} else {
if (in_array($fileType, array('all', 'dir'))) {
$add = true;
}
}
} else {
if (in_array($fileType, array('all', 'file'))) {
$add = true;
}
}
if ($add) {
if (!empty($filter)) {
if (preg_match('/' . $filter . '/i', $value)) {
$result[] = $value;
}
} else {
$result[] = $value;
}
}
}
}
if ($isReturnSingleArray) {
return $this->getSingeFileList($result);
}
return $result;
}
示例3: testGetSeparator
public function testGetSeparator()
{
$this->assertEquals(DIRECTORY_SEPARATOR, Util::getSeparator());
}
示例4: chgrpRecurse
/**
* Change group permission recursive
*
* @param string $filename
* @param int $fileOctal - ex. 0644
* @param int $dirOctal - ex. 0755
*
* @return bool
*/
protected function chgrpRecurse($path, $group)
{
if (!file_exists($path)) {
return false;
}
if (!is_dir($path)) {
return $this->chgrpReal($path, $group);
}
$result = $this->chgrpReal($path, $group);
$allFiles = $this->getFileManager()->getFileList($path);
foreach ($allFiles as $item) {
$result &= $this->chgrpRecurse($path . Utils\Util::getSeparator() . $item, $group);
}
return (bool) $result;
}