diff options
author | Steven Knight <knight@baldmt.com> | 2002-04-25 10:28:24 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2002-04-25 10:28:24 (GMT) |
commit | ed580001466a51a8bb8cf16f15e858d02866fb88 (patch) | |
tree | 0bf25db6a6857703dc1ae6d2a87c292fde97f3e9 /src/engine/SCons/Node/FS.py | |
parent | 6238fcb0f5fb8cd4aef9d956414618dbe5aa4072 (diff) | |
download | SCons-ed580001466a51a8bb8cf16f15e858d02866fb88.zip SCons-ed580001466a51a8bb8cf16f15e858d02866fb88.tar.gz SCons-ed580001466a51a8bb8cf16f15e858d02866fb88.tar.bz2 |
Don't create a directory Node when a file already exists there, and vice versa. (Chad Austin)
Diffstat (limited to 'src/engine/SCons/Node/FS.py')
-rw-r--r-- | src/engine/SCons/Node/FS.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py index 861fbaf..d629d40 100644 --- a/src/engine/SCons/Node/FS.py +++ b/src/engine/SCons/Node/FS.py @@ -167,6 +167,7 @@ class FS: path_comp = path_comp[1:] else: path_comp = [ path_first, ] + path_comp[1:] + # Lookup the directory for path_name in path_comp[:-1]: path_norm = _my_normcase(path_name) @@ -176,6 +177,14 @@ class FS: except KeyError: if not create: raise UserError + + # look at the actual filesystem and make sure there isn't + # a file already there + path = os.path.join(str(directory), path_name) + if os.path.isfile(path): + raise TypeError, \ + "File %s found where directory expected." % path + dir_temp = Dir(path_name, directory) directory.entries[path_norm] = dir_temp directory.add_wkid(dir_temp) @@ -186,6 +195,19 @@ class FS: except KeyError: if not create: raise UserError + + # make sure we don't create File nodes when there is actually + # a directory at that path on the disk, and vice versa + path = os.path.join(str(directory), path_comp[-1]) + if fsclass == File: + if os.path.isdir(path): + raise TypeError, \ + "Directory %s found where file expected." % path + elif fsclass == Dir: + if os.path.isfile(path): + raise TypeError, \ + "File %s found where directory expected." % path + ret = fsclass(path_comp[-1], directory) directory.entries[file_name] = ret directory.add_wkid(ret) |