Show left tmpdir recursively
This commit is contained in:
parent
9b6affa4a1
commit
c65bc2e5d9
@ -31,23 +31,29 @@ END {
|
|||||||
filecolor = ->(st) {
|
filecolor = ->(st) {
|
||||||
st.directory? ? "bold;blue" : st.symlink? ? "bold;cyan" : st.executable? ? "bold;green" : nil
|
st.directory? ? "bold;blue" : st.symlink? ? "bold;cyan" : st.executable? ? "bold;green" : nil
|
||||||
}
|
}
|
||||||
|
list_tree = ->(parent, indent = " ") {
|
||||||
|
Dir.children(parent).each do |child|
|
||||||
|
path = File.join(parent, 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 [
|
||||||
|
indent, m, st.nlink, st.size, st.mtime,
|
||||||
|
colorize.decorate(child, filecolor[st]),
|
||||||
|
(["->", colorize.cyan(File.readlink(path))] if st.symlink?),
|
||||||
|
].compact.join(" ")
|
||||||
|
if st.directory?
|
||||||
|
list_tree[File.join(parent, child), indent + " "]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
}
|
||||||
warn colorize.notice("Children under ")+colorize.fail(tmpdir)+":"
|
warn colorize.notice("Children under ")+colorize.fail(tmpdir)+":"
|
||||||
Dir.children(tmpdir).each do |child|
|
list_tree[tmpdir]
|
||||||
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)
|
FileUtils.rm_rf(tmpdir)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user