本文整理汇总了PHP中File::getPath方法的典型用法代码示例。如果您正苦于以下问题:PHP File::getPath方法的具体用法?PHP File::getPath怎么用?PHP File::getPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类File
的用法示例。
在下文中一共展示了File::getPath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: indexCrawledDocuments
/**
* Indexes document that was set in __construct.
*/
public function indexCrawledDocuments()
{
$sFileName = $this->oFile->getName();
$oFileMinorDocType = $this->oDbr->selectRow('image', 'img_minor_mime', array('img_name' => $sFileName, 'img_major_mime' => 'application'));
if ($oFileMinorDocType === false) {
return;
}
$sFileDocType = $this->mimeDecoding($oFileMinorDocType->img_minor_mime, $sFileName);
if (!$this->checkDocType($sFileDocType, $sFileName)) {
return;
}
$sFileTimestamp = $this->oFile->getTimestamp();
$sVirtualFilePath = $this->oFile->getPath();
$oFileRepoLocalRef = $this->oFile->getRepo()->getLocalReference($sVirtualFilePath);
if (!is_null($oFileRepoLocalRef)) {
$sFilePath = $oFileRepoLocalRef->getPath();
}
if ($this->checkExistence($sVirtualFilePath, 'repo', $sFileTimestamp, $sFileName)) {
return;
}
$sFileText = $this->getFileText($sFilePath, $sFileName);
$doc = $this->makeRepoDocument($sFileDocType, $sFileName, $sFileText, $sFilePath, $sFileTimestamp, $sVirtualFilePath);
if ($doc) {
// mode and ERROR_MSG_KEY are only passed for the case when addDocument fails
$this->oMainControl->addDocument($doc, $this->mode, self::S_ERROR_MSG_KEY);
}
}
开发者ID:hfroese,项目名称:mediawiki-extensions-BlueSpiceExtensions,代码行数:30,代码来源:BuildIndexMwSingleFile.class.php
示例2: copy
public function copy($destination, $overwrite = false, $mt = false)
{
// if (dirname($destination) == ".") {
// $destination = $this->getDirectory() . DS . $destination;
// }
$destination = $this->preparePath($destination);
if (strcmp(substr($destination, -1), DS) == 0) {
$destination .= $this->getName();
}
$file = new File($destination);
$dir = new Directory($file->getDirectory());
if (!$dir->exists() && !$dir->make()) {
throw new FileException(array("Directory '%s' not exists.", $dir->getPath()));
}
if (!$overwrite && $file->exists()) {
throw new FileException(array("File '%s' already exists.", $file->getPath()));
}
if ($file->exists() && !$file->delete()) {
throw new FileException(array("File '%s' cannot be deleted.", $file->getPath()));
}
if (!copy($this->pathAbsolute, $file->getPathAbsolute())) {
throw new FileException(array("Failed to copy file '%s'.", $this->path));
}
if ($mt) {
$filemtime = $this->getModificationTime();
@touch($file->getPathAbsolute(), $filemtime);
}
return $file;
}
示例3: execute
/**
* @return void
*/
public function execute()
{
if (is_null($this->file)) {
throw new \Exception('ファイルを指定してください');
}
$file = new File();
$file->setPath('copy_of_' . $this->file->getPath());
$file->create();
}
示例4: __construct
/**
* Construct the iterator with a file instance
* @param File $file Instance of a file object.
* @throws \InvalidArgumentException
*/
public function __construct(File $file)
{
if (!$file->exists()) {
throw new \InvalidArgumentException('The file "' . $file->getPath() . '" does not exist');
}
if (!$file->isReadable()) {
throw new \InvalidArgumentException('The file "' . $file->getPath() . '" is not readable.');
}
$this->file = $file;
$this->file->open('r');
}
示例5: testProps
function testProps()
{
$storage_test_root = "/" . FRAMEWORK_CORE_PATH . "tests/io/storage_dir/";
Storage::set_storage_root($storage_test_root);
$test_file = new File("/" . FRAMEWORK_CORE_PATH . "tests/io/file_props_test.php");
$this->assertFalse($test_file->hasStoredProps(), "Il file ha delle proprieta' con lo storage vuoto!!");
$storage = $test_file->getStoredProps();
$storage->add("test", array("hello" => 1, "world" => "good"));
$this->assertTrue($test_file->hasStoredProps(), "Il file storage delle proprieta' non e' stato creato!!");
$file_path = $test_file->getPath();
$sum = md5($file_path);
$store_subdir = "_" . substr($sum, 0, 1);
$storage_test_root_dir = new Dir($storage_test_root);
$real_store_dir = $storage_test_root_dir->getSingleSubdir();
$all_dirs = $real_store_dir->listFiles();
$props_file_dir = $all_dirs[0];
$this->assertEqual($props_file_dir->getName(), $store_subdir, "La directory creata non corrisponde!!");
$final_stored_path = new File($real_store_dir->getPath() . $props_file_dir->getName() . DS . $sum . ".ini");
$this->assertTrue($final_stored_path->exists(), "Il file finale delle props non e' stato trovato!!");
$test_file->deleteStoredProps();
$this->assertFalse($test_file->hasStoredProps(), "Il file delle proprieta' non e' stato eliminato!!");
$all_files = $real_store_dir->listFiles();
foreach ($all_files as $f) {
$f->delete(true);
}
Storage::set_storage_root(Storage::get_default_storage_root());
}
示例6: newFile
public function newFile($name, $contents)
{
$file = new File($this->t, $name);
$path = new Folder($file->getPath());
$path->exists() || $path->create();
$file->out()->write($contents);
}
示例7: updateFileHeaders
protected function updateFileHeaders(File $file, array $headers)
{
$status = $file->getRepo()->getBackend()->describe(['src' => $file->getPath(), 'headers' => $headers]);
if (!$status->isGood()) {
$this->error("Encountered error: " . print_r($status, true));
}
}
示例8: getPath
/**
* @return string
*/
public function getPath() : string
{
if (!$this->hasPath()) {
$this->setPath($this->createPath());
}
return parent::getPath();
}
示例9: testGetPath
/**
* Tests File::getPath
*/
public function testGetPath()
{
$spl = $this->getFileInfo();
$file = new File($spl);
$path = $file->getPath();
$this->assertEquals($spl->getPath(), $path);
}
示例10: __construct
/**
* Constructor - Defines the log file to be written
*
* @param string $filepath Path of the log file
*/
public function __construct($filepath)
{
$filepath = DATA_DIR . Config::DIR_DATA_LOGS . $filepath;
if (!File::exists(File::getPath($filepath))) {
throw new Exception('Log directory "' . $filepath . '" not found!');
}
$this->filepath = $filepath;
}
示例11: execute
/**
* Executes a program and returns the return code.
* Output from command is logged at INFO level.
* @return int Return code from execution.
*/
public function execute()
{
// test if os match
$myos = Phing::getProperty("os.name");
$this->log("Myos = " . $myos, PROJECT_MSG_VERBOSE);
if ($this->os !== null && strpos($os, $myos) === false) {
// this command will be executed only on the specified OS
$this->log("Not found in " . $os, PROJECT_MSG_VERBOSE);
return 0;
}
if ($this->dir !== null) {
if ($this->dir->isDirectory()) {
$currdir = getcwd();
@chdir($this->dir->getPath());
} else {
throw new BuildException("Can't chdir to:" . $this->dir->__toString());
}
}
if ($this->escape == true) {
// FIXME - figure out whether this is correct behavior
$this->command = escapeshellcmd($this->command);
}
if ($this->error !== null) {
$this->command .= ' 2> ' . $this->error->getPath();
$this->log("Writing error output to: " . $this->error->getPath());
}
if ($this->output !== null) {
$this->command .= ' 1> ' . $this->output->getPath();
$this->log("Writing standard output to: " . $this->output->getPath());
} elseif ($this->spawn) {
$this->command .= ' 1>/dev/null';
$this->log("Sending ouptut to /dev/null");
}
// If neither output nor error are being written to file
// then we'll redirect error to stdout so that we can dump
// it to screen below.
if ($this->output === null && $this->error === null) {
$this->command .= ' 2>&1';
}
// we ignore the spawn boolean for windows
if ($this->spawn) {
$this->command .= ' &';
}
$this->log("Executing command: " . $this->command);
$output = array();
$return = null;
exec($this->command, $output, $return);
if ($this->dir !== null) {
@chdir($currdir);
}
foreach ($output as $line) {
$this->log($line, $this->passthru ? PROJECT_MSG_INFO : PROJECT_MSG_VERBOSE);
}
if ($return != 0 && $this->checkreturn) {
throw new BuildException("Task exited with code {$return}");
}
return $return;
}
示例12: testGetSectorNames
function testGetSectorNames()
{
$f = new File("/framework/core/tests/pages/layout/my_test.layout.php");
$l = new Layout();
$l->__setup($f->getPath(), "my_test.layout.php", new Tree());
$this->assertEqual(count($l->getSectorNames()), 3, "Il numero dei settori non coincide!!");
$sector_names = $l->getSectorNames();
$this->assertEqual($sector_names[0], "/page/headers", "Il nome del settore non coincide!! : " . $sector_names[0]);
$this->assertEqual($sector_names[1], "/content", "Il nome del settore non coincide!! : " . $sector_names[1]);
$this->assertEqual($sector_names[2], "/footer", "Il nome del settore non coincide!! : " . $sector_names[2]);
}
示例13: get_layout_cache_key
private function get_layout_cache_key()
{
if ($this->layout_cache_key != null) {
return $this->layout_cache_key;
}
$layout_class_source = ClassLoader::instance()->get_element_content_by_name(get_class($this));
$f = new File("/" . $this->layout_path);
$layout_file_path = $f->getPath();
$layout_file_size = $f->getSize();
$layout_modification_time = $f->getModificationTime();
$this->layout_cache_key = md5($layout_class_source . $layout_file_path . $layout_file_size . $layout_modification_time);
return $this->layout_cache_key;
}
示例14: extract
static function extract($f, $dir)
{
$reader = $f->openReader();
$binarydata = $reader->read(3);
$data = unpack("a3", $binarydata);
if ($data[1] !== self::FF_ARCHIVE_HEADER) {
throw new InvalidDataException("Intestazione del file non valida : " . $data[1]);
}
$binarydata = $reader->read(2 + 2 + 2);
$data = unpack("v3", $binarydata);
if ($data[1] !== self::CURRENT_MAJOR || $data[2] !== self::CURRENT_MINOR || $data[3] !== self::CURRENT_REV) {
throw new InvalidDataException("Versione del file non supportata!! : " . $data[1] . "-" . $data[2] . "-" . $data[3]);
}
$binarydata = $reader->read(2);
$data = unpack("v", $binarydata);
$num_entries = $data[1];
$i = 0;
while ($i < $num_entries) {
$binarydata = $reader->read(2);
$data = unpack("v", $binarydata);
$entry_type = $data[1];
$binarydata = $reader->read(2);
$data = unpack("v", $binarydata);
$path_length = $data[1];
$binarydata = $reader->read($path_length);
$data = unpack("a*", $binarydata);
$path = $data[1];
if ($entry_type === self::ENTRY_TYPE_DIR) {
$d = $dir->newSubdir($path);
$d->touch();
}
if ($entry_type === self::ENTRY_TYPE_FILE) {
$binarydata = $reader->read(4);
$data = unpack("V", $binarydata);
$num_bytes = $data[1];
$compressed_file_data = $reader->read($num_bytes);
$uncompressed_file_data = gzuncompress($compressed_file_data);
$f = new File($dir->getPath() . $path);
$writer = $f->openWriter();
$writer->write($uncompressed_file_data);
$writer->close();
$sha1_checksum = $reader->read(20);
if (strcmp($sha1_checksum, sha1_file($f->getFullPath(), true)) !== 0) {
throw new InvalidDataException("La somma sha1 non corrisponde per il file : " . $f->getPath());
}
}
$i++;
}
$reader->close();
}
示例15: require_script_file
public static function require_script_file($file)
{
if ($file instanceof File) {
$file_object = $file;
} else {
$file_object = new File($file);
}
if (!$file_object->exists()) {
throw new Exception("Script not found : " . $file);
} else {
$path_with_hash = $file_object->getPath() . "?hash=" . md5($file_object->getModificationTime());
self::require_script($path_with_hash);
}
}