[yoshimi-user] Expand state file path and continue start if it doesn't exist

  • From: Nikita Zlobin <cook60020tmp@xxxxxxx>
  • To: yoshimi-user@xxxxxxxxxxxxxxxxxxxxx
  • Date: Sun, 7 Apr 2013 15:13:39 +0600

For now these two things are defeated.
stat() functions need full expanded path, for what there is realpath().

From 03db56da3294a28d0ffb5316892c983a99e3a0eb Mon Sep 17 00:00:00 2001
From: Nikita Zlobin <nick87720z@xxxxxxxxx>
Date: Sun, 7 Apr 2013 14:35:25 +0600
Subject: [PATCH] Expand state file path and continue start if it doesn't
exist

---
src/Misc/Config.cpp | 24 +++++++++++++++++++-----
1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/src/Misc/Config.cpp b/src/Misc/Config.cpp
index 9562f24..53d4139 100644
--- a/src/Misc/Config.cpp
+++ b/src/Misc/Config.cpp
@@ -30,6 +30,7 @@
#include <string>
#include <argp.h>
#include <libgen.h>
+#include <limits.h>

#if defined(__SSE__)
#include <xmmintrin.h>
@@ -171,11 +172,23 @@ bool Config::Setup(int argc, char **argv)
if (!midiDevice.size())
midiDevice = "default";
loadCmdArgs(argc, argv);
- if (restoreState && !(StateFile.size() && isRegFile(StateFile)))
- {
- Log("Invalid state file specified for restore: " + StateFile);
- return false;
- }
+ if (restoreState)
+ {
+ char * fp;
+ if (! StateFile.size()) goto no_state0;
+ else fp = new char [PATH_MAX];
+
+ if (! realpath (StateFile.c_str(), fp)) goto no_state1;
+ StateFile = fp;
+ delete (fp);
+
+ if (! isRegFile(StateFile))
+ {
+ no_state1: delete (fp);
+ no_state0: Log("Invalid state file specified for restore: " + StateFile);
+ restoreState = false;
+ }
+ }
AntiDenormals(true);
return true;
}
@@ -939,6 +952,7 @@ static error_t parse_cmds (int key, char *arg, struct
argp_state *state)
case 'k': settings->startJack = true; break;
case 'K': settings->connectJackaudio = true; break;
case 'S':
+ printf ("state arg = %s\n", arg);
settings->restoreState = true;
if (arg)
settings->StateFile = string(arg);
--
1.7.9.5

Other related posts:

  • » [yoshimi-user] Expand state file path and continue start if it doesn't exist - Nikita Zlobin