Skip to content

Commit e32a31b

Browse files
committed
Replace deprecated API usage when trying to get the boot volume's name
1 parent eb98603 commit e32a31b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

SymbolicLinker.m

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,13 @@ void MakeSymbolicLinkToDesktop(CFURLRef url)
7171
fileName = CFURLCopyLastPathComponent(url);
7272
if (SLIsEqualToString(fileName, CFSTR("/"))) // true if the user is making a symlink to the boot volume
7373
{
74+
NSString *volumeName = nil;
75+
7476
CFRelease(fileName);
75-
fileName = CFURLCopyFileSystemPath(url, kCFURLHFSPathStyle); // use CoreFoundation to figure out the boot volume's name
77+
if ([(NSURL *)url getResourceValue:&volumeName forKey:NSURLVolumeLocalizedNameKey error:NULL]) // try to get the boot volume name (like "Macintosh HD")
78+
fileName = CFBridgingRetain(volumeName); // use it if we got it
79+
else
80+
fileName = CFBridgingRetain(@":"); // use a default value if that failed for some reason; we can't use "/" because that's reserved
7681
}
7782
fileNameWithSymlinkExtension = CFStringCreateWithFormat(kCFAllocatorDefault, NULL, CFSTR("%@ symlink"), fileName);
7883
destinationURL = CFURLCreateCopyAppendingPathComponent(kCFAllocatorDefault, desktopFolderURL, fileNameWithSymlinkExtension, false);

0 commit comments

Comments
 (0)