]> gitweb.michael.orlitzky.com - mailshears.git/blobdiff - lib/common/filesystem.rb
Factor out common code that can be used to mv (rename) accounts.
[mailshears.git] / lib / common / filesystem.rb
diff --git a/lib/common/filesystem.rb b/lib/common/filesystem.rb
new file mode 100644 (file)
index 0000000..72ff901
--- /dev/null
@@ -0,0 +1,22 @@
+class Filesystem
+
+  def self.begins_with_dot(path)
+    return (path[0..0] == '.')
+  end
+
+  def self.get_subdirs(dir)
+    subdirs = []
+
+    Dir.open(dir) do |d|
+      d.each do |entry|
+        relative_path = File.join(dir, entry)
+        if (File.directory?(relative_path) and not begins_with_dot(entry))
+          subdirs << entry
+        end
+      end
+    end
+
+    return subdirs
+  end
+
+end