File.RealPath (gb)
Static Function RealPath ( Path As String [ , Parent As Boolean ] ) As String
Since 3.13
Return the canonical absolute pathname of a path, with no symbolic links inside.
Since 3.20
If the optional
Parent argument is
TRUE
, and if
Path is a relative path received from another component (usually by a function argument),
then the returned path will be modified so that it points at the same file.
For example, if
Path is
./image.png
, then
File.Path("./image.png", True)
will return
../image.png
, so that the new path points at the same file as the old path from a calling component.
This function is useful when a public API of a component receives a file path from a call located in another component, usually the main project.
Example
' The Response.SendFile() method from the gb.web component
Public Sub SendFile(Path As String, Optional ContentType As String)
Dim sBuffer As String
Dim hFile As File
$bDone = True
Path = File.RealPath(Path, True)
If Not Exist(Path) Then
Print "Status: 404 Not Found"
Print
Return
Endif
...
End
You must sure that the path comes from another component before using this feature, and you must call it once.
For example, you can't call
Response.SendFile()
from the same component (i.e. from
gb.web
source code) with a local path, because
then it will search for that file in the parent component, not in the
gb.web
component.