X-Git-Url: http://nitlanguage.org diff --git a/lib/core/file.nit b/lib/core/file.nit index 2405186..dc1ccb7 100644 --- a/lib/core/file.nit +++ b/lib/core/file.nit @@ -1216,15 +1216,21 @@ redef class String path.add('/') end var error: nullable Error = null - for d in dirs do + for i in [0 .. dirs.length - 1[ do + var d = dirs[i] if d.is_empty then continue path.append(d) path.add('/') - var res = path.to_s.to_cstring.file_mkdir(mode) + if path.file_exists then continue + var res = path.to_cstring.file_mkdir(mode) if not res and error == null then error = new IOError("Cannot create directory `{path}`: {sys.errno.strerror}") end end + var res = self.to_cstring.file_mkdir(mode) + if not res and error == null then + error = new IOError("Cannot create directory `{path}`: {sys.errno.strerror}") + end return error end