Can be used by other modules that need easy mocking in tests.
Signed-off-by: Dominik Csapak <[email protected]>
---
new in v5 (split out from first qemu-server patch)
src/PVE/File.pm | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/src/PVE/File.pm b/src/PVE/File.pm
index abdf9d7..3fa8643 100644
--- a/src/PVE/File.pm
+++ b/src/PVE/File.pm
@@ -13,8 +13,10 @@ use POSIX qw(EEXIST EOPNOTSUPP);
use base 'Exporter';
our @EXPORT_OK = qw(
+ file_exists
file_set_contents
file_get_contents
+ file_get_size
file_read_first_line
file_read_last_line
dir_glob_regex
@@ -285,4 +287,16 @@ sub dir_glob_foreach($dir, $regex, $func) {
}
}
+# easier to mock for testing than '-f'.
+sub file_exists {
+ my ($path) = @_;
+ return -f $path;
+}
+
+# easier to mock for testing than '-s'.
+sub file_get_size {
+ my ($path) = @_;
+ return -s $path;
+}
+
1;
--
2.47.3