lib/rscm/path_converter.rb in rscm-0.4.0 vs lib/rscm/path_converter.rb in rscm-0.4.2
- old
+ new
@@ -9,58 +9,52 @@
module PathConverter
def filepath_to_nativepath(path, escaped)
return nil if path.nil?
path = File.expand_path(path)
if(WIN32)
- path.gsub(/\//, "\\")
+ escaped ? path.gsub(/\//, "\\\\\\\\") : path.gsub(/\//, "\\")
elsif(CYGWIN)
- cmd = "cygpath --windows #{path}"
- Better.popen(cmd) do |io|
- cygpath = io.read.chomp
- escaped ? cygpath.gsub(/\\/, "\\\\\\\\") : cygpath
- end
+ cygpath = `cygpath --windows #{path}`.chomp
+ escaped ? cygpath.gsub(/\\/, "\\\\\\\\") : cygpath
else
path
end
end
+ module_function :filepath_to_nativepath
def filepath_to_nativeurl(path)
return nil if path.nil?
if(WINDOWS)
urlpath = filepath_to_nativepath(path, false).gsub(/\\/, "/")
"file:///#{urlpath}"
else
"file://#{File.expand_path(path)}"
end
end
+ module_function :filepath_to_nativeurl
def nativepath_to_filepath(path)
return nil if path.nil?
path = File.expand_path(path)
if(WIN32)
path.gsub(/\//, "\\")
elsif(CYGWIN)
path = path.gsub(/\\/, "/")
- cmd = "cygpath --unix #{path}"
- Better.popen(cmd) do |io|
- io.read.chomp
- end
+ `cygpath --unix #{path}`.chomp
else
path
end
end
+ module_function :nativepath_to_filepath
def ensure_trailing_slash(url)
return nil if url.nil?
if(url && url[-1..-1] != "/")
"#{url}/"
else
url
end
end
-
- module_function :filepath_to_nativepath
- module_function :filepath_to_nativeurl
- module_function :nativepath_to_filepath
module_function :ensure_trailing_slash
+
end
end