1818#
1919# Namespace for several file utility methods for copying, moving, removing, etc.
2020#
21+ # == About the Examples
22+ #
23+ # Some examples here involve trees of file entries.
24+ # For these, we sometimes display trees using the
25+ # {tree command-line utility}[https://en.wikipedia.org/wiki/Tree_(command)],
26+ # which is a recursive directory-listing utility that produces
27+ # a depth-indented listing of files and directories.
28+ #
29+ # We use a helper method to launch the command and control the format:
30+ #
31+ # def tree(dirpath = '.')
32+ # command = "tree --noreport --charset=ascii #{dirpath}"
33+ # system(command)
34+ # end
35+ #
36+ # To illustrate, here's the tree for the test directory for \FileUtils:
37+ # tree('test')
38+ # test
39+ # |-- fileutils
40+ # | |-- clobber.rb
41+ # | |-- fileasserts.rb
42+ # | |-- test_dryrun.rb
43+ # | |-- test_fileutils.rb
44+ # | |-- test_nowrite.rb
45+ # | |-- test_verbose.rb
46+ # | `-- visibility_tests.rb
47+ # `-- lib
48+ # |-- core_assertions.rb
49+ # |-- envutil.rb
50+ # |-- find_executable.rb
51+ # `-- helper.rb
52+ #
2153# === Module Functions
2254#
2355# require 'fileutils'
@@ -839,7 +871,7 @@ def cp_r(src, dest, preserve: nil, noop: nil, verbose: nil,
839871 #
840872 # If +src+ is a directory, recursively copies +src+ to +dest+:
841873 #
842- # system('tree --charset=ascii src1')
874+ # tree(' src1')
843875 # src1
844876 # |-- dir0
845877 # | |-- src0.txt
@@ -848,7 +880,7 @@ def cp_r(src, dest, preserve: nil, noop: nil, verbose: nil,
848880 # |-- src2.txt
849881 # `-- src3.txt
850882 # FileUtils.copy_entry('src1', 'dest1')
851- # system('tree --charset=ascii dest1')
883+ # tree(' dest1')
852884 # dest1
853885 # |-- dir0
854886 # | |-- src0.txt
@@ -923,14 +955,14 @@ def copy_stream(src, dest)
923955 # If +src+ is the path to a single file or directory and +dest+ does not exist,
924956 # moves +src+ to +dest+:
925957 #
926- # system('tree --charset=ascii src0')
958+ # tree(' src0')
927959 # src0
928960 # |-- src0.txt
929961 # `-- src1.txt
930962 # File.exist?('dest0') # => false
931963 # FileUtils.mv('src0', 'dest0')
932964 # File.exist?('src0') # => false
933- # system('tree --charset=ascii dest0')
965+ # tree(' dest0')
934966 # dest0
935967 # |-- src0.txt
936968 # `-- src1.txt
@@ -940,13 +972,13 @@ def copy_stream(src, dest)
940972 # copies from each path in the array to +dest+:
941973 #
942974 # File.file?('src1.txt') # => true
943- # system('tree --charset=ascii src1')
975+ # tree(' src1')
944976 # src1
945977 # |-- src.dat
946978 # `-- src.txt
947979 # Dir.empty?('dest1') # => true
948980 # FileUtils.mv(['src1.txt', 'src1'], 'dest1')
949- # system('tree --charset=ascii dest1')
981+ # tree(' dest1')
950982 # dest1
951983 # |-- src1
952984 # | |-- src.dat
@@ -1076,7 +1108,7 @@ def rm_f(list, noop: nil, verbose: nil)
10761108 #
10771109 # For each directory path, recursively removes files and directories:
10781110 #
1079- # system('tree --charset=ascii src1')
1111+ # tree(' src1')
10801112 # src1
10811113 # |-- dir0
10821114 # | |-- src0.txt
0 commit comments