Function RenewList()
Print "Enter Renew List: " + Gui.FileOperations.File_CurrentPath
Local FileList:String[] = LoadDir(Gui.FileOperations.File_CurrentPath)
For Local temp:String = Eachin FileList
Print temp
next
Use brl.process, it has a CurrentDir function. Don't ask me why it is in that module. I simply don't know.I did see at the top of the os module the word deprecating and to use brl.filesystem and brl.filepath instead however neither has a CurrentDir function used in gbFileOperations.
Import brl.filesystem
Import brl.filepath
Import brl.process
Import mojo
Function Main:Int()
New MyGame()
Return 0
End function
Class MyGame Extends App
Field curDir:= CurrentDir()
Method OnCreate()
End Method
Method OnUpdate()
Local dirList:String[] = LoadDir(curDir)
For Local item:=Eachin dirList
If FileType(item) = FILETYPE_DIR
Print(item + " <Dir>")
Else
Print(item)
End If
Next
'now try changing directory up
If KeyHit(KEY_UP)
Local L:String[] = curDir.Split("/")
If L.Length < 2 Then Return 0
Local NewPath:String
For Local i = 0 To L.Length - 2
If NewPath = "" Then
NewPath = L[i]
Else
NewPath = NewPath + "/" + L[i]
End If
Next
curDir = NewPath
Print curDir
End if
End Method
End Class
Yes, it is called basically at the set framerate. See mojo.app.SetUpdateRate to see its effects. Default is set to 60 frames per second.It’s because the siting is in OnUpdate and gets called every frame
Import brl.filesystem
Import brl.filepath
Import brl.process
Import mojo
Function Main:Int()
New MyGame()
Return 0
End function
Class MyGame Extends App
Field curDir:= CurrentDir()
Field dirList:String[]
Field dirChanged:Bool
Method OnCreate()
RenewList()
dirChanged=False
End Method
Method OnUpdate()
If dirChanged
RenewList()
dirChanged = False
End If
'now try changing directory up
If KeyHit(KEY_UP)
Local L:String[] = curDir.Split("/")
If L.Length < 2 Then Return 0
Local NewPath:String
For Local i = 0 To L.Length - 2
If NewPath = "" Then
NewPath = L[i]
Else
NewPath = NewPath + "/" + L[i]
End If
Next
curDir = NewPath
dirChanged = True
Print curDir
End if
End Method
Method RenewList()
dirList = LoadDir(curDir)
For Local item:=Eachin dirList
If FileType(item) = FILETYPE_DIR
Print(item + " <Dir>")
Else
Print(item)
End If
Next
End Method
End Class
Function LoadDir:String[]( path:String,recursive:Bool=False,hidden:Bool=False )
Local dirs:=New StringDeque
Local files:=New StringStack
If Not path.EndsWith( "/" ) path+="/"
#If HOST<>"winnt"
If Not ( path.StartsWith( "/" ) Or path.StartsWith( "." )) Then path="/"+path
#End
dirs.PushLast ""
While Not dirs.IsEmpty()
Local dir:String=dirs.PopFirst()
For Local f:String=Eachin _LoadDir( path+dir )
If Not hidden And f.StartsWith(".") Continue
Local p:=dir+f
files.Push p
If recursive And FileType( path+p )=FILETYPE_DIR dirs.PushLast p+"/"
Next
Wend
Return files.ToArray()
End
Import brl.filesystem
Import brl.filepath
Import brl.process
Import mojo
Function Main:Int()
New MyGame()
Return 0
End function
Class MyGame Extends App
Field curDir:= CurrentDir()
Field dirList:String[]
Field dirChanged:Bool
Method OnCreate()
RenewList()
dirChanged=False
End Method
Method OnUpdate()
If dirChanged
RenewList()
dirChanged = False
End If
'now try changing directory up
If KeyHit(KEY_UP)
Local L:String[] = curDir.Split("/")
If L.Length < 2 Then Return 0
Local NewPath:String
For Local i = 0 To L.Length - 2
If NewPath = "" Then
NewPath = L[i]
Else
NewPath = NewPath + "/" + L[i]
End If
Next
curDir = NewPath
dirChanged = True
Print curDir
End if
End Method
Method RenewList()
dirList = LoadDir(curDir)
For Local item:=Eachin dirList
Print (FileType(item)) 'added this**********
If FileType(item) = FILETYPE_DIR
Print(item + " <Dir>")
Else
Print(item)
End If
Next
End Method
End Class