Add EXTENSION parameter for filename

This commit is contained in:
2020-04-20 10:02:05 +02:00
parent 631004a9e4
commit bf881f5468
3 changed files with 5 additions and 2 deletions
+1
View File
@@ -7,6 +7,7 @@ namespace BufferUtils
{
extern const size_t FILE_MOD;
extern const size_t FOLDER_MOD;
extern const std::string FILE_EXTENSION;
std::string get_filename(
std::string root_folder,
+2 -1
View File
@@ -7,6 +7,7 @@ using namespace std;
const size_t BufferUtils::FILE_MOD = 1000;
// Must be power of 10 and >= than FILE_MOD.
const size_t BufferUtils::FOLDER_MOD = 100000;
const std::string BufferUtils::FILE_EXTENSION = ".h5";
string BufferUtils::get_filename(
std::string root_folder,
@@ -23,7 +24,7 @@ string BufferUtils::get_filename(
folder << root_folder << "/";
folder << device_name << "/";
folder << folder_base << "/";
folder << file_base << ".bin";
folder << file_base << FILE_EXTENSION;
return folder.str();
}
+2 -1
View File
@@ -5,7 +5,8 @@ using namespace std;
TEST(BufferUtils, get_filename)
{
auto expected_file = "/root/device-1/12300000/12345000.bin";
auto expected_file = "/root/device-1/12300000/12345000" +
BufferUtils::FILE_EXTENSION;
auto root_folder = "/root";
auto device_name = "device-1";