module File
Public Class Methods
symlink(target_name, link_name)
click to toggle source
# File lib/dyndoc/common/file.rb, line 28 def symlink(target_name, link_name) #if on windows, call mklink, else self.symlink if RUBY_PLATFORM =~ /mswin32|cygwin|mingw|bccwin/ #windows mklink syntax is reverse of unix ln -s #windows mklink is built into cmd.exe #vulnerable to command injection, but okay because this is a hack to make a cli tool work. opt = (File.directory? target_name) ? "/D" : "" stdin, stdout, stderr, wait_thr = Open3.popen3('cmd.exe', "/c mklink " + opt + "#{link_name} #{target_name}") wait_thr.value.exitstatus else self.old_symlink(target_name, link_name) end end
Also aliased as: old_symlink
symlink?(file_name)
click to toggle source
# File lib/dyndoc/common/file.rb, line 42 def symlink?(file_name) #if on windows, call mklink, else self.symlink if RUBY_PLATFORM =~ /mswin32|cygwin|mingw|bccwin/ #vulnerable to command injection because calling with cmd.exe with /c? stdin, stdout, stderr, wait_thr = Open3.popen3("cmd.exe /c dir #{file_name} | find \"SYMLINK\"") wait_thr.value.exitstatus else self.old_symlink?(file_name) end end
Also aliased as: old_symlink?