diff options
Diffstat (limited to 'generic/tclFCmd.c')
-rw-r--r-- | generic/tclFCmd.c | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/generic/tclFCmd.c b/generic/tclFCmd.c index f8606e5..9ee530b 100644 --- a/generic/tclFCmd.c +++ b/generic/tclFCmd.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclFCmd.c,v 1.32 2005/05/10 18:34:37 kennykb Exp $ + * RCS: @(#) $Id: tclFCmd.c,v 1.33 2005/06/09 16:24:47 vincentdarley Exp $ */ #include "tclInt.h" @@ -261,11 +261,35 @@ TclFileMakeDirsCmd(interp, objc, objv) errfile = target; goto done; } - } else if ((errno != ENOENT) - || (Tcl_FSCreateDirectory(target) != TCL_OK)) { + } else if (errno != ENOENT) { errfile = target; goto done; } + + if (Tcl_FSCreateDirectory(target) != TCL_OK) { + /* + * Create might have failed because of being in a race + * condition with another process trying to create the + * same subdirectory. + */ + if (errno == EEXIST) { + if ((Tcl_FSStat(target, &statBuf) == 0) + && S_ISDIR(statBuf.st_mode)) { + /* + * It is a directory that wasn't there before, + * so keep going without error. + */ + Tcl_ResetResult(interp); + } else { + errfile = target; + goto done; + } + } else { + errfile = target; + goto done; + } + } + /* Forget about this sub-path */ Tcl_DecrRefCount(target); target = NULL; |