2017-07-11 15:12:03 +02:00
|
|
|
# FileUtils
|
|
|
|
|
|
|
|
## Description
|
|
|
|
Provides file system related utility functions.
|
|
|
|
|
|
|
|
## Constructor
|
|
|
|
Since there are only static utility methods there is no need for instantiating objects.
|
|
|
|
|
2017-11-24 15:59:34 +01:00
|
|
|
|
2017-07-11 15:12:03 +02:00
|
|
|
## Method Details
|
|
|
|
|
|
|
|
### validateDirectory(dir)
|
|
|
|
|
|
|
|
#### Description
|
|
|
|
Checks whether a file exists and is a directory.
|
|
|
|
|
|
|
|
#### Parameters
|
2017-11-24 15:59:34 +01:00
|
|
|
* `dir` - The directory to be checked. In case it is relative path it is checked against the
|
2017-07-11 15:12:03 +02:00
|
|
|
current working directory. In case of doubt use the absolute path (prefix the directory with `pwd`).
|
|
|
|
|
|
|
|
#### Return value
|
|
|
|
none
|
|
|
|
|
|
|
|
#### Side effects
|
|
|
|
none
|
|
|
|
|
|
|
|
#### Exceptions
|
2017-11-24 15:59:34 +01:00
|
|
|
* `IllegalArgumentException`:
|
|
|
|
* If the parameter `dir` is null or empty.
|
|
|
|
* `AbortException`:
|
|
|
|
* If the directory does not exist or is not a directory.
|
2017-07-11 15:12:03 +02:00
|
|
|
|
|
|
|
#### Example
|
|
|
|
```groovy
|
|
|
|
FileUtils.validateDirectory('/path/to/dir')
|
|
|
|
```
|
|
|
|
|
2017-11-24 15:59:34 +01:00
|
|
|
|
2017-07-11 15:12:03 +02:00
|
|
|
### validateDirectoryIsNotEmpty(dir)
|
|
|
|
|
|
|
|
#### Description
|
|
|
|
Check whether a directory is not empty. Before the directory is checked, `validateDirectory(dir)` is executed.
|
|
|
|
|
|
|
|
#### Parameters
|
2017-11-24 15:59:34 +01:00
|
|
|
* `dir` - The directory to be checked. In case it is relative path it is checked against the
|
2017-07-11 15:12:03 +02:00
|
|
|
current working directory. In case of doubt use the absolute path (prefix the directory with `pwd`).
|
|
|
|
|
|
|
|
#### Return value
|
|
|
|
none
|
|
|
|
|
|
|
|
#### Side effects
|
|
|
|
none
|
|
|
|
|
|
|
|
#### Exceptions
|
2017-11-24 15:59:34 +01:00
|
|
|
* `IllegalArgumentException`:
|
|
|
|
* If the parameter `dir` is null or empty.
|
|
|
|
* `AbortException`:
|
|
|
|
* If the directory does not exist or is not a directory or the directory is empty.
|
2017-07-11 15:12:03 +02:00
|
|
|
|
|
|
|
#### Example
|
|
|
|
```groovy
|
|
|
|
FileUtils.validateDirectoryIsNotEmpty('/path/to/dir')
|
|
|
|
```
|
|
|
|
|