Code: Select all
EnableExplicit
Define DirID.i, LibID.i
Define Attributes.i, RaisedError.i
Define Path$, LibraryName$
; enumerate all libraries in the given path including their function names
If (OpenConsole("so loading test") <> 0)
Path$ = "/usr/lib"
DirID = ExamineDirectory(#PB_Any, Path$, "*")
While NextDirectoryEntry(DirID)
If (DirectoryEntryType(DirID) = #PB_DirectoryEntry_File)
Attributes = DirectoryEntryAttributes(DirID)
If ((Attributes & #PB_FileSystem_Link) = 0)
LibraryName$ = DirectoryEntryName(DirID)
OnErrorGoto(?SkipLibrary)
RaisedError = 1
LibID = OpenLibrary(#PB_Any, DirectoryEntryName(DirID))
RaisedError = 0
If (LibID <> 0)
If (ExamineLibraryFunctions(LibID) <> 0)
While (NextLibraryFunction() <> 0)
Wend
EndIf
CloseLibrary(LibID)
EndIf
SkipLibrary:
If (RaisedError <> 0)
PrintN(" skipped " + Hex(Attributes) + " = " + LibraryName$)
EndIf
EndIf
EndIf
Wend
FinishDirectory(DirID)
EndIf
Input()

On Neptune linux, this creates a fatal error. Not sure if thats bug report worthy or even really any purbasic bug, but interesting to see imho because it throws a fatal error and purebasic is able to recover and handle the situation with the onerror library.