From 7681c7584f0496b77d249d89afbb7d95089dc4b7 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Fri, 27 Dec 2013 11:40:24 -0500 Subject: [PATCH] add String#absolute_path? --- lib/rscons/environment.rb | 2 +- lib/rscons/monkey/string.rb | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/rscons/environment.rb b/lib/rscons/environment.rb index d1ee802..8a24f44 100644 --- a/lib/rscons/environment.rb +++ b/lib/rscons/environment.rb @@ -99,7 +99,7 @@ module Rscons end end if @build_root and not found_match - unless source_fname.start_with?('/') or source_fname =~ %r{^\w:[\\/]} + unless source_fname.absolute_path? build_fname = "#{@build_root}/#{build_fname}" end end diff --git a/lib/rscons/monkey/string.rb b/lib/rscons/monkey/string.rb index b17ebef..bb70541 100644 --- a/lib/rscons/monkey/string.rb +++ b/lib/rscons/monkey/string.rb @@ -17,4 +17,9 @@ class String def set_suffix(suffix = '') sub(/\.[^.]*$/, suffix) end + + # Return whether the string represents an absolute filesystem path + def absolute_path? + self =~ %r{^(/|\w:[\\/])} + end end