Method: LinuxStat::FTW.stat_all

Defined in:
lib/linux_stat/ftw.rb

.stat_all(path = __dir__, flags = nil) ⇒ Object

Show info about all directories and files in a given path and under its subdirectories. It accepts two arguments: * path: Path is the expanded path that you want to walk through. * flags: Flags will give you the ability to tune the output as you desire.

Each flag value can be obtained through LinuxStat::NFTW.constants().
Or you can use LinuxStat::NFTW::FLAGS for readable flags in hash format.
You can do Or-ing to add multiple flags. More info here:
https://man7.org/linux/man-pages/man3/ftw.3.html
If no flags or nil were given as the second argument,
it will use LS::NFTW::FTW_DEPTH | LS::NFTW::FTW_CONTINUE by default.

The return value contains a Hash. The hash contains two keys: ‘error` and a `value`.

* error: If there were any exceptions, the key will be set to true, otherwise false.
       Having an error means not all values are listed in the `value` array.
* value: Is an array, it can or cannot be empty regardless of errors.
  The `value` key contains an array of Hashes. Each hash contains the following information about a file:
      1. type_flag: Type of the file.
      2. level: Depth of the file.
      3. st_size: Size of the file in bytes.
      4. path: Full path of the file.
      5. basename: basename of the file.

Usage Example:

	 LinuxStat::FTW.stat_all(File.expand_path('~/.rvm/lib/'), LS::NFTW::FTW_DEPTH | LS::NFTW::FTW_CONTINUE)
  => {:value=>[{:type_flag=>:FTW_F, :level=>1, :st_size=>278, :path=>"/home/user/.rvm/lib/rvm.rb", :basename=>"rvm.rb"}, {:type_flag=>:FTW_F, :level=>2, :st_size=>286, :path=>"/home/user/.rvm/lib/rvm/capistrano.rb", :basename=>"capistrano.rb"}, {:type_flag=>:FTW_DP, :level=>1, :st_size=>27, :path=>"/home/user/.rvm/lib/rvm", :basename=>"rvm"}, {:type_flag=>:FTW_DP, :level=>0, :st_size=>31, :path=>"/home/user/.rvm/lib", :basename=>"lib"}], :error=>false}

Internally calls LinuxStat::NFTW.stat(path, flag).



36
37
38
39
40
41
# File 'lib/linux_stat/ftw.rb', line 36

def stat_all(path = __dir__, flags = nil)
	LS::NFTW.stat(
		path,
		flags ? flags : LS::NFTW::FTW_DEPTH | LS::NFTW::FTW_CONTINUE
	)
end