Sfoglia il codice sorgente

Construct a default path

Zachary Kotlarek 12 anni fa
parent
commit
b655f5901b
1 ha cambiato i file con 8 aggiunte e 5 eliminazioni
  1. 8 5
      speak/speak.m

+ 8 - 5
speak/speak.m

@@ -84,12 +84,15 @@ static void sockCallback (CFSocketRef sock, CFSocketCallBackType type, CFDataRef
 @end
 @end
 
 
 int main(int argc, const char *argv[]) {
 int main(int argc, const char *argv[]) {
-	if (argc < 2) {
-		return -1;
+
+	// Construct a default socket path or use the provided one
+	NSString *str;
+	if (argc > 1) {
+		str = [NSString stringWithUTF8String: argv[1]];
+	} else {
+		NSString *tmpDir = NSTemporaryDirectory();
+		str = [NSString stringWithFormat:@"%@plexMonitor/SPEAK.socket", tmpDir];
 	}
 	}
-		
-	// Convert from c-string to NSString
-	NSString *str = [NSString stringWithUTF8String: argv[1]];
 	
 	
 	// Init the speech engine
 	// Init the speech engine
 	synth = [[NSSpeechSynthesizer alloc] init];
 	synth = [[NSSpeechSynthesizer alloc] init];