zynaddsubfx

ZynAddSubFX open source synthesizer
Log | Files | Refs | Submodules | LICENSE

commit 4da1ff928130ab05082a09c8221b96a008530fcd
parent 44b58574e307f212eed2010e7f040681ebdcfb61
Author: Friedolino <[email protected]>
Date:   Sat, 18 Apr 2020 16:37:14 +0200

time as filename for unnamed parts in savexml

Diffstat:
Msrc/Misc/Part.cpp | 14++++++++++++--
Msrc/Misc/Part.h | 1+
2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/Misc/Part.cpp b/src/Misc/Part.cpp @@ -169,6 +169,13 @@ static const Ports partPorts = { [](const char *, RtData &d) { Part *p = (Part*)d.obj; + if (!p->hasFilename) { // if part was never loaded or saved + time_t rawtime; // make a new name from date and time + struct tm * timeinfo; + time (&rawtime); + timeinfo = localtime (&rawtime); + strftime (p->loaded_file,23,"%F_%R.xiz",timeinfo); + } p->saveXML(p->loaded_file); }}, //{"kit#16::T:F", "::Enables or disables kit item", 0, @@ -296,6 +303,7 @@ Part::Part(Allocator &alloc, const SYNTH_T &synth_, const AbsTime &time_, cleanup(); Pname = new char[PART_MAX_NAME_LEN]; + hasFilename = false; oldvolumel = oldvolumer = 0.5f; lastnote = -1; @@ -1081,7 +1089,8 @@ int Part::saveXML(const char *filename) xml.endbranch(); int result = xml.saveXMLfile(filename, gzip_compression); - strcpy(loaded_file,filename); + strncpy(loaded_file,filename, sizeof(loaded_file)); + hasFilename = true; return result; } @@ -1096,7 +1105,8 @@ int Part::loadXMLinstrument(const char *filename) return -10; // store filename in member variable - strcpy(loaded_file,filename); + strncpy(loaded_file,filename, sizeof(loaded_file)); + hasFilename = true; getfromXMLinstrument(xml); xml.exitbranch(); diff --git a/src/Misc/Part.h b/src/Misc/Part.h @@ -174,6 +174,7 @@ class Part int lastnote; char loaded_file[256]; + bool hasFilename; const static rtosc::Ports &ports;