File

Use

Used to manipulate files or directories.

Core Object Class

To implement this component function you need to load the core class:

EasySwoole\Utility\File

Core Object Method

createDirectory

Create a directory:

  • string $dirPath directory path
  • string $permissions directory permissions
static function createDirectory($dirPath, $permissions = 0755):bool

cleanDirectory

Empty the directory:

  • string $dirPath directory path
  • string $keepStructure whether to maintain the directory structure
static function cleanDirectory($dirPath, $keepStructure = false):bool

deleteDirectory

Delete directory:

  • string $dirPath directory path
static function deleteDirectory($dirPath):bool

copyDirectory

Copy directory:

  • string $source source location
  • string $target target location
  • bool $overwrite whether to overwrite
static function copyDirectory($source, $target, $overwrite = true):bool

moveDirectory

Mobile directory:

  • string $source source location
  • string $target target location
  • bool $overwrite whether to overwrite
Static function moveDirectory($source, $target ,$overwrite = true):bool

copyFile

Copy the file:

  • string $source source location
  • string $target target location
  • bool $overwrite whether to overwrite
Static function copyFile($source, $target, $overwrite = true):bool

touchFile

Create an empty file:

  • string $filePath filename
  • bool $overwrite whether to overwrite
static function touchFile($filePath, $overwrite = true):bool

createFile

Create a content file:

  • string $filePath filename
  • string $content content
  • bool $overwrite whether to overwrite
Static function createFile($filePath, $content, $overwrite = true):bool

moveFile

Move files:

  • string $source source location
  • string $target target location
  • bool $overwrite whether to overwrite
Static function moveFile($source, $target, $overwrite = true):bool

scanDir

Get an array of file directories or directory files:

  • string $dirPath directory path
static function scanDir($dirPath)