Zig 0.17.0-dev (Split by item) This is an example of documentation generated by
ZigDoc , an alternative to Zig's built-in
Auto Doc feature. See also
examples in other modes/formats . The project being documented here (as the example) is the Zig standard library.
std › dynamic_library › ElfDynLib › resolveFromName Private Function resolveFromName Doc Source Private Function std.dynamic_library.ElfDynLib.resolveFromName
fn resolveFromName (io : Io , path_or_name : []const u8 , LD_LIBRARY_PATH : ?[]const u8 ) !Io .File Params io : Io path_or_name : []const u8 LD_LIBRARY_PATH : ?[]const u8 File dynamic_library.zig: 200
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221 fn resolveFromName (io : Io , path_or_name : []const u8 , LD_LIBRARY_PATH : ?[]const u8 ) !Io .File {
if (std .mem .findScalarPos (u8 , path_or_name , 0 , '/' )) |_ | {
return Io .Dir .cwd ().openFile (io , path_or_name , .{});
}
// Only read LD_LIBRARY_PATH if the binary is not setuid/setgid
if (std .os .linux .geteuid () == std .os .linux .getuid () and
std .os .linux .getegid () == std .os .linux .getgid ())
{
if (LD_LIBRARY_PATH ) |ld_library_path | {
if (resolveFromSearchPath (io , ld_library_path , path_or_name , ':' )) |file | {
return file ;
}
}
}
if (resolveFromParent (io , "/lib" , path_or_name )) |file | return file ;
if (resolveFromParent (io , "/lib64" , path_or_name )) |file | return file ;
if (resolveFromParent (io , "/usr/lib" , path_or_name )) |file | return file ;
if (resolveFromParent (io , "/usr/lib64" , path_or_name )) |file | return file ;
return error .FileNotFound ;
}
This implements enough to be able to load system libraries in general Places where it differs from dlopen: