Class: File

Inherits:
Object
  • Object
show all
Defined in:
lib/seqtrimnext/utils/string_utils.rb

Class Method Summary collapse

Class Method Details

.is_zip?(file_path) ⇒ Boolean

Returns:

  • (Boolean)


31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/seqtrimnext/utils/string_utils.rb', line 31

def self.is_zip?(file_path)
  res=false
  begin
    f=File.open(file_path,'rb')
    head=f.read(4)
    f.close
    res=(head=="PK\x03\x04")
  rescue
    res=false
  end
  
  return res
end

.unzip(file_path) ⇒ Object



45
46
47
48
49
50
51
52
53
54
# File 'lib/seqtrimnext/utils/string_utils.rb', line 45

def self.unzip(file_path)
  unzipped=`unzip "#{file_path}"`
  file_list = unzipped.split("\n")
  list=[]
  
  # select only the files, not folders
  list=file_list.select{|e| e=~/inflating/}.map{|e| e.gsub('inflating:','').strip}
  
  return list
end