aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/src/filelib.erl
AgeCommit message (Collapse)Author
2013-09-12Remove ^L characters hidden randomly in the code. Not those used in text ↵Pierre Fenoll
files as delimiters. While working on a tool that processes Erlang code and testing it against this repo, I found out about those little sneaky 0xff. I thought it may be of help to other people build such tools to remove non-conforming-to-standard characters.
2013-07-21Update filelib.erl typespecsJosé Valim
Most functions in filelib support binaries as arguments but that was not reflected in the typespecs. The types filename_all() and dirname_all() were introduced to mimic file:name_all().
2013-02-22Update copyright yearsBjörn-Egil Dahlberg
2013-02-13Remove special case handling "-" at the beginning of a charsetBjörn Gustavsson
We don't need this special case, since "-" is only special between two other characters.
2013-02-13Optimize character sets using gb_setsBjörn Gustavsson
2013-02-13Clean up and simplify the inner matching loopBjörn Gustavsson
Use list comprehensions and 'orelse' to make the code more concise. Rename wildcard_5/2 to match_part/2 to make it clearer what it does. If the pattern always matches, don't test it in every iteration of the loop.
2013-02-13Only sort the result list once, just before returningBjörn Gustavsson
There does not seem to be any advantage of sorting the result of file:list_dir/1 directly. Disadvantages are that we'll need to be careful to keep the result sorted, and that we could waste time sorting filenames that the pattern matching will discard anyway.
2013-02-13Replace filename:join/2 with '++'Björn Gustavsson
Under controlled circumstances (and we are in control of the circumstances), filename:join/2 can be replaced with '++'. '++' is faster because it is implmented in C, does not need to look at the list elements it copies, and does not need to copy its right operand.
2013-02-13Rethink the filelib:wildcard() functionsBjörn Gustavsson
Commit 70b5e24c9498225fadc08d19503269c8aad851bf broke filelib:wildcard(Pattern, "."). Over the years, the logic for filelib:wilcard() has become a mess of special cases. Probably because of premature optimization, filelib:wildcard(Pattern) and filelib:wildcard(Pattern, Cwd) are handled differently. They can be consolidated if we use a "." as the default Cwd argument. We can also simplify things by compiling the Cwd argument into the wildcard. We did not that in the initial implementation because it used to be possible to pre-compile a wildcard and pass it to filelib:wildcard/{1,2}. Since that is no longer possible, there is no point in keeping the compiled wildcard "portable" (not dependent on the Cwd argument).
2013-02-13Don't redefine error/1Björn Gustavsson
It is confusing. Rename our own exception-generating function to badpattern/1.
2013-02-13Don't allow binaries as the Cwd argument for filelib:wildcard()Björn Gustavsson
filelib:wildcard() will no longer support "raw filenames", so it makes no sense for it to accept a binary Cwd argument.
2013-02-13Don't handle binaries from file:list_dir/1Björn Gustavsson
In R16B, file:list_dir/1 will never return binaries.
2012-09-17Allow ** in filelib:wildcardJosé Valim
Two adjacent * used as a single pattern will match all files and zero or more directories and subdirectories.
2012-09-12Fix filelib:wildcard/2Björn Gustavsson
filelib:wildcard("some/relative/path/*.beam", Path) would fail to match any file. That is, filelib:wildcard/2 would not work if the first component of the pattern did not contain any wildcard characters. Noticed-by: Samuel Rivas
2012-08-31Update copyright yearsBjörn-Egil Dahlberg
2012-05-23Fix infinite loop when an invalid drive letter it givenLukas Larsson
2011-05-12Types and specifications have been modified and addedHans Bolinder
2010-12-03Test and correct filelib and filenamePatrik Nyblom
2010-12-01Make filelib not crash on re codepoints beyond 255 in re when filename is rawPatrik Nyblom
2010-11-30Teach filelib to use re in unicode mode when filenames are not rawPatrik Nyblom
2010-09-10Remove warnings for clashes with new autoimported BIFsPatrik Nyblom
2010-03-07file.hrl: Move out type declarationsKostis Sagonas
Having various type declarations in the file.hrl file was once upon a time necessary since the system could not really handle remote types. Now it can and these declarations should not be there but appear in file.erl instead. This means that files that need to use these types can refer to them using a remote type reference, and not having to include file.hrl - at least not for this reason.
2010-01-30Merge branch 'ta/ensure_dir_eexist' into ccase/r13b04_devErlang/OTP
* ta/ensure_dir_eexist: filelib_SUITE: strenghten tests of filelib:ensure_dir/1 Don't return a false {error,eexist} in filelib:ensure_dir/1 OTP-8389 Because of a race condition, using filelib:ensure_dir/1 from multiple processes to create the same path or parts of the same directory structure, filelib:ensure_dir/1 could return a meaningless {error,eexist}. That race condition has been eliminated, and {error,eexist} will now be returned only if there exists a regular file, device file, or some other non-directory file with the same name. (Thanks to Tuncer Ayaz.)
2010-01-18Don't return a false {error,eexist} in filelib:ensure_dir/1Tuncer Ayaz
This is about the non-atomicity of filelib:ensure_dir/1. When using filelib:ensure_dir/1 from multiple processes to create the same path or parts of the same directory structure (which happens with rebar's worker processes) it happens quite a lot that between a file:read_file_info/1 and file:make_dir/1 one of the other procs has already created the directory we want to create. mkdir(1) says one of the following for -p depending on which Unix like system you're on: "no error if existing" "no error will be reported if a directory given as an operand already exists" I've seen more than one Erlang project where the return value of ensure_dir/1 is ignored completely. To eliminate the race condition, call file:make_dir/1 without first testing whether the directory exists. If it succeeds everything is fine. Otherwise, if the error code is {error,eexists}, check whether the directory exists. If it does, everything is fine; if not, return {error,eexist} (which indicates that there exists a regular file with the same name, or (more unlikely) that another process removed the directory after the call to file:make_dir/1). Signed-off-by: Tuncer Ayaz <[email protected]>
2009-11-20The R13B03 release.OTP_R13B03Erlang/OTP