Well I have added lib/std/posix/filesystem.flx. This contains "stat" and 
"readdir" etc
at the moment.

There is also a nice wrapper shown here:

//-----------------------------
include "std/posix/filesystem";
open List;
println "Scanning directory";
var result = FileSystem::filesin(".");
println "Scan done";
match result with
| None => { println "ERROR"; }
| Some ?files => { println "Files"; println files; println "Done"; }
endmatch;
println "Finished";
//-------------------------

which yields:

Scanning directory
Scan done
Files
['.', '..', '.DS_Store', '.f.flx.swp', '.git', '.gitignore', '.gitmodules', 
'bin', 'build', 'buildsystem', 'cpkgs', 'demos', 'f', 'f.cpp', 'f.dylib', 
'f.flx', 'f.hpp', 'f.includes', 'f.o', 'f.os', 'f.par', 'f.resh', 'f.rtti', 
'f.why', 'f_ctors.cpp', 'fbuild', 'fbuildroot.py', 'fbuildroot.pyc', 
'flx_version.py', 'flxg_stats.txt', 'interscript', 'lpsrc', 'misc', 'mydb.db', 
're2', 'sandbox', 'script', 'specs', 'speed', 'src', 't', 't.cpp', 't.dylib', 
't.flx', 't.hpp', 't.includes', 't.o', 't.os', 't.par', 't.resh', 't.rtti', 
't.why', 't1.tmp', 't2.tmp', 't_ctors.cpp', 'test', 'test.fdoc', 'tgc.cpp', 
'tgc.dylib', 'tgc.flx', 'tgc.hpp', 'tgc.includes', 'tgc.os', 'tgc.par', 
'tgc.resh', 'tgc.rtti', 'tgc.why', 'tgc_ctors.cpp', 'tmp.log', 'tmp.out', 
'tmp.tmp', 'tmp.txt', 'tmp1.tmp', 'tmp2.log', 'tmp2.tmp', 'tools', 
'webserver.files', 'xx', 'xxspkgs']
Done
Finished

Oh, I have some rubbish there .. :)

I will make some functions to:

a) get all the non-directory files
b) get all the sub-directories

as well and perhaps:

c) all the files with a union constructor indicating dir or POF (Plain Old 
File).
d) fully populated directory tree (recursively find things)
e) skeleton (just subdirs, recursively).

perhaps this can be done with a single data structure and some
flags, not sure.

I'm also thinking of a very radical one:

f) fully LOADED tree.

which means it actually has the contents of all the files loaded into memory as 
well.
This makes copying a directory a one liner.. :)

A smart version of this could use lazy evaluation, even smarter use mmap.

The Python version of this (the tree walker thing) is all wrong.

--
john skaller
skal...@users.sourceforge.net





------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
Felix-language mailing list
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to