diff options
Diffstat (limited to 'meta/lib/oe/path.py')
-rw-r--r-- | meta/lib/oe/path.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/meta/lib/oe/path.py b/meta/lib/oe/path.py index 8902951581..f58c0138bb 100644 --- a/meta/lib/oe/path.py +++ b/meta/lib/oe/path.py | |||
@@ -42,3 +42,25 @@ def format_display(path, metadata): | |||
42 | return path | 42 | return path |
43 | else: | 43 | else: |
44 | return rel | 44 | return rel |
45 | |||
46 | def remove(path): | ||
47 | """Equivalent to rm -f or rm -rf""" | ||
48 | import os, errno, shutil | ||
49 | try: | ||
50 | os.unlink(path) | ||
51 | except OSError, exc: | ||
52 | if exc.errno == errno.EISDIR: | ||
53 | shutil.rmtree(path) | ||
54 | elif exc.errno != errno.ENOENT: | ||
55 | raise | ||
56 | |||
57 | def symlink(source, destination, force=False): | ||
58 | """Create a symbolic link""" | ||
59 | import os, errno | ||
60 | try: | ||
61 | if force: | ||
62 | remove(destination) | ||
63 | os.symlink(source, destination) | ||
64 | except OSError, e: | ||
65 | if e.errno != errno.EEXIST or os.readlink(destination) != source: | ||
66 | raise | ||