edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/context.rb;C521915 File: context.rb =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/context.rb;C521915 (server) 8/6/2008 2:43 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/context.rb;unniseo @@ -775,13 +775,13 @@ def self.find_executable(executable) executable.downcase! result = [] - search_path = ENV['PATH'].split(';') + search_path = ENV['PATH'].split(File::PATH_SEPARATOR) search_path.each do |dir| - path = dir.gsub '\\', '/' - Dir[path + '/*.exe'].each do |file| - file_path = Pathname.new(file) - result << file_path.dirname if file_path.basename.downcase == executable - end + path = Pathname.new(dir) + file_path = path + executable + result << file_path.dirname if file_path.exist? + file_path = path + executable + '.exe' + result << file_path.dirname if file_path.exist? end result end @@ -806,11 +806,11 @@ load path_to_config if File.exist? path_to_config unless defined?(UserEnvironment::MRI) - ruby_exe_paths = UserEnvironment.find_executable 'ruby.exe' - if ruby_exe_paths.length == 1 + ruby_exe_paths = UserEnvironment.find_executable 'ruby' + unless ruby_exe_paths.empty? UserEnvironment.const_set(:MRI, Pathname.new(ruby_exe_paths.first + '\..\\')) else - raise ArgumentError.new("Found more than one version of ruby.exe on your path #{ruby_exe_paths.join(', ')}") + raise ArgumentError.new("Could not find ruby.exe on your path") end end UserEnvironment.const_set(:TAGS, "#{ENV['HOME']}\\dev\\ironruby-tags".gsub('\\', '/')) unless defined?(UserEnvironment::TAGS) =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Rakefile;C521915 edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/FileOps.cs;C521915 File: FileOps.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/FileOps.cs;C521915 (server) 8/7/2008 9:11 AM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/FileOps.cs;unniseo @@ -219,10 +219,54 @@ [RubyMethod("dirname", RubyMethodAttributes.PublicSingleton)] public static MutableString/*!*/ DirName(CodeContext/*!*/ context, object/*!*/ self, MutableString/*!*/ path) { - string directoryName = System.IO.Path.GetDirectoryName(path.ConvertToString()); + string directoryName = path.ConvertToString(); + if (IsValidPath(path.ConvertToString())) + { + directoryName = System.IO.Path.GetDirectoryName(path.ConvertToString()); + string fileName = System.IO.Path.GetFileName(path.ConvertToString()); + if (!String.IsNullOrEmpty(fileName)) + { + directoryName = StripPathCharacters(path.ConvertToString().Replace(fileName, "")); + } + } + else + { + if (directoryName.Length > 1) + directoryName = "//"; + } return Glob.CanonicalizePath(MutableString.Create(String.IsNullOrEmpty(directoryName) ? "." : directoryName)); } + private static bool IsValidPath(string path) + { + int length = 0; + foreach (char c in path.ToCharArray()) + { + if ((c == '/') || (c == '\\')) + continue; + length++; + } + return (length > 0); + + } + + private static string StripPathCharacters(string path) + { + int limit=0; + for (int charIndex = path.Length - 1; charIndex > 0; charIndex--) + { + if (!((path[charIndex] == '/') || (path[charIndex] == '\\'))) + break; + limit++; + } + if (limit > 0) + { + limit--; + return path.Substring(0, path.Length - limit - 1); + } + return path; + } + [RubyMethod("executable?", RubyMethodAttributes.PublicSingleton)] [RubyMethod("executable_real?", RubyMethodAttributes.PublicSingleton)] public static bool IsExecutable(CodeContext/*!*/ context, object self, [NotNull]MutableString/*!*/ path) { @@ -767,6 +811,7 @@ private readonly static MutableString INTERNAL_SEPARATOR = MutableString.Create("/"); + private readonly static string NUL_VALUE = "NUL"; [RubyConstant] public readonly static MutableString SEPARATOR = INTERNAL_SEPARATOR; @@ -843,6 +888,8 @@ result = new FileInfo(path); } else if (pal.DirectoryExists(path)) { result = new DirectoryInfo(path); + } else if (path.ToUpper().Equals(NUL_VALUE)) { + result = null; } else { return false; } ===================================================================