Commit 337a53f5 authored by kulvait's avatar kulvait

Update CTMAL and function to concatenate files accepts also vector of filenames

parent 194e0e8e
......@@ -3,6 +3,7 @@
#include <plog/Log.h>
#include <experimental/filesystem>
#include <fstream>
#include <iostream>
#include <limits.h>
......@@ -11,8 +12,6 @@
#include <stdarg.h> // For va_start, etc.
#include <string>
#include <sys/stat.h>
#include <experimental/filesystem>
#include "littleEndianAlignment.h"
#include "stringFormatter.h"
......@@ -25,7 +24,8 @@ namespace io {
uint8_t* buffer,
std::streamsize numBytes);
void writeFirstBytes(std::string fileName, uint8_t* buffer, uint64_t numBytes);
void writeBytesFrom(std::string fileName, uint64_t fromPosition, uint8_t* buffer, uint64_t numBytes);
void
writeBytesFrom(std::string fileName, uint64_t fromPosition, uint8_t* buffer, uint64_t numBytes);
void appendBytes(std::string fileName, uint8_t* buffer, uint64_t numBytes);
void createEmptyFile(std::string fileName, uint64_t numBytes, bool overwrite);
bool pathExists(std::string fileName);
......@@ -35,24 +35,30 @@ namespace io {
std::string getParent(const std::string& path);
std::string getBasename(const std::string& path);
std::string fileToString(const std::string& fileName);
/**
* Concatenate text files given by inputFiles into the file given by outputFile.
* Intended to create compilation of cl files into the file allsources.cl
* Example:
* @code
* std::string xpath = "/path/to/files"
* clFile = io::xprintf("%s/opencl/allsources.cl", xpath.c_str());
* io::concatenateTextFiles(clFile, true,
* { io::xprintf("%s/opencl/utils.cl", xpath.c_str()),
* io::xprintf("%s/opencl/projector.cl", xpath.c_str()),
* io::xprintf("%s/opencl/backprojector.cl", xpath.c_str()) });
*
* @endcode
*
* @param outputFile Output file string.
* @param overwrite Should overwrite output file.
* @param inputFiles Input files as a std::initializer_list should be strings put into {} brackets.
*/
void concatenateTextFiles(const std::string& outputFile, bool overwrite, std::initializer_list<std::string> inputFiles);
/**
* Concatenate text files given by inputFiles into the file given by outputFile.
* Intended to create compilation of cl files into the file allsources.cl
* Example:
* @code
* std::string xpath = "/path/to/files"
* clFile = io::xprintf("%s/opencl/allsources.cl", xpath.c_str());
* io::concatenateTextFiles(clFile, true,
* { io::xprintf("%s/opencl/utils.cl", xpath.c_str()),
* io::xprintf("%s/opencl/projector.cl", xpath.c_str()),
* io::xprintf("%s/opencl/backprojector.cl", xpath.c_str()) });
*
* @endcode
*
* @param outputFile Output file string.
* @param overwrite Should overwrite output file.
* @param inputFiles Input files as a std::initializer_list should be strings put into {}
* brackets.
*/
void concatenateTextFiles(const std::string& outputFile,
bool overwrite,
std::initializer_list<std::string> inputFiles);
void concatenateTextFiles(const std::string& outputFile,
bool overwrite,
std::vector<std::string>& inputFiles);
} // namespace io
} // namespace CTL
......@@ -285,6 +285,18 @@ namespace io {
void concatenateTextFiles(const std::string& outputFile,
bool overwrite,
std::initializer_list<std::string> inputFiles)
{
std::vector<std::string> inputFilesVector;
for(std::string f : inputFiles)
{
inputFilesVector.push_back(f);
}
concatenateTextFiles(outputFile, overwrite, inputFilesVector);
}
void concatenateTextFiles(const std::string& outputFile,
bool overwrite,
std::vector<std::string>& inputFiles)
{
if(pathExists(outputFile) && !overwrite)
{
......
Subproject commit 4def9045b8796d3fb3be5092aed2e8262acaafec
Subproject commit 6a7824c9c86e5ec06a9c0d0a9bacc2d551c3b6ab
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment