本文整理汇总了PHP中FileSystem::getFileSystem方法的典型用法代码示例。如果您正苦于以下问题:PHP FileSystem::getFileSystem方法的具体用法?PHP FileSystem::getFileSystem怎么用?PHP FileSystem::getFileSystem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileSystem
的用法示例。
在下文中一共展示了FileSystem::getFileSystem方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetFileSystemReturnsCorrect
/**
* @dataProvider fileSystemMappingsDataProvider
*/
public function testGetFileSystemReturnsCorrect($expectedFileSystemClass, $fsTypeKey)
{
$this->_resetFileSystem();
Phing::setProperty('host.fstype', $fsTypeKey);
$system = FileSystem::getFileSystem();
$this->assertInstanceOf($expectedFileSystemClass, $system);
}
示例2: stream_open
/**
* @param $path
* @param $mode
* @param $options
* @param $opened_path
*
* @return bool
* @throws IOException
*/
public function stream_open($path, $mode, $options, &$opened_path)
{
// if we're on Windows, urldecode() the path again
if (FileSystem::getFileSystem()->getSeparator() == '\\') {
$path = urldecode($path);
}
$filepath = substr($path, 8);
$this->createDirectories(dirname($filepath));
$this->fp = fopen($filepath, $mode);
return true;
}
示例3: getFiles
private function getFiles()
{
$files = array();
foreach ($this->fileSets as $fs) {
$ds = $fs->getDirectoryScanner($this->project);
$dir = $fs->getDir($this->project);
$srcFiles = $ds->getIncludedFiles();
foreach ($srcFiles as $file) {
$files[] = $dir . FileSystem::getFileSystem()->getSeparator() . $file;
}
}
return $files;
}
示例4: stream_open
/**
* @param $path
* @param $mode
* @param $options
* @param $opened_path
* @return bool
* @throws IOException
*/
public function stream_open($path, $mode, $options, &$opened_path)
{
// if we're on Windows, urldecode() the path again
if (FileSystem::getFileSystem()->getSeparator() == '\\') {
$path = urldecode($path);
}
$filepath = substr($path, 8);
$this->createDirectories(dirname($filepath));
$this->fp = fopen($filepath, $mode);
if (!$this->fp) {
throw new BuildException("Unable to open stream for path {$path}");
}
return true;
}
示例5: main
public function main()
{
if ('' === $this->property) {
throw new BuildException('You must specify the property attribute!');
}
if (true === is_null($this->baseDir)) {
$baseDir = new PhingFile($this->project->getBaseDir());
$this->addBaseDir($baseDir);
}
$directorySeparator = FileSystem::getFileSystem()->getSeparator();
$baseName = $this->baseDir->getPath();
$baseNameParts = explode($directorySeparator, $baseName);
$numberOfBaseNameParts = count($baseNameParts);
if ($this->strip > $numberOfBaseNameParts) {
throw new BuildException('Cannot strip ' . $this->strip . ' components from a ' . $numberOfBaseNameParts . ' components path!');
}
while ($this->strip > 0) {
array_pop($baseNameParts);
$this->strip = $this->strip - 1;
}
$baseName = implode($directorySeparator, $baseNameParts);
$baseName = basename($baseName);
$this->project->setProperty($this->property, $baseName);
}
示例6: _checkFile1
/**
* @param PhingFile $file
* @return bool
* @throws IOException
*/
private function _checkFile1(PhingFile $file)
{
// Resolve symbolic links
if ($this->followSymlinks && $file->isLink()) {
$linkTarget = new PhingFile($file->getLinkTarget());
if ($linkTarget->isAbsolute()) {
$file = $linkTarget;
} else {
$fs = FileSystem::getFileSystem();
$file = new PhingFile($fs->resolve($fs->normalize($file->getParent()), $fs->normalize($file->getLinkTarget())));
}
}
if ($this->type !== null) {
if ($this->type === "dir") {
return $file->isDirectory();
} else {
if ($this->type === "file") {
return $file->isFile();
}
}
}
return $file->exists();
}
示例7: main
/**
* The main entry point method.
*/
public function main()
{
$project = $this->getProject();
require_once 'Net/FTP.php';
$ftp = new Net_FTP($this->host, $this->port);
$ret = $ftp->connect();
if (@PEAR::isError($ret)) {
throw new BuildException('Could not connect to FTP server ' . $this->host . ' on port ' . $this->port . ': ' . $ret->getMessage());
} else {
$this->log('Connected to FTP server ' . $this->host . ' on port ' . $this->port, $this->logLevel);
}
$ret = $ftp->login($this->username, $this->password);
if (@PEAR::isError($ret)) {
throw new BuildException('Could not login to FTP server ' . $this->host . ' on port ' . $this->port . ' with username ' . $this->username . ': ' . $ret->getMessage());
} else {
$this->log('Logged in to FTP server with username ' . $this->username, $this->logLevel);
}
if ($this->passive) {
$this->log('Setting passive mode', $this->logLevel);
$ret = $ftp->setPassive();
if (@PEAR::isError($ret)) {
$ftp->disconnect();
throw new BuildException('Could not set PASSIVE mode: ' . $ret->getMessage());
}
}
// append '/' to the end if necessary
$dir = substr($this->dir, -1) == '/' ? $this->dir : $this->dir . '/';
if ($this->clearFirst) {
// TODO change to a loop through all files and directories within current directory
$this->log('Clearing directory ' . $dir, $this->logLevel);
$ftp->rm($dir, true);
}
// Create directory just in case
$ret = $ftp->mkdir($dir, true);
if (@PEAR::isError($ret)) {
$ftp->disconnect();
throw new BuildException('Could not create directory ' . $dir . ': ' . $ret->getMessage());
}
$ret = $ftp->cd($dir);
if (@PEAR::isError($ret)) {
$ftp->disconnect();
throw new BuildException('Could not change to directory ' . $dir . ': ' . $ret->getMessage());
} else {
$this->log('Changed directory ' . $dir, $this->logLevel);
}
$fs = FileSystem::getFileSystem();
$convert = $fs->getSeparator() == '\\';
foreach ($this->filesets as $fs) {
$ds = $fs->getDirectoryScanner($project);
$fromDir = $fs->getDir($project);
$srcFiles = $ds->getIncludedFiles();
$srcDirs = $ds->getIncludedDirectories();
foreach ($srcDirs as $dirname) {
if ($convert) {
$dirname = str_replace('\\', '/', $dirname);
}
$this->log('Will create directory ' . $dirname, $this->logLevel);
$ret = $ftp->mkdir($dirname, true);
if (@PEAR::isError($ret)) {
$ftp->disconnect();
throw new BuildException('Could not create directory ' . $dirname . ': ' . $ret->getMessage());
}
}
foreach ($srcFiles as $filename) {
$file = new PhingFile($fromDir->getAbsolutePath(), $filename);
if ($convert) {
$filename = str_replace('\\', '/', $filename);
}
$this->log('Will copy ' . $file->getCanonicalPath() . ' to ' . $filename, $this->logLevel);
$ret = $ftp->put($file->getCanonicalPath(), $filename, true, $this->mode);
if (@PEAR::isError($ret)) {
$ftp->disconnect();
throw new BuildException('Could not deploy file ' . $filename . ': ' . $ret->getMessage());
}
}
}
$ftp->disconnect();
$this->log('Disconnected from FTP server', $this->logLevel);
}
示例8: transform
/**
* Transforms the DOM document
*/
protected function transform(DOMDocument $document)
{
if (!$this->toDir->exists()) {
throw new BuildException("Directory '" . $this->toDir . "' does not exist");
}
$xslfile = $this->getStyleSheet();
$xsl = new DOMDocument();
$xsl->load($xslfile->getAbsolutePath());
$proc = new XSLTProcessor();
if (defined('XSL_SECPREF_WRITE_FILE')) {
if (version_compare(PHP_VERSION, '5.4', "<")) {
ini_set("xsl.security_prefs", XSL_SECPREF_WRITE_FILE | XSL_SECPREF_CREATE_DIRECTORY);
} else {
$proc->setSecurityPrefs(XSL_SECPREF_WRITE_FILE | XSL_SECPREF_CREATE_DIRECTORY);
}
}
$proc->importStyleSheet($xsl);
$proc->setParameter('', 'output.sorttable', $this->useSortTable);
if ($this->format == "noframes") {
$writer = new FileWriter(new PhingFile($this->toDir, "phpunit-noframes.html"));
$writer->write($proc->transformToXML($document));
$writer->close();
} else {
ExtendedFileStream::registerStream();
$toDir = (string) $this->toDir;
// urlencode() the path if we're on Windows
if (FileSystem::getFileSystem()->getSeparator() == '\\') {
$toDir = urlencode($toDir);
}
// no output for the framed report
// it's all done by extension...
$proc->setParameter('', 'output.dir', $toDir);
$proc->transformToXML($document);
ExtendedFileStream::unregisterStream();
}
}
示例9: main
/**
* This method does the work.
* @return void
*/
function main()
{
if ($this->list === null && count($this->filesets) == 0) {
throw new BuildException("Need either list or nested fileset to iterate through");
}
if ($this->param === null) {
throw new BuildException("You must supply a property name to set on each iteration in param");
}
if ($this->calleeTarget === null) {
throw new BuildException("You must supply a target to perform");
}
$callee = $this->callee;
$callee->setTarget($this->calleeTarget);
$callee->setInheritAll(true);
$callee->setInheritRefs(true);
if (trim($this->list)) {
$arr = explode($this->delimiter, $this->list);
foreach ($arr as $value) {
$value = trim($value);
$this->log("Setting param '{$this->param}' to value '{$value}'", Project::MSG_VERBOSE);
$prop = $callee->createProperty();
$prop->setOverride(true);
$prop->setName($this->param);
$prop->setValue($value);
$callee->main();
}
}
$total_files = 0;
$total_dirs = 0;
// filesets
foreach ($this->filesets as $fs) {
$ds = $fs->getDirectoryScanner($this->project);
$fromDir = $fs->getDir($this->project);
$srcFiles = $ds->getIncludedFiles();
$srcDirs = $ds->getIncludedDirectories();
$this->log(count($srcDirs) . ' directories and ' . count($srcFiles) . ' files', Project::MSG_VERBOSE);
$filecount = count($srcFiles);
$total_files = $total_files + $filecount;
for ($j = 0; $j < $filecount; $j++) {
$value = $srcFiles[$j];
if ($this->param) {
$this->log("Setting param '{$this->param}' to value '{$value}'", Project::MSG_VERBOSE);
$prop = $callee->createProperty();
$prop->setOverride(true);
$prop->setName($this->param);
$prop->setValue($value);
}
if ($this->absparam) {
$prop = $callee->createProperty();
$prop->setOverride(true);
$prop->setName($this->absparam);
$prop->setValue($fromDir . FileSystem::getFileSystem()->getSeparator() . $value);
}
$callee->main();
}
$dircount = count($srcDirs);
$total_dirs = $total_dirs + $dircount;
for ($j = 0; $j < $dircount; $j++) {
$value = $srcDirs[$j];
if ($this->param) {
$this->log("Setting param '{$this->param}' to value '{$value}'", Project::MSG_VERBOSE);
$prop = $callee->createProperty();
$prop->setOverride(true);
$prop->setName($this->param);
$prop->setValue($value);
}
if ($this->absparam) {
$prop = $callee->createProperty();
$prop->setOverride(true);
$prop->setName($this->absparam);
$prop->setValue($fromDir . FileSystem::getFileSystem()->getSeparator() . $value);
}
$callee->main();
}
}
}
示例10: parseFiles
/**
* Build a list of files (from the fileset elements)
* and call the phpDocumentor parser
*
* @return string
*/
private function parseFiles()
{
$parser = $this->app['parser'];
$builder = $this->app['descriptor.builder'];
$builder->createProjectDescriptor();
$projectDescriptor = $builder->getProjectDescriptor();
$projectDescriptor->setName($this->title);
$paths = array();
// filesets
foreach ($this->filesets as $fs) {
$ds = $fs->getDirectoryScanner($this->project);
$dir = $fs->getDir($this->project);
$srcFiles = $ds->getIncludedFiles();
foreach ($srcFiles as $file) {
$paths[] = $dir . FileSystem::getFileSystem()->getSeparator() . $file;
}
}
$this->project->log("Will parse " . count($paths) . " file(s)", Project::MSG_VERBOSE);
$files = new \phpDocumentor\Fileset\Collection();
$files->addFiles($paths);
$mapper = new \phpDocumentor\Descriptor\Cache\ProjectDescriptorMapper($this->app['descriptor.cache']);
$mapper->garbageCollect($files);
$mapper->populate($projectDescriptor);
$parser->setPath($files->getProjectRoot());
$parser->setDefaultPackageName($this->defaultPackageName);
$parser->parse($builder, $files);
$mapper->save($projectDescriptor);
return $mapper;
}
示例11: main
/**
* The main entry point method.
*/
public function main()
{
$project = $this->getProject();
require_once 'Net/FTP.php';
$ftp = new Net_FTP($this->host, $this->port);
if ($this->ssl) {
$ret = $ftp->setSsl();
if (@PEAR::isError($ret)) {
throw new BuildException('SSL connection not supported by php' . ': ' . $ret->getMessage());
} else {
$this->log('Use SSL connection', $this->logLevel);
}
}
$ret = $ftp->connect();
if (@PEAR::isError($ret)) {
throw new BuildException('Could not connect to FTP server ' . $this->host . ' on port ' . $this->port . ': ' . $ret->getMessage());
} else {
$this->log('Connected to FTP server ' . $this->host . ' on port ' . $this->port, $this->logLevel);
}
$ret = $ftp->login($this->username, $this->password);
if (@PEAR::isError($ret)) {
throw new BuildException('Could not login to FTP server ' . $this->host . ' on port ' . $this->port . ' with username ' . $this->username . ': ' . $ret->getMessage());
} else {
$this->log('Logged in to FTP server with username ' . $this->username, $this->logLevel);
}
if ($this->passive) {
$this->log('Setting passive mode', $this->logLevel);
$ret = $ftp->setPassive();
if (@PEAR::isError($ret)) {
$ftp->disconnect();
throw new BuildException('Could not set PASSIVE mode: ' . $ret->getMessage());
}
}
// append '/' to the end if necessary
$dir = substr($this->dir, -1) == '/' ? $this->dir : $this->dir . '/';
if ($this->clearFirst) {
// TODO change to a loop through all files and directories within current directory
$this->log('Clearing directory ' . $dir, $this->logLevel);
$ftp->rm($dir, true);
}
// Create directory just in case
$ret = $ftp->mkdir($dir, true);
if (@PEAR::isError($ret)) {
$ftp->disconnect();
throw new BuildException('Could not create directory ' . $dir . ': ' . $ret->getMessage());
}
$ret = $ftp->cd($dir);
if (@PEAR::isError($ret)) {
$ftp->disconnect();
throw new BuildException('Could not change to directory ' . $dir . ': ' . $ret->getMessage());
} else {
$this->log('Changed directory ' . $dir, $this->logLevel);
}
$fs = FileSystem::getFileSystem();
$convert = $fs->getSeparator() == '\\';
foreach ($this->filesets as $fs) {
// Array for holding directory content informations
$remoteFileInformations = array();
$ds = $fs->getDirectoryScanner($project);
$fromDir = $fs->getDir($project);
$srcFiles = $ds->getIncludedFiles();
$srcDirs = $ds->getIncludedDirectories();
foreach ($srcDirs as $dirname) {
if ($convert) {
$dirname = str_replace('\\', '/', $dirname);
}
// Read directory informations, if file exists, else create the directory
if (!$this->_directoryInformations($ftp, $remoteFileInformations, $dirname)) {
$this->log('Will create directory ' . $dirname, $this->logLevel);
$ret = $ftp->mkdir($dirname, true);
if (@PEAR::isError($ret)) {
$ftp->disconnect();
throw new BuildException('Could not create directory ' . $dirname . ': ' . $ret->getMessage());
}
}
if ($this->dirmode) {
if ($this->dirmode == 'inherit') {
$mode = fileperms($dirname);
} else {
$mode = $this->dirmode;
}
// Because Net_FTP does not support a chmod call we call ftp_chmod directly
ftp_chmod($ftp->_handle, $mode, $dirname);
}
}
foreach ($srcFiles as $filename) {
$file = new PhingFile($fromDir->getAbsolutePath(), $filename);
if ($convert) {
$filename = str_replace('\\', '/', $filename);
}
$local_filemtime = filemtime($file->getCanonicalPath());
if (isset($remoteFileInformations[$filename]['stamp'])) {
$remoteFileModificationTime = $remoteFileInformations[$filename]['stamp'];
} else {
$remoteFileModificationTime = 0;
}
if (!$this->depends || $local_filemtime > $remoteFileModificationTime) {
//.........这里部分代码省略.........
示例12: resolveFile
/**
* Interpret the filename as a file relative to the given file -
* unless the filename already represents an absolute filename.
*
* @param $file the "reference" file for relative paths. This
* instance must be an absolute file and must not contain
* ./ or ../ sequences (same for \ instead of /).
* @param $filename a file name
*
* @return PhingFile A PhingFile object pointing to an absolute file that doesn't contain ./ or ../ sequences
* and uses the correct separator for the current platform.
*/
function resolveFile($file, $filename)
{
// remove this and use the static class constant File::seperator
// as soon as ZE2 is ready
$fs = FileSystem::getFileSystem();
$filename = str_replace('/', $fs->getSeparator(), str_replace('\\', $fs->getSeparator(), $filename));
// deal with absolute files
if (StringHelper::startsWith($fs->getSeparator(), $filename) || strlen($filename) >= 2 && Character::isLetter($filename[0]) && $filename[1] === ':') {
return new PhingFile($this->normalize($filename));
}
if (strlen($filename) >= 2 && Character::isLetter($filename[0]) && $filename[1] === ':') {
return new PhingFile($this->normalize($filename));
}
$helpFile = new PhingFile($file->getAbsolutePath());
$tok = strtok($filename, $fs->getSeparator());
while ($tok !== false) {
$part = $tok;
if ($part === '..') {
$parentFile = $helpFile->getParent();
if ($parentFile === null) {
$msg = "The file or path you specified ({$filename}) is invalid relative to " . $file->getPath();
throw new IOException($msg);
}
$helpFile = new PhingFile($parentFile);
} else {
if ($part === '.') {
// Do nothing here
} else {
$helpFile = new PhingFile($helpFile, $part);
}
}
$tok = strtok($fs->getSeparator());
}
return new PhingFile($helpFile->getAbsolutePath());
}
示例13: replaceSeparator
protected function replaceSeparator($item)
{
$fs = FileSystem::getFileSystem();
return str_replace($fs->getSeparator(), '/', $item);
}
示例14: compareTo
/**
* Compares two abstract pathnames lexicographically. The ordering
* defined by this method depends upon the underlying system. On UNIX
* systems, alphabetic case is significant in comparing pathnames; on Win32
* systems it is not.
*
* @param PhingFile $file Th file whose pathname sould be compared to the pathname of this file.
*
* @return int Zero if the argument is equal to this abstract pathname, a
* value less than zero if this abstract pathname is
* lexicographically less than the argument, or a value greater
* than zero if this abstract pathname is lexicographically
* greater than the argument
*/
public function compareTo(PhingFile $file)
{
$fs = FileSystem::getFileSystem();
return $fs->compare($this, $file);
}
示例15: init
/**
* Initialize task.
* @return void
*/
public function init()
{
$this->fs = FileSystem::getFileSystem();
}