Class: File

Inherits:
Object
  • Object
show all
Defined in:
lib/rake/helpers/file.rb

Constant Summary collapse

@@separator =
nil

Class Method Summary collapse

Class Method Details

.cygpath(path, flag = nil) ⇒ Object



16
17
18
19
20
# File 'lib/rake/helpers/file.rb', line 16

def self.cygpath(path, flag = nil)
  flag ||= '-w'
  # convert to Windows path

  path = `cygpath #{flag} "#{path}"`.chomp
end

.cygwin?Boolean

Returns:

  • (Boolean)


5
6
7
# File 'lib/rake/helpers/file.rb', line 5

def self.cygwin?
  RUBY_PLATFORM.downcase.include?('cygwin')
end

.dirname2(path, flag = nil) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/rake/helpers/file.rb', line 28

def self.dirname2(path, flag = nil)
  path = dirname(path)
  return path unless cygwin?
  path = cygpath(path, flag)
  path.gsub!('\\', '\\\\') unless flag
  path
end

.expand_path2(path, flag = nil) ⇒ Object



22
23
24
25
26
# File 'lib/rake/helpers/file.rb', line 22

def self.expand_path2(path, flag = nil)
  path = expand_path(path)
  return path unless cygwin?
  return cygpath(path, flag)
end

.separatorObject



9
10
11
12
13
14
# File 'lib/rake/helpers/file.rb', line 9

def self.separator
  return @@separator if @@separator
  # Return `backlash` for Cygwin and Windows (ALT_SEPARATOR)

  # otherwise - system separator

  return @@separator = cygwin? ? '\\' : (ALT_SEPARATOR ? ALT_SEPARATOR : SEPARATOR)
end