当前位置: 首页>>代码示例>>PHP>>正文


PHP sys_get_temp_dir函数代码示例

本文整理汇总了PHP中sys_get_temp_dir函数的典型用法代码示例。如果您正苦于以下问题:PHP sys_get_temp_dir函数的具体用法?PHP sys_get_temp_dir怎么用?PHP sys_get_temp_dir使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了sys_get_temp_dir函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: dir_name

 public function dir_name()
 {
     $path = ini_get("xhprof.output_dir");
     $path = empty($path) ? sys_get_temp_dir() : $path;
     return $path;
     // return DATA_DIR."/xhprof/";
 }
开发者ID:sss201413,项目名称:ecstore,代码行数:7,代码来源:xhprof.php

示例2: __construct

 public function __construct($namespace = '', $defaultLifetime = 0, $directory = null)
 {
     parent::__construct('', $defaultLifetime);
     if (!isset($directory[0])) {
         $directory = sys_get_temp_dir() . '/symfony-cache';
     }
     if (isset($namespace[0])) {
         if (preg_match('#[^-+_.A-Za-z0-9]#', $namespace, $match)) {
             throw new InvalidArgumentException(sprintf('FilesystemAdapter namespace contains "%s" but only characters in [-+_.A-Za-z0-9] are allowed.', $match[0]));
         }
         $directory .= '/' . $namespace;
     }
     if (!file_exists($dir = $directory . '/.')) {
         @mkdir($directory, 0777, true);
     }
     if (false === ($dir = realpath($dir))) {
         throw new InvalidArgumentException(sprintf('Cache directory does not exist (%s)', $directory));
     }
     if (!is_writable($dir .= DIRECTORY_SEPARATOR)) {
         throw new InvalidArgumentException(sprintf('Cache directory is not writable (%s)', $directory));
     }
     // On Windows the whole path is limited to 258 chars
     if ('\\' === DIRECTORY_SEPARATOR && strlen($dir) > 234) {
         throw new InvalidArgumentException(sprintf('Cache directory too long (%s)', $directory));
     }
     $this->directory = $dir;
 }
开发者ID:zanderbaldwin,项目名称:symfony,代码行数:27,代码来源:FilesystemAdapter.php

示例3: testFromNonDirectoryWithNonExistingPath

 public function testFromNonDirectoryWithNonExistingPath()
 {
     $directory = uniqid(sys_get_temp_dir() . 'non-existing', true);
     $exception = InvalidDirectory::fromNonDirectory($directory);
     self::assertInstanceOf(InvalidDirectory::class, $exception);
     self::assertSame(sprintf('"%s" does not exists', $directory), $exception->getMessage());
 }
开发者ID:roave,项目名称:better-reflection,代码行数:7,代码来源:InvalidDirectoryTest.php

示例4: testExecution

 /**
  * @dataProvider getFormat
  * @runInSeparateProcess
  */
 public function testExecution($format)
 {
     $tmpDir = sys_get_temp_dir() . '/sf_hello';
     $filesystem = new Filesystem();
     $filesystem->remove($tmpDir);
     $filesystem->mkdirs($tmpDir);
     chdir($tmpDir);
     $tester = new CommandTester(new InitCommand());
     $tester->execute(array('--name' => 'Hello' . $format, '--app-path' => 'hello' . $format, '--web-path' => 'web', '--src-path' => 'src', '--format' => $format));
     // autoload
     $content = file_get_contents($file = $tmpDir . '/src/autoload.php');
     $content = str_replace("__DIR__.'/vendor", "'" . __DIR__ . "/../../../../src/vendor", $content);
     file_put_contents($file, $content);
     // Kernel
     $class = 'Hello' . $format . 'Kernel';
     $file = $tmpDir . '/hello' . $format . '/' . $class . '.php';
     $this->assertTrue(file_exists($file));
     $content = file_get_contents($file);
     $content = str_replace("__DIR__.'/../src/vendor/Symfony/src/Symfony/Bundle'", "'" . __DIR__ . "/../../../../src/vendor/Symfony/src/Symfony/Bundle'", $content);
     file_put_contents($file, $content);
     require_once $file;
     $kernel = new $class('dev', true);
     $response = $kernel->handle(Request::create('/'));
     $this->assertRegExp('/successfully/', $response->getContent());
     $filesystem->remove($tmpDir);
 }
