Hello! I’m hoping to show release notes in my module when it’s updated, like so:
I only want this message to display once, then only appear again once there’s a new version. My first attempt looks like,
UpdatesVisualizerWidget()
{
std::string path = asset::plugin(pluginInstance, "res/release_notes/groovebox.txt");
std::ifstream ifs(path);
// If the release notes cannot be found, this means that the file was already
// viewed and renamed, so don't view it again.
if(ifs.fail())
{
module->show_updates_visualizer = false;
}
// Show the release notes
else
{
// Read the release notes from the file. The release notes will be
// displayed in the drawLayer(...) function
release_notes.assign((std::istreambuf_iterator<char>(ifs)),
(std::istreambuf_iterator<char>()) );
// Rename updates file so it isn't shown next time the module is loaded
std::string destination = asset::plugin(pluginInstance, "res/release_notes/groovebox_viewed.txt");
if(std::rename(path.c_str(), destination.c_str()) != 0)
{
DEBUG("unable to rename file to ");
DEBUG(destination.c_str());
}
}
}
In short, the code is saying:
- If the
res/release_notes/groovebox.txt
file exists, read the content, rename the file, and display the release notes. - Otherwise, don’t show the release notes.
Maybe I’m on the right track, but my attempt to rename the res/release_notes/groovebox.txt
file is failing. I can’t tell if that’s because Rack doesn’t have permissions to update that file. Any suggestions would be much appreciated!
Thanks,
Bret