File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed
Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -556,9 +556,22 @@ fn listCompilers(allocator: Allocator) !void {
556556 {
557557 var it = install_dir .iterate ();
558558 while (try it .next ()) | entry | {
559- if (entry .kind != .directory )
559+ var target = entry .name ;
560+ var link_buffer : [std .fs .max_path_bytes ]u8 = undefined ;
561+ var real_buffer : [std .fs .max_path_bytes ]u8 = undefined ;
562+ if (entry .kind == .sym_link ) {
563+ const link_path = install_dir .readLink (entry .name , & link_buffer ) catch continue ;
564+ const real_path = install_dir .realpath (link_path , & real_buffer ) catch continue ;
565+ const relative = try std .fs .path .relative (allocator , install_dir_string , real_path );
566+ defer allocator .free (relative );
567+ if (std .fs .path .isAbsolute (relative ) or std .mem .startsWith (u8 , relative , ".." )) {
568+ continue ;
569+ }
570+ install_dir .access (link_path , .{}) catch continue ;
571+ target = link_path ;
572+ } else if (entry .kind != .directory )
560573 continue ;
561- if (std .mem .endsWith (u8 , entry . name , ".installing" ))
574+ if (std .mem .endsWith (u8 , target , ".installing" ))
562575 continue ;
563576 try stdout .print ("{s}\n " , .{entry .name });
564577 }
You can’t perform that action at this time.
0 commit comments