/
readdir.rb
21 lines (17 loc) · 913 Bytes
/
readdir.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/local/bin/ruby
# -*- Mode:Ruby; Coding:us-ascii-unix; fill-column:132 -*-
####################################################################################################################################
# @file readdir.rb
# @author Mitch Richling <https://www.mitchr.me/>
# @Copyright Copyright 1994 by Mitch Richling. All rights reserved.
# @brief UNIX directory access.@EOL
# @Keywords UNIX filename directory UFS Ruby opendir readdir
# @Std Ruby
#
# This Ruby program is intended to illustrate how one reads UNIX directories(file names in a subdirectory); however, we
# illustrate the Ruby-esq approach over the more POSIX-like readdir interface.
##----------------------------------------------------------------------------------------------------------------------------------
dirToRead = ARGV.shift;
Dir.foreach(dirToRead) do |dirEnt|
printf("File: %s\n", dirEnt);
end