When setting the server directory to DirRootExternal, everything was normal. After changing the directory to DirInternal, the FTP client received a response of 500 Invalid path. I found that the path results returned by the following functions are different
CanonicalPath:/data/data/b4a.example2/files/aa
BaseDir:/data/user/0/b4a.example2/files/aa
false
B4X:
Private Sub NormalizePath(p As String) As String
If p.StartsWith("/") Or p.StartsWith("\") Then p = p.SubString(1)
#if B4A Or B4J
Dim jo As JavaObject
jo.InitializeNewInstance("java.io.File", Array(File.Combine(mServer.BaseDir, p)))
Dim CanonicalPath As String = jo.RunMethod("getCanonicalPath", Null)
Log("CanonicalPath:" & CanonicalPath.ToLowerCase)
Log("BaseDir:" & mServer.BaseDir.ToLowerCase)
Log(CanonicalPath.ToLowerCase.StartsWith(mServer.BaseDir.ToLowerCase))
If CanonicalPath.ToLowerCase.StartsWith(mServer.BaseDir.ToLowerCase) Then
Dim r As String = CanonicalPath.SubString(mServer.BaseDir.Length).Replace("\", "/")
If r.Length = 0 Then Return "/" Else Return r
Else
SendResponse(450, "Invalid path: " & p)
Return ""
End If
CanonicalPath:/data/data/b4a.example2/files/aa
BaseDir:/data/user/0/b4a.example2/files/aa
false