/** * Returns the filepointer of the opened file $fileName in a unique directory.. * * This method will create a new unique folder in the temporary directory specified in ezcMailParser. * The fileName property of this class will be set to the location of the new file. * * @throws ezcBaseFileNotFoundException * if the file could not be opened. * @param string $fileName * @return resource */ private function openFile($fileName) { // The filename is now relative, we need to extend it with the absolute path. // To provide uniqueness we put the file in a directory based on processID and rand. $dirName = ezcMailParser::getTmpDir() . getmypid() . '-' . self::$counter++ . '/'; if (!is_dir($dirName)) { mkdir($dirName, 0700); } // remove the directory and the file when PHP shuts down ezcMailParserShutdownHandler::registerForRemoval($dirName); $this->fileName = $dirName . $fileName; $fp = fopen($this->fileName, 'w'); if ($this->fp === false) { throw new ezcBaseFileNotFoundException($this->fileName); } return $fp; }
/** * Test for bug #12844. */ public function testTempDirNonWindows() { if (ezcBaseFeatures::os() === 'Windows') { self::markTestSkipped('Test is for non-Windows only'); } ezcMailParser::setTmpDir(null); $this->assertEquals('/tmp/', ezcMailParser::getTmpDir()); }