zynaddsubfx

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

commit fc044c6008e73509ea01914a9d7454b66fce3521
parent 56baa23fbc4d5a63e795c57b873c29d7fffc085a
Author: Friedolino <mkirchn@freenet.de>
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; @@ -1042,7 +1050,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; } @@ -1057,7 +1066,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 @@ -160,6 +160,7 @@ class Part int lastnote; char loaded_file[256]; + bool hasFilename; const static rtosc::Ports &ports;