summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDirk Baechle <dl9obn@darc.de>2014-11-05 13:56:56 (GMT)
committerDirk Baechle <dl9obn@darc.de>2014-11-05 13:56:56 (GMT)
commitad21677e236fb53db18f42402ec7f024f3e58a36 (patch)
tree2b3a9c9cf003d6627f278117b49fc8e60ba49c74 /src
parent9866a7f445bb30e8cb16cc1f9c0225dfc1061ff5 (diff)
downloadSCons-ad21677e236fb53db18f42402ec7f024f3e58a36.zip
SCons-ad21677e236fb53db18f42402ec7f024f3e58a36.tar.gz
SCons-ad21677e236fb53db18f42402ec7f024f3e58a36.tar.bz2
- added new method rentry_exists_on_disk (check for physical files/dirs)
Diffstat (limited to 'src')
-rw-r--r--src/engine/SCons/Node/FS.py33
-rw-r--r--src/engine/SCons/Node/FSTests.py26
2 files changed, 59 insertions, 0 deletions
diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py
index 219718c..e73dd92 100644
--- a/src/engine/SCons/Node/FS.py
+++ b/src/engine/SCons/Node/FS.py
@@ -1830,6 +1830,12 @@ class Dir(Base):
return self.tpath + OS_SEP + name
def entry_exists_on_disk(self, name):
+ """ Searches through the file/dir entries of the current
+ directory, and returns True if a physical entry with the given
+ name could be found.
+
+ @see rentry_exists_on_disk
+ """
try:
d = self.on_disk_entries
except AttributeError:
@@ -1854,6 +1860,33 @@ class Dir(Base):
else:
return name in d
+ def rentry_exists_on_disk(self, name):
+ """ Searches through the file/dir entries of the current
+ *and* all its remote directories (repos), and returns
+ True if a physical entry with the given name could be found.
+ The local directory (self) gets searched first, so
+ repositories take a lower precedence regarding the
+ searching order.
+
+ @see entry_exists_on_disk
+ """
+
+ rentry_exists = self.entry_exists_on_disk(name)
+ if not rentry_exists:
+ # Search through the repository folders
+ norm_name = _my_normcase(name)
+ for rdir in self.get_all_rdirs():
+ try:
+ node = rdir.entries[norm_name]
+ if node:
+ rentry_exists = True
+ break
+ except KeyError:
+ if rdir.entry_exists_on_disk(name):
+ rentry_exists = True
+ break
+ return rentry_exists
+
memoizer_counters.append(SCons.Memoize.CountValue('srcdir_list'))
def srcdir_list(self):
diff --git a/src/engine/SCons/Node/FSTests.py b/src/engine/SCons/Node/FSTests.py
index c4dc2ce..0326717 100644
--- a/src/engine/SCons/Node/FSTests.py
+++ b/src/engine/SCons/Node/FSTests.py
@@ -2052,6 +2052,32 @@ class DirTestCase(_tempdirTestCase):
if os.path.normcase("TeSt") != os.path.normpath("TeSt") or sys.platform == "cygwin":
assert d.entry_exists_on_disk('case-insensitive')
+ def test_rentry_exists_on_disk(self):
+ """Test the Dir.rentry_exists_on_disk() method
+ """
+ test = self.test
+
+ does_not_exist = self.fs.Dir('does_not_exist')
+ assert not does_not_exist.rentry_exists_on_disk('foo')
+
+ test.subdir('d')
+ test.write(['d', 'exists'], "d/exists\n")
+ test.write(['d', 'Case-Insensitive'], "d/Case-Insensitive\n")
+
+ test.subdir('r')
+ test.write(['r', 'rexists'], "r/rexists\n")
+
+ d = self.fs.Dir('d')
+ r = self.fs.Dir('r')
+ d.addRepository(r)
+
+ assert d.rentry_exists_on_disk('exists')
+ assert d.rentry_exists_on_disk('rexists')
+ assert not d.rentry_exists_on_disk('does_not_exist')
+
+ if os.path.normcase("TeSt") != os.path.normpath("TeSt") or sys.platform == "cygwin":
+ assert d.rentry_exists_on_disk('case-insensitive')
+
def test_srcdir_list(self):
"""Test the Dir.srcdir_list() method
"""