@@ -34,8 +34,6 @@ const aboutId = "_about"
3434const backId = "_back"
3535const scratchId = "_scratch"
3636const scratch_file = HOME + "/scratch.bas"
37- const labelTemp = chr( 183 ) + "Temporary Files" + chr( 183 )
38- const labelProj = chr( 183 ) + "Project Files" + chr( 183 )
3937
4038func mk_menu(value, lab, x)
4139 local bn
256254
257255sub loadFileList(path, byref basList)
258256 erase basList
259- local emptyNode, ext_storage, int_storage
257+ local emptyNode
260258
261259 func walker(node)
262260 if (node.depth== 0 ) then
@@ -270,38 +268,43 @@ sub loadFileList(path, byref basList)
270268 endif
271269 return node.depth == 0
272270 end
273- dirwalk path, "" , use walker(x)
274-
275- if (path = "/" && is_android) then
276- ext_storage = env( "EXTERNAL_DIR" )
277- if (len(ext_storage) > 0 ) then
278- emptyNode.name = mid(ext_storage, 2 )
279- emptyNode.dir = true
280- emptyNode.size = ""
281- emptyNode.mtime = 0
282- basList << emptyNode
283- endif
284- int_storage = env( "INTERNAL_DIR" )
285- if (len(int_storage) > 0 && int_storage != ext_storage) then
286- emptyNode.name = mid(int_storage, 2 )
287- emptyNode.dir = true
288- emptyNode.size = ""
289- emptyNode.mtime = 0
290- basList << emptyNode
291- endif
271+
272+ func androidWalker(node)
273+ if (node.depth == 0 && node.dir == 0 && lower(right(node.name, 4 )) == ".bas" ) then
274+ basList << node
275+ endif
276+ return node.depth == 0
277+ end
278+
279+ if (is_android) then
280+ path = env( "EXTERNAL_DIR" )
281+ if (len(path) > 0 ) then
282+ dirwalk path, "" , use androidWalker(x)
283+ endif
284+ path = env( "INTERNAL_DIR" )
285+ if (len(path) > 0 ) then
286+ dirwalk path, "" , use androidWalker(x)
287+ endif
288+ path = env( "LEGACY_DIR" )
289+ if (len(path) > 0 ) then
290+ dirwalk path, "" , use androidWalker(x)
291+ endif
292+ else
293+ dirwalk path, "" , use walker(x)
292294 endif
293295end
294296
295297sub listFiles( byref frm, path, sortDir, byref basList)
296- local lastItem, bn, abbr, gap, n, lab, name, txtcol, i, pathx
298+ local lastItem, bn, abbr, gap, n, lab, name, txtcol, i
297299 local name_col = colNav
298300 local size_col = colNav
299301 local date_col = colNav
300302
301- if (right(path, 1 ) != "/" ) then
302- path += "/"
303- endif
303+ sub fix_path
304+ if (right(path, 1 ) != "/" ) then path += "/"
305+ end
304306
307+ fix_path
305308 loadFileList(path, basList)
306309 select case sortDir
307310 case 0
@@ -323,9 +326,9 @@ sub listFiles(byref frm, path, sortDir, byref basList)
323326 date_col = colNav2
324327 end select
325328
326- func mk_bn(id , labText, labCol)
329+ func mk_bn(value , labText, labCol)
327330 local bn
328- bn.value = id
331+ bn.value = value
329332 bn.label = labText
330333 bn.color = labCol
331334 bn.x = 3
@@ -341,28 +344,15 @@ sub listFiles(byref frm, path, sortDir, byref basList)
341344 frm.inputs << bn
342345 end
343346
344- sub mk_link(id , labText, labCol, x, y)
345- local bn = mk_bn(id , labText, labCol)
347+ sub mk_link(value , labText, labCol, x, y)
348+ local bn = mk_bn(value , labText, labCol)
346349 bn.type = "link"
347350 bn.x = x
348351 bn.y = y
349352 frm.inputs << bn
350353 end
351354
352355 if (is_android) then
353- pathx = mid(path, 1 , len(path) - 1 )
354- if (pathx == env( "INTERNAL_DIR" ) || pathx == "/data/data/net.sourceforge.smallbasic/files" ) then
355- mk_link(env( "EXTERNAL_DIR" ), "[Project Files]" , colDir, 3 , -lineSpacing)
356- mk_label(labelTemp, colText, -char_w, - 1 )
357- elseif (pathx == env( "EXTERNAL_DIR" )) then
358- mk_label(labelProj, colText, 3 , -lineSpacing)
359- mk_link(env( "INTERNAL_DIR" ), "[Temporary Files]" , colDir, -char_w, - 1 )
360- else
361- logprint env( "EXTERNAL_DIR" )
362- logprint pathx
363- mk_link(env( "EXTERNAL_DIR" ), "[Project Files]" , colDir, 3 , -lineSpacing)
364- mk_label( "Files in " + path, colText, -char_w, - 1 )
365- endif
366356 mk_link(sortNameId, "[Name]" , name_col, 0 , -linespacing)
367357 else
368358 mk_label( "Files in " + path, colText, 3 , -lineSpacing)
@@ -381,6 +371,10 @@ sub listFiles(byref frm, path, sortDir, byref basList)
381371 node = basList(i)
382372 txtcol = iff(node.dir, colDir, colFile)
383373 name = node.name
374+ if (node.path) then
375+ path = node.path
376+ fix_path
377+ endif
384378 if (abbr) then
385379 bn = mk_bn(path + name, name, txtcol)
386380 bn.type = "link"
0 commit comments