mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-04 18:51:17 -06:00
Merge pull request #2226 from OpenSpace/issue/2209
Issue/2209 Fixes for Session Recording Conversion
This commit is contained in:
6
data/tasks/sessRecConvertVersion.task
Normal file
6
data/tasks/sessRecConvertVersion.task
Normal file
@@ -0,0 +1,6 @@
|
||||
return {
|
||||
{
|
||||
Type = "ConvertRecFileVersionTask",
|
||||
InputFilePath = "../../user/recordings/input.osrec"
|
||||
}
|
||||
}
|
||||
@@ -550,6 +550,16 @@ public:
|
||||
*/
|
||||
std::string convertFile(std::string filename, int depth = 0);
|
||||
|
||||
/**
|
||||
* Converts file format of a session recording file to the current format version
|
||||
* (will determine the file format conversion to convert from based on the file's
|
||||
* header version number). Accepts a relative path (currently from task runner dir)
|
||||
* rather than a path assumed to be relative to ${RECORDINGS}.
|
||||
*
|
||||
* \param filename name of the file to convert
|
||||
*/
|
||||
void convertFileRelativePath(std::string filenameRelative);
|
||||
|
||||
/**
|
||||
* Goes to legacy session recording inherited class, and calls its convertFile()
|
||||
* method, and then returns the resulting conversion filename.
|
||||
@@ -617,7 +627,6 @@ protected:
|
||||
bool handleRecordingFile(std::string filenameIn);
|
||||
static bool isPath(std::string& filename);
|
||||
void removeTrailingPathSlashes(std::string& filename);
|
||||
void extractFilenameFromPath(std::string& filename);
|
||||
bool playbackCamera();
|
||||
bool playbackTimeChange();
|
||||
bool playbackScript();
|
||||
|
||||
@@ -143,15 +143,6 @@ void SessionRecording::removeTrailingPathSlashes(std::string& filename) {
|
||||
}
|
||||
}
|
||||
|
||||
void SessionRecording::extractFilenameFromPath(std::string& filename) {
|
||||
size_t unixDelimiter = filename.find_last_of("/");
|
||||
if (unixDelimiter != std::string::npos)
|
||||
filename = filename.substr(unixDelimiter + 1);
|
||||
size_t windowsDelimiter = filename.find_last_of("\\");
|
||||
if (windowsDelimiter != std::string::npos)
|
||||
filename = filename.substr(windowsDelimiter + 1);
|
||||
}
|
||||
|
||||
bool SessionRecording::handleRecordingFile(std::string filenameIn) {
|
||||
if (isPath(filenameIn)) {
|
||||
LERROR("Recording filename must not contain path (/) elements");
|
||||
@@ -1624,7 +1615,7 @@ std::string SessionRecording::isolateTermFromQuotes(std::string s) {
|
||||
}
|
||||
//If no quotes found, remove other possible characters from end
|
||||
std::string unwantedChars = " );";
|
||||
while (unwantedChars.find(s.back()) != std::string::npos) {
|
||||
while (!s.empty() && (unwantedChars.find(s.back()) != std::string::npos)) {
|
||||
s.pop_back();
|
||||
}
|
||||
return s;
|
||||
@@ -2303,6 +2294,10 @@ void SessionRecording::readFileIntoStringStream(std::string filename,
|
||||
inputFstream.close();
|
||||
}
|
||||
|
||||
void SessionRecording::convertFileRelativePath(std::string filenameRelative) {
|
||||
convertFile(absPath(filenameRelative).string());
|
||||
}
|
||||
|
||||
std::string SessionRecording::convertFile(std::string filename, int depth) {
|
||||
std::string conversionOutFilename = filename;
|
||||
std::ifstream conversionInFile;
|
||||
@@ -2331,9 +2326,6 @@ std::string SessionRecording::convertFile(std::string filename, int depth) {
|
||||
//conversionInStream.seekg(conversionInStream.beg);
|
||||
newFilename = getLegacyConversionResult(filename, depth + 1);
|
||||
removeTrailingPathSlashes(newFilename);
|
||||
if (isPath(newFilename)) {
|
||||
extractFilenameFromPath(newFilename);
|
||||
}
|
||||
if (filename == newFilename) {
|
||||
return filename;
|
||||
}
|
||||
@@ -2572,7 +2564,7 @@ std::string SessionRecording::determineConversionOutFilename(const std::string f
|
||||
filenameSansExtension = filename.substr(0, filename.find_last_of("."));
|
||||
}
|
||||
filenameSansExtension += "_" + fileFormatVersion() + "-" + targetFileFormatVersion();
|
||||
return absPath("${RECORDINGS}/" + filenameSansExtension + fileExtension).string();
|
||||
return filenameSansExtension + fileExtension;
|
||||
}
|
||||
|
||||
bool SessionRecording_legacy_0085::convertScript(std::stringstream& inStream,
|
||||
|
||||
@@ -52,11 +52,6 @@ ConvertRecFileVersionTask::ConvertRecFileVersionTask(const ghoul::Dictionary& di
|
||||
_inFilename = dictionary.value<std::string>(KeyInFilePath);
|
||||
_inFilePath = absPath(_inFilename);
|
||||
|
||||
std::string::size_type idx = _inFilename.find_last_of('/');
|
||||
if (idx != std::string::npos) {
|
||||
_inFilename = _inFilename.substr(idx + 1);
|
||||
}
|
||||
|
||||
ghoul_assert(std::filesystem::is_regular_file(_inFilePath), "The file must exist");
|
||||
if (!std::filesystem::is_regular_file(_inFilePath)) {
|
||||
LERROR(fmt::format("Failed to load session recording file: {}", _inFilePath));
|
||||
@@ -100,7 +95,7 @@ void ConvertRecFileVersionTask::convert() {
|
||||
));
|
||||
return;
|
||||
}
|
||||
sessRec->convertFile(_inFilename);
|
||||
sessRec->convertFileRelativePath(_inFilename);
|
||||
}
|
||||
|
||||
documentation::Documentation ConvertRecFileVersionTask::documentation() {
|
||||
|
||||
Reference in New Issue
Block a user