diff options
author | Erlang/OTP <[email protected]> | 2010-01-30 09:21:08 +0000 |
---|---|---|
committer | Erlang/OTP <[email protected]> | 2010-01-30 09:21:08 +0000 |
commit | 3add162b87ba2c2d6b4922ac4b8c5f0c59fb2d5d (patch) | |
tree | fa042554c1acfb5d2475b4f284710083bbbc7b8d /lib/stdlib/src/filelib.erl | |
parent | 1cfb7ea778a90a234ae811666a594057198920b4 (diff) | |
parent | 67657eddd662b2367b36a336d38c674e477e1184 (diff) | |
download | otp-3add162b87ba2c2d6b4922ac4b8c5f0c59fb2d5d.tar.gz otp-3add162b87ba2c2d6b4922ac4b8c5f0c59fb2d5d.tar.bz2 otp-3add162b87ba2c2d6b4922ac4b8c5f0c59fb2d5d.zip |
Merge branch 'ta/ensure_dir_eexist' into ccase/r13b04_dev
* 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.)
Diffstat (limited to 'lib/stdlib/src/filelib.erl')
-rw-r--r-- | lib/stdlib/src/filelib.erl | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/lib/stdlib/src/filelib.erl b/lib/stdlib/src/filelib.erl index d65588f0d1..74c5172137 100644 --- a/lib/stdlib/src/filelib.erl +++ b/lib/stdlib/src/filelib.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 1997-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 1997-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% -module(filelib). @@ -228,7 +228,17 @@ ensure_dir(F) -> ok; false -> ensure_dir(Dir), - file:make_dir(Dir) + case file:make_dir(Dir) of + {error,eexist}=EExist -> + case do_is_dir(Dir, file) of + true -> + ok; + false -> + EExist + end; + Err -> + Err + end end. |