开发者ID:kawahara,项目名称:symfony-bootstrapper,代码行数:30,代码来源:InitCommandTest.php

示例5: processemail

 public static function processemail($emailsrc, $pdfout, $coverfile = '')
 {
     $combfilelist = array();
     # Process the email
     $emailparts = Mail_mimeDecode::decode(array('include_bodies' => true, 'decode_bodies' => true, 'decode_headers' => true, 'input' => file_get_contents($emailsrc), 'crlf' => "\r\n"));
     # Process the cover if it exists
     if ($coverfile !== '') {
         $combfilelist[] = self::processpart(file_get_contents($coverfile), mime_content_type($coverfile));
     }
     # Process the parts
     $combfilelist = array_merge($combfilelist, self::processparts($emailparts));
     # Create an intermediate file to build the pdf
     $tmppdffilename = sys_get_temp_dir() . '/e2p-' . (string) abs((int) (microtime(true) * 100000)) . '.pdf';
     # Build the command to combine all of the intermediate files into one
     $conbcom = str_replace(array_merge(array('INTFILE', 'COMBLIST'), array_keys(self::$driver_paths)), array_merge(array($tmppdffilename, implode(' ', $combfilelist)), array_values(self::$driver_paths)), self::$mime_drivers['gs']);
     exec($conbcom);
     # Remove the intermediate files
     foreach ($combfilelist as $combfilename) {
         unlink($combfilename);
     }
     # Write the intermediate file to the final destination
     $intfileres = fopen($tmppdffilename, 'rb');
     $outfileres = fopen($pdfout, 'ab');
     while (!feof($intfileres)) {
         fwrite($outfileres, fread($intfileres, 8192));
     }
     fclose($intfileres);
     fclose($outfileres);
     # Remove the intermediate file
     unlink($tmppdffilename);
 }
开发者ID:swk,项目名称:bluebox,代码行数:31,代码来源:emailtopdf.php

示例6: testSetPath

 public function testSetPath()
 {
     $exporter = $this->getMockForAbstractClass(AbstractExporter::class);
     $path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . sha1(time()) . DIRECTORY_SEPARATOR;
     $exporter->setPath($path);
     $this->assertEquals($path, $exporter->getPath());
 }
开发者ID:fireguard,项目名称:report,代码行数:7,代码来源:AbstractExporterTest.php

示例7: setUp

 public function setUp()
 {
     $this->numberOfPayloads = 5;
     $this->tempDirectory = sys_get_temp_dir() . '/orphanage';
     $this->realDirectory = sys_get_temp_dir() . '/storage';
     $this->payloads = array();
     $filesystem = new Filesystem();
     $filesystem->mkdir($this->tempDirectory);
     $filesystem->mkdir($this->realDirectory);
     for ($i = 0; $i < $this->numberOfPayloads; $i++) {
         // create temporary file
         $file = tempnam(sys_get_temp_dir(), 'uploader');
         $pointer = fopen($file, 'w+');
         fwrite($pointer, str_repeat('A', 1024), 1024);
         fclose($pointer);
         $this->payloads[] = new FilesystemFile(new UploadedFile($file, $i . 'grumpycat.jpeg', null, null, null, true));
     }
     // create underlying storage
     $this->storage = new FilesystemStorage($this->realDirectory);
     // is ignored anyways
     $chunkStorage = new FilesystemChunkStorage('/tmp/');
     // create orphanage
     $session = new Session(new MockArraySessionStorage());
     $session->start();
     $config = array('directory' => $this->tempDirectory);
     $this->orphanage = new FilesystemOrphanageStorage($this->storage, $session, $chunkStorage, $config, 'cat');
 }
开发者ID:lsv,项目名称:OneupUploaderBundle,代码行数:27,代码来源:FilesystemOrphanageStorageTest.php

