1
0
mirror of https://github.com/danog/file.git synced 2025-01-23 05:41:18 +01:00
file/lib/Driver.php

123 lines
3.0 KiB
PHP
Raw Normal View History

2015-07-10 21:59:39 -04:00
<?php
2015-08-05 10:55:56 -04:00
namespace Amp\File;
2015-07-10 21:59:39 -04:00
2015-07-30 10:10:53 -04:00
interface Driver {
2015-07-10 21:59:39 -04:00
/**
* Execute a file stat operation
*
* If the requested path does not exist the resulting Promise will resolve to NULL.
*
* @param string $path The file system path to stat
* @return \Amp\Promise A promise resolving to an associative array upon successful resolution
*/
2015-07-17 10:27:38 -04:00
public function stat($path);
2015-07-10 21:59:39 -04:00
/**
* Same as stat() except if the path is a link then the link's data is returned
*
* @param string $path The file system path to stat
* @return \Amp\Promise A promise resolving to an associative array upon successful resolution
*/
2015-07-17 10:27:38 -04:00
public function lstat($path);
2015-07-10 21:59:39 -04:00
/**
* Create a symlink $link pointing to the file/directory located at $target
*
* @param string $target
* @param string $link
* @return \Amp\Promise
*/
2015-07-17 10:27:38 -04:00
public function symlink($target, $link);
2015-07-10 21:59:39 -04:00
/**
* Rename a file or directory
*
* @param string $from
* @param string $to
* @return \Amp\Promise
*/
2015-07-17 10:27:38 -04:00
public function rename($from, $to);
2015-07-10 21:59:39 -04:00
/**
* Delete a file
*
* @param string $path
* @return \Amp\Promise
*/
2015-07-17 10:27:38 -04:00
public function unlink($path);
2015-07-10 21:59:39 -04:00
/**
* Create a director
*
* @param string $path
* @param int $mode
* @return \Amp\Promise
*/
2015-07-17 10:27:38 -04:00
public function mkdir($path, $mode = 0644);
2015-07-10 21:59:39 -04:00
/**
* Delete a directory
*
* @param string $path
* @return \Amp\Promise
*/
2015-07-17 10:27:38 -04:00
public function rmdir($path);
2015-07-10 21:59:39 -04:00
/**
* Retrieve an array of files and directories inside the specified path
*
* Dot entries are not included in the resulting array (i.e. "." and "..").
*
* @param string $path
* @return \Amp\Promise
*/
2015-07-17 10:27:38 -04:00
public function scandir($path);
2015-07-10 21:59:39 -04:00
/**
* chmod a file or directory
*
* @param string $path
* @param int $mode
* @return \Amp\Promise
*/
2015-07-17 10:27:38 -04:00
public function chmod($path, $mode);
2015-07-10 21:59:39 -04:00
/**
* chown a file or directory
*
* @param string $path
* @param int $uid
* @param int $gid
* @return \Amp\Promise
*/
2015-07-17 10:27:38 -04:00
public function chown($path, $uid, $gid);
2015-07-10 21:59:39 -04:00
2015-07-18 14:53:46 -04:00
/**
* Update the access and modification time of the specified path
*
* If the file does not exist it will be created automatically.
*
* @param string $path
* @return \Amp\Promise
*/
public function touch($path);
2015-07-10 21:59:39 -04:00
/**
* Buffer the specified file's contents
*
* @param string $path The file path from which to buffer contents
* @return \Amp\Promise A promise resolving to a string upon successful resolution
*/
2015-07-17 10:27:38 -04:00
public function get($path);
2015-07-10 21:59:39 -04:00
/**
* Write the contents string to the specified path.
*
* @param string $path The file path to which to $contents should be written
* @param string $contents The data to write to the specified $path
* @return \Amp\Promise A promise resolving to the integer length written upon success
*/
2015-07-17 10:27:38 -04:00
public function put($path, $contents);
2015-07-10 21:59:39 -04:00
}