;; returns a list of file names in dir
;;
;; for example:
;; (win32_list_dir2 (Str "c:/Users/andrew/Documents/code/extempore/*"))
;; (win32_list_dir2 (Str "c:/Users/andrew/Documents/code/extempore/*.exe"))
(bind-func win32_list_dir
(lambda (dir:String*)
(let ((data:WIN32_FIND_DATA* (salloc))
(hfind:HANDLE (FindFirstFileA (cstring dir) data))
(lst:List{String*}* (list)))
(if (= hfind INVALID_HANDLE_VALUE)
lst
(begin
(set! lst (cons (get_file_name data) lst))
(while (FindNextFileA hfind data)
(set! lst (cons (get_file_name data) lst)))
(FindClose hfind)
lst)))))