proposal: expand definition of filename type

James Hague james.hague@REDACTED
Thu Sep 3 17:36:26 CEST 2009

I've found that sometimes it's handy to have filenames as lists--which
is the Erlang standard--and sometimes it's nice to treat them as
binaries.  So here's a proposal: In file access functions, define a
filename to be a binary or an IO list.

1. file:file_open(<<"circus/images/clown.png">>, []).
2. file:file_open([Directory, BaseName, ".dat"], []).

* Filenames, which can potentially be long, don't expand into 8 or 16
bytes per character.  (Think of code that manipulates a huge directory
tree, for example.)
* It's easy to add path names and extensions without copying entire lists.

Open questions:
* Just keep the filename module operating on lists?
* Should there be an alternate version of file:list_dir that returns a
list of binaries?

Note that there shouldn't be any compatibility issues, because lists
are a subset of IO lists.

More information about the erlang-questions mailing list