public function testMove()
 {
     // setup
     SpoonDirectory::create($this->path . '/move_org');
     // copy
     SpoonDirectory::move($this->path . '/move_org', $this->path . '/move_dest');
     // check if both folders exists
     $var = (bool) (!SpoonDirectory::exists($this->path . '/move_org') && SpoonDirectory::exists($this->path . '/move_dest'));
     // assert
     $this->assertTrue($var);
     // cleanup
     SpoonDirectory::delete($this->path . '/move_dest');
 }
Beispiel #2
0
 /**
  * Write an error/custom message to the log.
  *
  * @return	void
  * @param	string $message			The messages that should be logged.
  * @param	string[optional] $type	The type of message you want to log, possible values are: error, custom.
  */
 public static function write($message, $type = 'error')
 {
     // milliseconds
     list($milliseconds) = explode(' ', microtime());
     $milliseconds = round($milliseconds * 1000, 0);
     // redefine var
     $message = date('Y-m-d H:i:s') . ' ' . $milliseconds . 'ms | ' . $message . "\n";
     $type = SpoonFilter::getValue($type, array('error', 'custom'), 'error');
     // file
     $file = self::getPath() . '/' . $type . '.log';
     // rename if needed
     if ((int) @filesize($file) >= self::MAX_FILE_SIZE * 1024) {
         // start new log file
         SpoonDirectory::move($file, $file . '.' . date('Ymdhis'));
     }
     // write content
     SpoonFile::setContent($file, $message, true, true);
 }
Beispiel #3
0
 /**
  * Move/rename a directory/file.
  *
  * @return	bool						True if the file was moved or renamed, false if not.
  * @param	string $source				Path of the source file.
  * @param	string $destination			Path of the destination.
  * @param 	bool[optional] $overwrite	Should an existing file be overwritten?
  * @param	int[optional] $chmod		Chmod mode that should be applied on the file/directory.
  */
 public static function move($source, $destination, $overwrite = true, $chmod = 0777)
 {
     // this is just an alias for SpoonDirectory::move
     return SpoonDirectory::move($source, $destination, $overwrite, $chmod);
 }
Beispiel #4
0
 /**
  * Move/rename a directory/file.
  *
  * @return	bool						True if the file was moved or renamed, false if not.
  * @param	string $source				Path of the source file.
  * @param	string $destination			Path of the destination.
  * @param 	bool[optional] $overwrite	Should an existing file be overwritten?
  * @param	int[optional] $chmod		Chmod mode that should be applied on the file/directory.
  */
 public static function move($source, $destination, $overwrite = true, $chmod = 0777)
 {
     return SpoonDirectory::move($source, $destination, $overwrite, $chmod);
 }
Beispiel #5
0
 /**
  * Move/rename a directory/file.
  *
  * @return	bool						True if the file was moved or renamed, false if not.
  * @param	string $source				Path of the source file.
  * @param	string $destination			Path of the destination.
  * @param 	bool[optional] $overwrite	Should an existing file be overwritten?
  * @param	int[optional] $chmod		Chmod mode that should be applied on the file/directory. Defaults to 0777 (+rwx for all) for directories and 0666 (+rw for all) for files.
  */
 public static function move($source, $destination, $overwrite = true, $chmod = null)
 {
     if ($chmod === null) {
         $chmod = is_dir($source) ? 0777 : 0666;
     }
     return SpoonDirectory::move($source, $destination, $overwrite, $chmod);
 }
Beispiel #6
0
 /**
  * Archive the current log file, but only if it exists.
  *
  * @return	SpoonLog
  */
 public function rotate()
 {
     // file
     $file = $this->getPath() . '/' . $this->type . '.log';
     // rename file
     if (SpoonFile::exists($file)) {
         SpoonDirectory::move($file, $file . '.' . date('Ymdhis'));
     }
     // self
     return $this;
 }