How to get the user's logs folder in cocoa (NSSearchPathForDirectoriesInDomains possibly)

StackOverflow https://stackoverflow.com/questions/15462058

  •  24-03-2022
  •  | 
  •  

문제

I'm porting a Carbon application to Cocoa and am looking for the equivalent of kLogsFolderType in Cocoa, which currently would return /Users/me/Library/Logs

I have seen NSSearchPathForDirectoriesInDomains with the associated types, but can't find a value that would be an equivalent.

도움이 되었습니까?

해결책

There is no NSSearchPathDirectory option for ~/Library/Logs in Apple's docs, so you have to use NSLibraryDirectory and build the rest up yourself:

NSArray *URLs = [[NSFileManager defaultManager] URLsForDirectory:NSLibraryDirectory 
                                                       inDomains:NSUserDomainMask];
NSURL *logsURL = [[URLs lastObject] URLByAppendingPathComponent:@"Logs"];
NSString *logsPath = [libraryURL path];
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top