Show left files info
This commit is contained in:
parent
c789e4c493
commit
cd95f6b87f
@ -13,7 +13,41 @@ end
|
||||
pid = $$
|
||||
END {
|
||||
if pid == $$
|
||||
FileUtils.rm_rf(tmpdir)
|
||||
begin
|
||||
Dir.rmdir(tmpdir)
|
||||
rescue Errno::ENOENT
|
||||
rescue Errno::ENOTEMPTY
|
||||
require_relative "colorize"
|
||||
colorize = Colorize.new
|
||||
mode_inspect = ->(m, s) {
|
||||
[
|
||||
(m & 0o4 == 0 ? ?- : ?r),
|
||||
(m & 0o2 == 0 ? ?- : ?w),
|
||||
(m & 0o1 == 0 ? (s ? s.upcase : ?-) : (s || ?x)),
|
||||
]
|
||||
}
|
||||
filecolor = ->(st) {
|
||||
st.directory? ? "bold;blue" : st.link? ? "bold;cyan" : st.executable? ? "bold;green" : nil
|
||||
}
|
||||
warn colorize.notice("Children under ")+colorize.fail(tmpdir)+":"
|
||||
Dir.children(tmpdir).each do |child|
|
||||
path = File.join(tmpdir, child)
|
||||
st = File.lstat(path)
|
||||
m = st.mode
|
||||
m = [
|
||||
(st.file? ? ?- : st.ftype[0]),
|
||||
mode_inspect[m >> 6, (?s unless m & 04000 == 0)],
|
||||
mode_inspect[m >> 3, (?s unless m & 02000 == 0)],
|
||||
mode_inspect[m, (?t unless m & 01000 == 0)],
|
||||
].join("")
|
||||
warn [
|
||||
" ", m, st.nlink, st.size, st.mtime,
|
||||
colorize.decorate(child, filecolor[st]),
|
||||
(["->", colorize.cyan(File.readlink(path))] if st.symlink?),
|
||||
].compact.join(" ")
|
||||
end
|
||||
FileUtils.rm_rf(tmpdir)
|
||||
end
|
||||
end
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user