file_iter.bi:
Code: Select all
'' ruben.coder@gmail.com
namespace chi
'' never use this in multiple threads or this on one thread
'' and DIR() on another, etc...
type FILE_ITER
declare constructor( byref path as string )
declare operator for( )
declare operator step( )
declare operator next( byref end_cond as FILE_ITER ) as integer
declare function filename( ) as string
as string p_pathname, p_latest
end type
end namespace
#inclib "file_iter"
Code: Select all
'' ruben.coder@gmail.com
#include "file_iter.bi"
namespace chi
constructor FILE_ITER( byref path as string )
p_pathname = path
end constructor
operator FILE_ITER.for( )
p_latest = dir(p_pathname & "/*.*")
end operator
operator FILE_ITER.step( )
p_latest = dir("")
end operator
operator FILE_ITER.next( byref end_cond as FILE_ITER ) as integer
return p_latest <> ""
end operator
function FILE_ITER.filename( ) as string
return p_latest
end function
end namespace
Code: Select all
#include "file_iter.bi"
using chi
'' change it to any directory
for i as FILE_ITER = "d:\media\music\cha0s" to ""
? i.filename( )
next