From 68c257f96f8835ae66f51f5aa547915b5831e146 Mon Sep 17 00:00:00 2001 From: Stefan Nussbaumer Date: Mon, 9 Sep 2013 23:32:40 +0200 Subject: [PATCH] don't try to read OSCCommands if file doesn't exist .gitignore ammended Signed-off-by: Stefan Nussbaumer --- .gitignore | 1 + CVCenter/OSCCommands.sc | 23 +++++++++++++++-------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 043ecbe..5eb7111 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ CVCenter/CVCenterPreferences CVCenter/CVCenterShortcuts CVCenter/globalShortcuts CVCenter/keyCodesAndModsOSX +CVCenter/keyCodesAndModsLinux diff --git a/CVCenter/OSCCommands.sc b/CVCenter/OSCCommands.sc index f8262b6..054ee57 100644 --- a/CVCenter/OSCCommands.sc +++ b/CVCenter/OSCCommands.sc @@ -275,7 +275,10 @@ 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 }); @@ -283,17 +286,21 @@ OSCCommands { *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 } } } \ No newline at end of file