summaryrefslogtreecommitdiff
path: root/jni/ruby/sample/fullpath.rb
diff options
context:
space:
mode:
authorJari Vetoniemi <jari.vetoniemi@indooratlas.com>2020-03-16 18:49:26 +0900
committerJari Vetoniemi <jari.vetoniemi@indooratlas.com>2020-03-30 00:39:06 +0900
commitfcbf63e62c627deae76c1b8cb8c0876c536ed811 (patch)
tree64cb17de3f41a2b6fef2368028fbd00349946994 /jni/ruby/sample/fullpath.rb
Fresh start
Diffstat (limited to 'jni/ruby/sample/fullpath.rb')
-rw-r--r--jni/ruby/sample/fullpath.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/jni/ruby/sample/fullpath.rb b/jni/ruby/sample/fullpath.rb
new file mode 100644
index 0000000..112ca58
--- /dev/null
+++ b/jni/ruby/sample/fullpath.rb
@@ -0,0 +1,23 @@
+#! /usr/local/bin/ruby
+# convert ls-lR filename into fullpath.
+
+if ARGV[0] =~ /-p/
+ ARGV.shift
+ path = ARGV.shift
+end
+
+if path == nil
+ path = ""
+elsif path !~ %r|/$|
+ path += "/"
+end
+
+while line = gets()
+ case line
+ when /:$/
+ path = line.chop.chop + "/"
+ when /^total/, /^d/
+ when /^(.*\d )(.+)$/
+ print($1, path, $2, "\n")
+ end
+end