Skip to content

Commit

Permalink
* versioning on scanner
Browse files Browse the repository at this point in the history
  • Loading branch information
cannam committed Aug 17, 2004
1 parent afc7d23 commit 51fdc32
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 6 deletions.
33 changes: 28 additions & 5 deletions dssi-vst-scanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR cmdline, int cmdshow)
}
}

int version = int(RemotePluginVersion * 1000);
write(targetfd, &version, sizeof(int));

HINSTANCE libHandle = 0;

std::vector<std::string> vstPath = Paths::getPath
Expand Down Expand Up @@ -206,14 +209,28 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR cmdline, int cmdshow)

struct stat st;
if (!stat(cacheFileName.c_str(), &st)) {
haveCache = true;
} else {
int testfd = open(cacheFileName.c_str(), O_RDONLY);
if (testfd >= 0) {
int testVersion = 0;
if (read(testfd, &testVersion, sizeof(int)) == sizeof(int) &&
testVersion == version) {
haveCache = true;
} else {
cerr << "dssi-vst-scanner: Cache version mismatch for file "
<< cacheFileName << " (" << testVersion << ", wanted "
<< version << ") - rewriting" << endl;
}
close(testfd);
}
}
if (!haveCache) {
if ((fd = open(cacheFileName.c_str(), O_WRONLY | O_CREAT, 0644)) < 0) {
cerr << "dssi-vst-scanner: Failed to open cache file " << cacheFileName;
perror(" for writing");
fd = targetfd;
} else {
writingCache = true;
write(fd, &version, sizeof(int));
}
}
}
Expand Down Expand Up @@ -352,9 +369,15 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR cmdline, int cmdshow)
cerr << "dssi-vst-scanner: Failed to open cache file " << cacheFileName;
perror("for reading");
} else {
unsigned char c;
while (read(fd, &c, 1) == 1) {
write(targetfd, &c, 1);
int testVersion = 0;
if (read(fd, &testVersion, sizeof(int)) != sizeof(int) ||
testVersion != version) {
cerr << "dssi-vst-scanner: Internal error: cache file " << cacheFileName << " verified earlier, but now fails version test (" << testVersion << " != " << version << ")" << endl;
} else {
unsigned char c;
while (read(fd, &c, 1) == 1) {
write(targetfd, &c, 1);
}
}
close(fd);
}
Expand Down
2 changes: 1 addition & 1 deletion remoteplugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#ifndef REMOTE_PLUGIN_H
#define REMOTE_PLUGIN_H

static const float RemotePluginVersion = 0.8;
static const float RemotePluginVersion = 0.9;

enum RemotePluginDebugLevel {
RemotePluginDebugNone,
Expand Down
6 changes: 6 additions & 0 deletions remotevstclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,12 @@ RemoteVSTClient::queryPlugins(std::vector<PluginRecord> &plugins)

try {
char buffer[64];
int version = 0;

tryRead(fd, &version, sizeof(int));
if (version != int(RemotePluginVersion * 1000)) {
throw ((std::string)"Plugin scanner version mismatch");
}

while (1) {

Expand Down

0 comments on commit 51fdc32

Please sign in to comment.