Posted 19 March 2015 - 05:39 AM
Been working on a small mzx project, and I have noticed that reading directories being really slow. I'm not doing something stupidly wrong am I?
. "open_dir opens a subdirectory"
. "up_dir opens the parent directory if it has permission"
. "top_dir opens the top-level directory"
color c11
set "$dir_s&dir_s&" to "."
inc "dir_s" by 1
: "set_dir"
set "f" to 0
set "file" to 0
set "dir" to 1
set "ui_dir" to 0
set "ui_file" to 0
set "$dir0" to ".."
set "$dir" to ""
loop start
inc "$dir" by "&$dir_s('loopcount')&"
inc "$dir" by "/"
loop for "('dir_s'-1)"
set "&$dir&" to "fread_open"
: "readdir_l"
set "$buffer" to "fread"
if "$buffer.length" = 0 then "readdir_s"
set "$f&f&" to "$buffer"
inc "f" by 1
goto "readdir_l"
: "readdir_s"
set "" to "fread_open"
if "f" != 0 then "#sortfiles"
end
: "open_dir"
if "$newdir" = ".." then "up_dir"
set "$dir_s&dir_s&" to "$newdir"
inc "dir_s" by 1
set "scroll_new_list_event" to 1
goto "set_dir"
: "up_dir"
if "dir_s" = 1 then "end"
dec "dir_s" by 1
set "scroll_new_list_event" to 1
goto "set_dir"
: "end"
end
: "#sortfiles"
loop start
set "$f" to "$f&loopcount&"
set "&$dir&/&$f&" to "fread_open"
set "fread_pos" to -1
if "fread_pos" = -1 then "sortfiles_s"
if "fread_pos" = 0 then "sortfiles_dir"
set "$file&file&" to "$f"
inc "file" by 1
goto "sortfiles_s"
: "sortfiles_dir"
set "$" to "fread"
if "$.length" = 0 then "sortfiles_s"
set "$dir&dir&" to "$f"
inc "dir" by 1
: "sortfiles_s"
set "" to "fread_open"
loop for "('f'-1)"
goto "#return"
<Nadir> mzxers don't make GAMES, usually
<phthalocyanine> they make experiences.
<Nadir> demos, more like
<Nadir> a glimpse into what could have been if mzx wasn't such a bore to work with
<Nadir> actually, i'm being unfair
<Nadir> i would have made mzx games if it was capable of running on more than 20 computers worldwide in 1998
<Nadir> >:D
<%Alice> functor
<%nooodl> i hear C++ has a thing called functors and they're completely different from Haskell functors...
<rorirover> the result is the most horrid thing in C++, it's basically black magic and it transforms any code you're writing into some eldritch monstrosity