2014-11-25 18:04:59 +01:00
|
|
|
#include "FuseTruncateTest.h"
|
|
|
|
|
2018-09-15 23:32:58 +02:00
|
|
|
void FuseTruncateTest::TruncateFile(const char *filename, fspp::num_bytes_t size) {
|
2014-12-06 15:33:01 +01:00
|
|
|
int error = TruncateFileReturnError(filename, size);
|
|
|
|
EXPECT_EQ(0, error);
|
2014-11-25 18:04:59 +01:00
|
|
|
}
|
|
|
|
|
2018-09-15 23:32:58 +02:00
|
|
|
int FuseTruncateTest::TruncateFileReturnError(const char *filename, fspp::num_bytes_t size) {
|
2014-11-25 18:04:59 +01:00
|
|
|
auto fs = TestFS();
|
|
|
|
|
|
|
|
auto realpath = fs->mountDir() / filename;
|
2018-09-15 23:32:58 +02:00
|
|
|
int retval = ::truncate(realpath.string().c_str(), size.value());
|
2014-12-06 15:33:01 +01:00
|
|
|
if (retval == 0) {
|
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
return errno;
|
|
|
|
}
|
2014-11-25 18:04:59 +01:00
|
|
|
}
|