本文整理汇总了PHP中System::tempDir方法的典型用法代码示例。如果您正苦于以下问题:PHP System::tempDir方法的具体用法?PHP System::tempDir怎么用?PHP System::tempDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System
的用法示例。
在下文中一共展示了System::tempDir方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
/**
* Sets up test case - initializes directory in %TEMP
*
*/
public function setUp()
{
$this->temp = $this->normalize(realpath(System::tempDir())) . md5(uniqid()) . '.xp' . DIRECTORY_SEPARATOR;
if (is_dir($this->temp) && !rmdir($this->temp)) {
throw new PrerequisitesNotMetError('Fixture directory exists, but cannot remove', NULL, $this->temp);
}
}
示例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: verifyTempDir
public static function verifyTempDir()
{
self::$temp = System::tempDir();
if (!is_writeable(self::$temp)) {
throw new PrerequisitesNotMetError('$TEMP is not writeable', null, [self::$temp . ' +w']);
}
if (($df = disk_free_space(self::$temp)) < 10240) {
throw new PrerequisitesNotMetError('Not enough space available in $TEMP', null, [sprintf('df %s = %.0fk > 10k', self::$temp, $df / 1024)]);
}
}
示例4: runningDirectory
public function runningDirectory()
{
new Process(System::tempDir());
}
示例5: main
/**
* Main runner method
*
* @param string[] args
*/
public static function main(array $args)
{
if (!$args) {
self::usage();
}
// Parse arguments
$output = '-';
for ($i = 0, $s = sizeof($args); $i < $s; $i++) {
if ('-O' == $args[$i]) {
$output = $args[++$i];
} else {
if ('-?' == $args[$i] || '--help' == $args[$i]) {
self::usage();
} else {
$package = $args[$i];
break;
}
}
}
// Load generator class
try {
$class = Package::forName('xp.codegen')->getPackage($package)->loadClass('Generator');
} catch (ElementNotFoundException $e) {
Console::$err->writeLine('*** No generator named "' . $package . '"');
exit(2);
}
$params = new ParamString(array_slice($args, $i + 1));
if ($params->exists('help', '?')) {
Console::$err->writeLine(self::textOf($class->getComment()));
exit(1);
}
// Instantiate generator
$generator = $class->newInstance($params);
$generator->storage = new FileSystemStorage(System::tempDir());
// Output
if ('-' === $output) {
$generator->output = new ConsoleOutput(Console::$err);
} else {
if (strstr($output, '.xar')) {
$generator->output = new ArchiveOutput($output);
} else {
$generator->output = new FileSystemOutput($output);
}
}
$generator->output->addObserver(newinstance('util.Observer', array(), '{
public function update($obs, $arg= NULL) { Console::writeLine(" >> ", $arg); }
}'));
Console::writeLine('===> Starting ', $generator);
// Compile target chain
$empty = new ArrayList();
$targets = create('new util.collections.HashTable<lang.reflect.Method, util.collections.HashTable<string, lang.Generic>>()');
foreach ($class->getMethods() as $method) {
if (!$method->hasAnnotation('target')) {
continue;
}
$target = create('new util.collections.HashTable<string, lang.Generic>()');
// Fetch dependencies
if ($method->hasAnnotation('target', 'depends')) {
$depends = create('new util.collections.Vector<lang.reflect.Method>()');
foreach ((array) $method->getAnnotation('target', 'depends') as $dependency) {
$depends[] = $class->getMethod($dependency);
}
$target['depends'] = $depends;
}
// Fetch input
if ($method->hasAnnotation('target', 'input')) {
$arguments = create('new util.collections.Vector<lang.reflect.Method>()');
foreach ((array) $method->getAnnotation('target', 'input') as $input) {
$arguments[] = $class->getMethod($input);
}
$target['arguments'] = $arguments;
}
$targets->put($method, $target);
}
// Invoke
try {
foreach ($targets->keys() as $method) {
self::invoke($generator, $method, $targets);
}
} catch (TargetInvocationException $e) {
Console::$err->writeLine('*** ', $e->getCause());
exit(3);
}
$generator->output->commit();
Console::writeLine('===> Done');
}
示例6: links_resolved_in_realpath
public function links_resolved_in_realpath()
{
$temp = System::tempDir();
$link = new Path($temp, 'link-to-temp');
if (false === symlink($temp, $link)) {
$this->skip('Cannot create ' . $link . ' -> ' . $temp);
}
$resolved = (new Path($link))->asRealpath()->toString();
unlink($link);
$this->assertEquals($temp, $resolved);
}
示例7: setUp
/**
* Sets up test case - initializes temp directory in %TEMP%
*
* @return void
*/
public function setUp()
{
$this->folder = new Folder(System::tempDir(), md5(uniqid()) . '.xp');
$this->folder->exists() && $this->folder->unlink();
$this->folder->create();
}
示例8: __construct
/**
* Constructor
*
* @param string prefix default "tmp"
*/
public function __construct($prefix = 'tmp')
{
parent::__construct(tempnam(System::tempDir(), $prefix . uniqid((double) microtime())));
}
示例9: prepareTempDir
public static function prepareTempDir()
{
self::$temp = new Folder(System::tempDir(), md5(uniqid()));
self::$temp->create();
session_save_path(self::$temp->getURI());
}
示例10: callingMain
public function callingMain()
{
$temp = System::tempDir();
// Create web.ini in system's temp dir
$ini = new File($temp, 'web.ini');
$ini->open(FILE_MODE_WRITE);
$ini->write("[app]\n" . "mappings=\"/:welcome\"\n" . "[app::welcome]\n" . "class=undefined\n" . "[app::welcome@dev]\n" . "class=\"" . self::$welcomeScriptlet->getName() . "\"\n");
$ini->close();
// Run
ob_start();
xp新criptlet愛unner::main(array($temp, $temp, 'dev', '/'));
$content = ob_get_contents();
ob_end_clean();
$ini->unlink();
// Assert
$this->assertEquals('<h1>Welcome, we are open</h1>', $content);
}