本文整理汇总了PHP中FileUtil::setContents方法的典型用法代码示例。如果您正苦于以下问题:PHP FileUtil::setContents方法的具体用法?PHP FileUtil::setContents怎么用?PHP FileUtil::setContents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileUtil
的用法示例。
在下文中一共展示了FileUtil::setContents方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: set_contents
public function set_contents()
{
$data = 'Test';
$f = new Stream();
$this->assertEquals(strlen($data), FileUtil::setContents($f, $data), 'bytes written equals');
$this->assertEquals($data, FileUtil::getContents($f));
}
示例2: setUp
public function setUp()
{
$tempDir = realpath(System::tempDir());
$this->fixture = new FilesystemPropertySource($tempDir);
// Create a temporary ini file
$this->tempFile = new File($tempDir, 'temp.ini');
FileUtil::setContents($this->tempFile, "[section]\nkey=value\n");
}
示例3: setUp
/**
* Sets up test case - creates temporary file
*
* @return void
*/
public function setUp()
{
try {
$this->file = new TempFile();
FileUtil::setContents($this->file, 'Created by FileInputStreamTest');
} catch (IOException $e) {
throw new PrerequisitesNotMetError('Cannot write temporary file', $e, [$this->file]);
}
}
示例4: perform
/**
* Execute action
*
* @return int
*/
public function perform()
{
$this->archive->open(ARCHIVE_READ);
$args = $this->getArguments();
while ($entry = $this->archive->getEntry()) {
if (!$this->_filter($entry, $args)) {
continue;
}
$f = new File($entry);
$data = $this->archive->extract($entry);
if (!($this->options & Options::SIMULATE)) {
// Create folder on demand. Note that inside a XAR, the directory
// separator is *ALWAYS* a forward slash, so we need to change
// it to whatever the OS we're currently running on uses.
$dir = new Folder(str_replace('/', DIRECTORY_SEPARATOR, dirname($entry)));
if (!$dir->exists()) {
$dir->create();
}
FileUtil::setContents($f, $data);
}
$this->options & Options::VERBOSE && $this->out->writeLinef('%10s %s', number_format(strlen($data), 0, FALSE, '.'), $entry);
}
$this->archive->close();
}
示例5: store
/**
* Store data
*
* @param string name
* @param string data
*/
protected function store($name, $data, $overwrite = TRUE)
{
$file = new File($this->path, $name);
mkdir($file->getPath(), 0755, true);
FileUtil::setContents($file, $data);
}
示例6: set_contents_writes_bytes
public function set_contents_writes_bytes()
{
$out = new MemoryOutputStream();
FileUtil::setContents(new File(Streams::writeableFd($out)), 'Test');
$this->assertEquals('Test', $out->getBytes());
}
示例7: readMalformedDataBC
public function readMalformedDataBC()
{
$s = new Stream();
FileUtil::setContents($s, '@@MALFORMED@@');
Image::loadFrom(new StreamReader(ref($s)));
}
示例8: store
/**
* Store data
*
* @param string name
* @param string data
*/
protected function store($name, $data)
{
FileUtil::setContents(new File($this->path, $name), $data);
}