[plt-dev] `tar', `find-files', and `fold-files'

From: Eli Barzilay (eli at barzilay.org)
Date: Thu Jul 2 11:54:35 EDT 2009

I've recently tried to use `tar' (actually, `tar-gzip') for my web
page (which I'm finally dragging out of the 90s), and the state of
things in that neighborhood is pretty bad.  It goes like this:

* I have all ".svn" directories in the result of a tarred directory.

* You cannot specify a filter -- you're basically left with the lower
  level and less convenient `tar->output' (which is worse if you want
  to gzip the result).

* To get a list of files, you would (and `tar' does) use `find-files'.
  That one is getting a predicate -- but it is pretty bad because the
  predicate gets the whole path, and it doesn't apply to including
  subdirectories.  The amount of work that the code would do if you
  wanted to omit a single directory based on its name would be
  ridiculous (you'd need to explode each path, turn all components to
  strings, then look for the one you want to omit -- and it would
  still run your code on all of the subpaths).

* The next level up is `fold-files'.  Even that is not too convenient;
  since it applies the function on the full path, but at least you can
  decide whether to descend into the directory or not.

* There should also be a way to have it (`find-files' or `fold-files')
  sort the contents.

* It would also be nice to have a way to keep files in string form,
  since that's a common case.

Any suggestions on how to resolve this -- hopefully with preserving
backward compatibility?

My best idea for `fold-files' is to add an optional function to get
the list of paths from a directory -- such a function can easily
ignore certain paths based on their name (ignoring the path leading to
them), and it can also sort the names.  Maybe also make the paths be
kept as strings if this function returns strings?  (Maybe by making it
in charge of constructing the paths?)

As for `find-files', I don't have any good ideas.  Maybe add keywords
to it, and make things like `tar' use the same keywords?  In light of
things as extreme as `file->string', I definitely thing that there
should be a way to say things like "give me the list of paths,
excluding `.svn' directories".

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!


Posted on the dev mailing list.