Skip to content

Commit 9d32dfb

Browse files
committed
configurable dump path
1 parent ffe9656 commit 9d32dfb

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

include/DMDUtil/Config.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ class DMDUTILAPI Config
5757
void SetDumpNotColorizedFrames(bool dumpNotColorizedFrames) { m_dumpNotColorizedFrames = dumpNotColorizedFrames; }
5858
bool IsDumpFrames() const { return m_dumpFrames; }
5959
void SetDumpFrames(bool dumpFrames) { m_dumpFrames = dumpFrames; }
60+
void SetDumpPath(const char* path) { m_dumpPath = path; }
61+
const char* GetDumpPath() const { return m_dumpPath.c_str(); }
6062
bool IsFilterTransitionalFrames() const { return m_filterTransitionalFrames; }
6163
void SetFilterTransitionalFrames(bool filterTransitionalFrames)
6264
{
@@ -110,6 +112,7 @@ class DMDUTILAPI Config
110112
bool m_showNotColorizedFrames;
111113
bool m_dumpNotColorizedFrames;
112114
bool m_dumpFrames;
115+
std::string m_dumpPath;
113116
bool m_filterTransitionalFrames;
114117
bool m_zedmd;
115118
std::string m_zedmdDevice;

include/DMDUtil/DMD.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ class DMDUTILAPI DMD
198198
char m_romName[DMDUTIL_MAX_NAME_SIZE] = {0};
199199
char m_altColorPath[DMDUTIL_MAX_PATH_SIZE] = {0};
200200
char m_pupVideosPath[DMDUTIL_MAX_PATH_SIZE] = {0};
201+
char m_dumpPath[DMDUTIL_MAX_PATH_SIZE] = {0};
201202
AlphaNumeric* m_pAlphaNumeric;
202203
SerumFrameStruct* m_pSerum;
203204
ZeDMD* m_pZeDMD;

src/Config.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,11 @@ void Config::parseConfigFile(const char* path)
6868
SetIgnoreUnknownFramesTimeout(r.Get<int>("Serum", "IgnoreUnknownFramesTimeout", 0));
6969
SetMaximumUnknownFramesToSkip(r.Get<int>("Serum", "MaximumUnknownFramesToSkip", 0));
7070
SetShowNotColorizedFrames(r.Get<bool>("Serum", "ShowNotColorizedFrames", false));
71-
// Dumper
72-
SetDumpNotColorizedFrames(r.Get<bool>("Dumper", "DumpNotColorizedFrames", false));
73-
SetDumpFrames(r.Get<bool>("Dumper", "DumpFrames", false));
74-
SetFilterTransitionalFrames(r.Get<bool>("Dumper", "FilterTransitionalFrames", false));
71+
// Dump
72+
SetDumpNotColorizedFrames(r.Get<bool>("Dump", "DumpNotColorizedFrames", false));
73+
SetDumpFrames(r.Get<bool>("Dump", "DumpFrames", false));
74+
SetDumpPath(r.Get<std::string>("Dump", "DumpPath", "").c_str());
75+
SetFilterTransitionalFrames(r.Get<bool>("Dump", "FilterTransitionalFrames", false));
7576
}
7677

7778
} // namespace DMDUtil

src/DMD.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1534,10 +1534,18 @@ void DMD::DumpDMDTxtThread()
15341534

15351535
if (name[0] != '\0')
15361536
{
1537-
char filename[128];
1537+
char filename[DMDUTIL_MAX_NAME_SIZE + 128 + 8 + 5];
15381538
char suffix[9]; // 8 chars + null terminator
15391539
GenerateRandomSuffix(suffix, 8);
1540-
snprintf(filename, DMDUTIL_MAX_NAME_SIZE + 5, "%s-%s.txt", name, suffix);
1540+
if (m_dumpPath[0] == '\0') strcpy(m_dumpPath, Config::GetInstance()->GetDumpPath());
1541+
if (m_dumpPath[strlen(m_dumpPath) - 1] == '/' || m_dumpPath[strlen(m_dumpPath) - 1] == '\\')
1542+
{
1543+
snprintf(filename, sizeof(filename), "%s%s-%s.txt", m_dumpPath, name, suffix);
1544+
}
1545+
else
1546+
{
1547+
snprintf(filename, sizeof(filename), "%s/%s-%s.txt", m_dumpPath, name, suffix);
1548+
}
15411549
f = fopen(filename, "w");
15421550
update = true;
15431551
memset(renderBuffer, 0, 2 * 256 * 64);

0 commit comments

Comments
 (0)