mirror of
https://github.com/chromebrew/chromebrew.git
synced 2026-01-09 15:37:56 -05:00
Enable additional temporarily disabled cops (#9394)
This commit is contained in:
committed by
GitHub
parent
fe6e9c4003
commit
eddca7e0e8
@@ -11,25 +11,25 @@ module DebUtils
|
||||
# extract_deb('example.deb', /*/) # extract all files from example.deb
|
||||
#
|
||||
file_found = false
|
||||
src_fileIO = File.open(file, 'rb')
|
||||
file_size = src_fileIO.size
|
||||
src_file_io = File.open(file, 'rb')
|
||||
file_size = src_file_io.size
|
||||
# get first line of the given file, should be a signature string (`!<arch>\n`) if it is a valid deb file
|
||||
signature = src_fileIO.gets
|
||||
signature = src_file_io.gets
|
||||
|
||||
abort 'Malformed archive :/'.lightred unless signature == "!<arch>\n"
|
||||
|
||||
# process each file in archive
|
||||
while (line = src_fileIO.gets)
|
||||
if line.chomp.empty? && (file_size == src_fileIO.tell)
|
||||
while (line = src_file_io.gets)
|
||||
if line.chomp.empty? && (file_size == src_file_io.tell)
|
||||
# early return if trailing newline is detected
|
||||
break
|
||||
elsif line.chomp.empty?
|
||||
warn "Unexpected newline in offset #{src_fileIO.tell}, ignoring...".yellow
|
||||
warn "Unexpected newline in offset #{src_file_io.tell}, ignoring...".yellow
|
||||
next
|
||||
end
|
||||
|
||||
# read file meta
|
||||
name, modtime, uid, gid, mode, size, end_char = \
|
||||
name, _modtime, _uid, _gid, mode, size, end_char = \
|
||||
line.scan(/(.{16})(.{12})(.{6})(.{6})(.{8})(.{10})(.{1})/).flatten.map(&:strip)
|
||||
|
||||
# remove slash suffix from filename (if any)
|
||||
@@ -40,18 +40,18 @@ module DebUtils
|
||||
abort 'Malformed archive :/'.lightred unless end_char == '`'
|
||||
|
||||
# capture file in archive with given offset bytes (file size)
|
||||
fileContent = src_fileIO.read(size.to_i)
|
||||
file_content = src_file_io.read(size.to_i)
|
||||
|
||||
# filter filename if a target file is specified
|
||||
if target.is_a?(String) && (name == target)
|
||||
# if target is passed as string, write matched file to filesyetem and exit function
|
||||
# write to filesystem
|
||||
return File.binwrite(name, fileContent, perm: mode.to_i(8))
|
||||
return File.binwrite(name, file_content, perm: mode.to_i(8))
|
||||
elsif target.is_a?(Regexp) && name =~ (target)
|
||||
# if target is passed as regex, write matched file to filesyetem and continue
|
||||
# searching for another matched file until EOF
|
||||
# write to filesystem
|
||||
File.binwrite(name, fileContent, perm: mode.to_i(8))
|
||||
File.binwrite(name, file_content, perm: mode.to_i(8))
|
||||
file_found = true
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user