Skip to content

Commit

Permalink
don't try to read OSCCommands if file doesn't exist
Browse files Browse the repository at this point in the history
.gitignore ammended

Signed-off-by: Stefan Nussbaumer <st9fan@gmail.com>
  • Loading branch information
nuss committed Sep 9, 2013
1 parent 7edb2bf commit 68c257f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -7,3 +7,4 @@ CVCenter/CVCenterPreferences
CVCenter/CVCenterShortcuts
CVCenter/globalShortcuts
CVCenter/keyCodesAndModsOSX
CVCenter/keyCodesAndModsLinux
23 changes: 15 additions & 8 deletions CVCenter/OSCCommands.sc
Expand Up @@ -275,25 +275,32 @@ OSCCommands {
var thisDeviceName, thisCmds, cmdsPath;

deviceName !? { thisDeviceName = deviceName.asSymbol };
cmdsPath = this.filenameSymbol.asString.dirname +/+ "OSCCommands";
if(File.exists(this.filenameSymbol.asString.dirname +/+ "OSCCommands")) {
cmdsPath = this.filenameSymbol.asString.dirname +/+ "OSCCommands";
} { ^nil };

thisCmds = Object.readArchive(cmdsPath);

if(deviceName.notNil, { ^thisCmds[thisDeviceName] }, { ^thisCmds });
}

*clearCmdsAt { |deviceName|
var cmdsPath, cmds;
cmdsPath = this.filenameSymbol.asString.dirname +/+ "OSCCommands";
cmds = Object.readArchive(cmdsPath);
cmds.removeAt(deviceName.asSymbol);
cmds.writeArchive(cmdsPath);
if(File.exists(this.filenameSymbol.asString.dirname +/+ "OSCCommands")) {
cmdsPath = this.filenameSymbol.asString.dirname +/+ "OSCCommands";
cmds = Object.readArchive(cmdsPath);
cmds.removeAt(deviceName.asSymbol);
cmds.writeArchive(cmdsPath);
}
}

*storedDevices {
var cmdsPath, cmds;
cmdsPath = this.filenameSymbol.asString.dirname +/+ "OSCCommands";
cmds = Object.readArchive(cmdsPath);
^cmds.keys;
if(File.exists(this.filenameSymbol.asString.dirname +/+ "OSCCommands")) {
cmdsPath = this.filenameSymbol.asString.dirname +/+ "OSCCommands";
cmds = Object.readArchive(cmdsPath);
^cmds.keys;
} { ^nil }
}

}

0 comments on commit 68c257f

Please sign in to comment.