소스 검색

Construct a default path

Zachary Kotlarek 12 년 전
부모
커밋
b655f5901b
1개의 변경된 파일과 8개의 추가작업 그리고 5개의 파일을 삭제
  1. 8 5
      speak/speak.m

+ 8 - 5
speak/speak.m

@@ -84,12 +84,15 @@ static void sockCallback (CFSocketRef sock, CFSocketCallBackType type, CFDataRef
 @end
 
 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
 	synth = [[NSSpeechSynthesizer alloc] init];