示例8: setUp

 public function setUp()
 {
     $this->tmpdir = sys_get_temp_dir() . '/' . uniqid('conveyor');
     $this->projectdir = $this->tmpdir . '/project';
     $this->reposdir = $this->tmpdir . '/repos';
     $this->reposurl = 'file:///' . $this->reposdir;
     $this->filesystem = new Filesystem();
     $this->filesystem->mkdir($this->tmpdir);
     $this->filesystem->mkdir($this->projectdir);
     $svnadminbin = getenv('SVNADMIN_BIN') ? getenv('SVNADMIN_BIN') : '/usr/local/bin/svnadmin';
     $svnbin = getenv('SVN_BIN') ? getenv('SVN_BIN') : '/usr/local/bin/svn';
     if (!file_exists($svnadminbin)) {
         $this->markTestSkipped(sprintf('%s not found', $svnadminbin));
     }
     if (!file_exists($svnbin)) {
         $this->markTestSkipped(sprintf('%s not found', $svnbin));
     }
     $svnadmin = new Svnadmin($this->tmpdir, $svnadminbin);
     $svnadmin->create(basename($this->reposdir));
     $svn = new Svn($this->reposurl, new CliAdapter($svnbin, new Cli(), new CliParser()));
     $svn->import(__DIR__ . '/../Test/Fixtures/skeleton/svn/trunk', '/', 'imported skeleton');
     $svn->setHead(new Reference('2.1', Reference::TAG));
     $svn->import(__DIR__ . '/../Test/Fixtures/skeleton/svn/tags/2.1', '/', 'imported skeleton');
     $svn->setHead(new Reference('feature1', Reference::BRANCH));
     $svn->import(__DIR__ . '/../Test/Fixtures/skeleton/svn/branches/feature1', '/', 'imported skeleton');
     $content = file_get_contents(__DIR__ . '/../Test/Fixtures/conveyor.yml.twig');
     $content = str_replace('{{ repository.url }}', $this->reposurl, $content);
     file_put_contents($this->projectdir . '/conveyor.yml', $content);
     chdir($this->projectdir);
 }
开发者ID:webcreate,项目名称:conveyor,代码行数:30,代码来源:VersionsCommandTest.php

示例9: assembleBook

 public function assembleBook()
 {
     // implode all the contents to create the whole book
     $book = $this->app->render('book.twig', array('items' => $this->app['publishing.items']));
     $temp = tempnam(sys_get_temp_dir(), 'easybook_');
     fputs(fopen($temp, 'w+'), $book);
     // use PrinceXML to transform the HTML book into a PDF book
     $prince = $this->app->get('prince');
     $prince->setBaseURL($this->app['publishing.dir.contents'] . '/images');
     // Prepare and add stylesheets before PDF conversion
     if ($this->app->edition('include_styles')) {
         $defaultStyles = tempnam(sys_get_temp_dir(), 'easybook_style_');
         $this->app->renderThemeTemplate('style.css.twig', array('resources_dir' => $this->app['app.dir.resources'] . '/'), $defaultStyles);
         $prince->addStyleSheet($defaultStyles);
     }
     // TODO: custom book styles could also be defined with Twig
     $customCss = $this->app->getCustomTemplate('style.css');
     if (file_exists($customCss)) {
         $prince->addStyleSheet($customCss);
     }
     // TODO: the name of the book file (book.pdf) must be configurable
     $errorMessages = array();
     $prince->convert_file_to_file($temp, $this->app['publishing.dir.output'] . '/book.pdf', $errorMessages);
     // show PDF conversion errors
     if (count($errorMessages) > 0) {
         foreach ($errorMessages as $message) {
             echo $message[0] . ': ' . $message[2] . ' (' . $message[1] . ')' . "\n";
         }
     }
 }
开发者ID:raulfraile,项目名称:easybook,代码行数:30,代码来源:PdfPublisher.php

示例10: setUp

 public function setUp()
 {
     parent::setUp();
     $this->originalFile = __DIR__ . '/files/testimage.gif';
     $this->compressedFile = $temp_file = sys_get_temp_dir() . '/php_image_optimizer.gif';
     copy($this->originalFile, $this->compressedFile);
 }
开发者ID:approached,项目名称:laravel-image-optimizer,代码行数:7,代码来源:ConvertGIFTest.php

