diff options
| author | Steven Knight <knight@baldmt.com> | 2009-02-23 14:55:04 (GMT) |
|---|---|---|
| committer | Steven Knight <knight@baldmt.com> | 2009-02-23 14:55:04 (GMT) |
| commit | 10009653a53d64a49ca5e3bfd016c34ca2f5d1fb (patch) | |
| tree | 87333fb00025497dd248a35b690accdda1d78180 /src/engine | |
| parent | 36ca75113047a8e0bb76e650b9f2e9c4e3ead187 (diff) | |
| download | SCons-10009653a53d64a49ca5e3bfd016c34ca2f5d1fb.zip SCons-10009653a53d64a49ca5e3bfd016c34ca2f5d1fb.tar.gz SCons-10009653a53d64a49ca5e3bfd016c34ca2f5d1fb.tar.bz2 | |
Issue 2152: Fix the ability of --clean to handle / delete broken
symlinks, as well as named pipes. (Mateusz Gruca)
Diffstat (limited to 'src/engine')
| -rw-r--r-- | src/engine/SCons/Script/Main.py | 9 | ||||
| -rw-r--r-- | src/engine/SCons/compat/__init__.py | 7 |
2 files changed, 14 insertions, 2 deletions
diff --git a/src/engine/SCons/Script/Main.py b/src/engine/SCons/Script/Main.py index cad241f..883af40 100644 --- a/src/engine/SCons/Script/Main.py +++ b/src/engine/SCons/Script/Main.py @@ -305,8 +305,8 @@ class CleanTask(SCons.Taskmaster.AlwaysTask): """An SCons clean task.""" def fs_delete(self, path, pathstr, remove=1): try: - if os.path.exists(path): - if os.path.isfile(path): + if os.path.lexists(path): + if os.path.isfile(path) or os.path.islink(path): if remove: os.unlink(path) display("Removed " + pathstr) elif os.path.isdir(path) and not os.path.islink(path): @@ -326,6 +326,11 @@ class CleanTask(SCons.Taskmaster.AlwaysTask): # then delete dir itself if remove: os.rmdir(path) display("Removed directory " + pathstr) + else: + errstr = "Path '%s' exists but isn't a file or directory." + raise SCons.Errors.UserError(errstr % (pathstr)) + except SCons.Errors.UserError, e: + print e except (IOError, OSError), e: print "scons: Could not remove '%s':" % pathstr, e.strerror diff --git a/src/engine/SCons/compat/__init__.py b/src/engine/SCons/compat/__init__.py index 542d31e..2a86324 100644 --- a/src/engine/SCons/compat/__init__.py +++ b/src/engine/SCons/compat/__init__.py @@ -167,6 +167,13 @@ except AttributeError: elif 'nt' in _names: os.devnull = 'nul' os.path.devnull = os.devnull +try: + os.path.lexists +except AttributeError: + # Pre-2.4 Python has no os.path.lexists function + def lexists(path): + return os.path.exists(path) or os.path.islink(path) + os.path.lexists = lexists import shlex try: |
