public function testUnique() { $path = tempnam(sys_get_temp_dir(), ""); $unique1 = Filter_File::unique($path); file_put_contents($unique1, ""); $unique2 = Filter_File::unique($path); unlink($path); unlink($unique1); $this->assertEquals($path . ".1", $unique1); $this->assertEquals($path . ".2", $unique2); }
public static function save($command) { // Store task to disk with a unique name. $microtime = microtime(); $microtime = explode(" ", $microtime); $microtime = $microtime[1] . $microtime[0]; $path = dirname(__DIR__) . "/processes/{$microtime}"; // On Windows the microtime is not fine enough which leads to one task overwriting another. // Deal with that problem here. $path = Filter_File::unique($path); $content = "{$command}"; file_put_contents($path, $content); }