1 |
efrain |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
declare(strict_types=1);
|
|
|
4 |
|
|
|
5 |
namespace OpenSpout\Common\Helper;
|
|
|
6 |
|
|
|
7 |
use OpenSpout\Common\Exception\IOException;
|
|
|
8 |
|
|
|
9 |
/**
|
|
|
10 |
* @internal
|
|
|
11 |
*/
|
|
|
12 |
interface FileSystemHelperInterface
|
|
|
13 |
{
|
|
|
14 |
/**
|
|
|
15 |
* Creates an empty folder with the given name under the given parent folder.
|
|
|
16 |
*
|
|
|
17 |
* @param string $parentFolderPath The parent folder path under which the folder is going to be created
|
|
|
18 |
* @param string $folderName The name of the folder to create
|
|
|
19 |
*
|
|
|
20 |
* @return string Path of the created folder
|
|
|
21 |
*
|
|
|
22 |
* @throws IOException If unable to create the folder or if the folder path is not inside of the base folder
|
|
|
23 |
*/
|
|
|
24 |
public function createFolder(string $parentFolderPath, string $folderName): string;
|
|
|
25 |
|
|
|
26 |
/**
|
|
|
27 |
* Creates a file with the given name and content in the given folder.
|
|
|
28 |
* The parent folder must exist.
|
|
|
29 |
*
|
|
|
30 |
* @param string $parentFolderPath The parent folder path where the file is going to be created
|
|
|
31 |
* @param string $fileName The name of the file to create
|
|
|
32 |
* @param string $fileContents The contents of the file to create
|
|
|
33 |
*
|
|
|
34 |
* @return string Path of the created file
|
|
|
35 |
*
|
|
|
36 |
* @throws IOException If unable to create the file or if the file path is not inside of the base folder
|
|
|
37 |
*/
|
|
|
38 |
public function createFileWithContents(string $parentFolderPath, string $fileName, string $fileContents): string;
|
|
|
39 |
|
|
|
40 |
/**
|
|
|
41 |
* Delete the file at the given path.
|
|
|
42 |
*
|
|
|
43 |
* @param string $filePath Path of the file to delete
|
|
|
44 |
*
|
|
|
45 |
* @throws IOException If the file path is not inside of the base folder
|
|
|
46 |
*/
|
|
|
47 |
public function deleteFile(string $filePath): void;
|
|
|
48 |
|
|
|
49 |
/**
|
|
|
50 |
* Delete the folder at the given path as well as all its contents.
|
|
|
51 |
*
|
|
|
52 |
* @param string $folderPath Path of the folder to delete
|
|
|
53 |
*
|
|
|
54 |
* @throws IOException If the folder path is not inside of the base folder
|
|
|
55 |
*/
|
|
|
56 |
public function deleteFolderRecursively(string $folderPath): void;
|
|
|
57 |
}
|