Class: BigKeeper::FileOperator

Inherits:
Object
  • Object
show all
Defined in:
lib/big_keeper/util/file_operator.rb

Overview

Operator for got

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.definitely_exists?(path) ⇒ Boolean

Returns:

  • (Boolean)


4
5
6
7
8
9
# File 'lib/big_keeper/util/file_operator.rb', line 4

def self.definitely_exists? path
  folder = File.dirname path
  filename = File.basename path
  # Unlike Ruby IO, ls, and find -f, this technique will fail to locate the file if the case is wrong:
  not %x( find "#{folder}" -name "#{filename}" ).empty?
end

.find_all_code_file(path) ⇒ Object



26
27
28
29
30
# File 'lib/big_keeper/util/file_operator.rb', line 26

def find_all_code_file(path)
  header_file_list = Dir.glob("#{path}/**/*.[h]")
  m_file_list = Dir.glob("#{path}/**/*.[m]")
  return header_file_list+m_file_list
end

.find_all_header_file(path) ⇒ Object



23
24
25
# File 'lib/big_keeper/util/file_operator.rb', line 23

def find_all_header_file(path)
  return Dir.glob("#{path}/**/*.h")
end

Instance Method Details

#current_usernameObject



15
16
17
18
# File 'lib/big_keeper/util/file_operator.rb', line 15

def current_username
  current_name = `whoami`
  current_name.chomp
end

#find_all(path, name) ⇒ Object



11
12
13
# File 'lib/big_keeper/util/file_operator.rb', line 11

def find_all(path, name)
  Dir.glob("#{path}/*/#{name}")
end