示例11: getZippedFile

	private static function getZippedFile($filename) {
		
		if(!self::zipModuleLoaded()) {
			throw new WURFL_WURFLException("The Zip extension is not loaded. Load the extension or use the flat wurfl.xml file");
		}
		
		
		$tmpDir = sys_get_temp_dir();
		
		$zip = new ZipArchive();

		if ($zip->open($filename)!==TRUE) {
			exit("cannot open <$filename>\n");
		}
		$zippedFile = $zip->statIndex(0);
		$wurflFile = $zippedFile['name'];
		
		//$wurflFile = md5(uniqid(rand(), true)); 
		
		//$zip->extractTo($tmpDir, $wurflFile);
		$zip->extractTo($tmpDir);

		$zip->close();
		
		return $tmpDir . '/' .$wurflFile;
	}
开发者ID:richard-cai,项目名称:Zend-Framework-Extended,代码行数:26,代码来源:Utils.php

示例12: testDetectTypeFromFileCannotOpen

 /**
  * @expectedException XML_XRD_Loader_Exception
  * @expectedExceptionMessage Cannot open file to determine type
  */
 public function testDetectTypeFromFileCannotOpen()
 {
     $file = tempnam(sys_get_temp_dir(), 'xml_xrd-unittests');
     $this->cleanupList[] = $file;
     chmod($file, '0000');
     @$this->loader->detectTypeFromFile($file);
 }
开发者ID:pear,项目名称:xml_xrd,代码行数:11,代码来源:LoaderTest.php

示例13: tempFilename

 protected function tempFilename()
 {
     $temp_dir = is_null($this->temp_dir) ? sys_get_temp_dir() : $this->temp_dir;
     $filename = tempnam($temp_dir, "xlsx_writer_");
     $this->temp_files[] = $filename;
     return $filename;
 }
开发者ID:mk-j,项目名称:php_xlsxwriter,代码行数:7,代码来源:xlsxwriter.class.php

示例14: php_sys_get_temp_dir

/**
 * NOTE: This function is incomplete, the fallback is to '/tmp' which targets Unix-like.
 *
 * @return string
 */
function php_sys_get_temp_dir()
{
    // (PHP 5 >= 5.2.1)
    if (function_exists('sys_get_temp_dir')) {
        return sys_get_temp_dir();
    }
    // (PHP 4 >= 4.3.0, PHP 5)
    if (function_exists('stream_get_meta_data')) {
        $handle = tmpfile();
        // (PHP 4, PHP 5)
        $meta = stream_get_meta_data($handle);
        // (PHP 5 >= 5.1.0)
        if (isset($meta['uri'])) {
            return dirname($meta['uri']);
        }
    }
    // emulate  PHP 4 <= 4.0.6 tempnam() behavior, fragile
    foreach (array('TMPDIR', 'TMP') as $key) {
        if (isset($_ENV[$key])) {
            return $_ENV[$key];
        }
    }
    // fallback for Unix-like (php_shell specifically)
    return '/tmp';
}
开发者ID:melzaiady,项目名称:DropboxUploader,代码行数:30,代码来源:test-filemtime.php

示例15: generate

 public function generate()
 {
     $tempPath = sys_get_temp_dir() . '/';
     // FastCGI fix for Windows machines, where temp path is not available to
     // PHP, and defaults to the unwritable system directory.  If the temp
     // path is pointing to the system directory, shift to the 'TEMP'
     // sub-folder, which should also exist, but actually be writable.
     if (IS_WIN && $tempPath == getenv("SystemRoot") . '/') {
         $tempPath = getenv("SystemRoot") . '/TEMP/';
     }
     $keyFile = $tempPath . md5(microtime(true));
     if (!is_dir($tempPath)) {
         mkdir($tempPath);
     }
     $return = array();
     if ($this->canGenerateKeys()) {
         shell_exec('ssh-keygen -q -t rsa -b 2048 -f ' . $keyFile . ' -N "" -C "deploy@phpci"');
         $pub = file_get_contents($keyFile . '.pub');
         $prv = file_get_contents($keyFile);
         if (empty($pub)) {
             $pub = '';
         }
         if (empty($prv)) {
             $prv = '';
         }
         $return = array('private_key' => $prv, 'public_key' => $pub);
     }
     return $return;
 }
开发者ID:bztrn,项目名称:PHPCI,代码行数:29,代码来源:SshKey.php


注:本文中的sys_get_temp_dir函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。