From 907e349c11b2ef689434e9e3504b97a6c0a843b6 Mon Sep 17 00:00:00 2001 From: hut Date: Sun, 22 Nov 2009 21:13:09 +0100 Subject: a partly done directory class --- code/directory.rb | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 code/directory.rb diff --git a/code/directory.rb b/code/directory.rb new file mode 100644 index 00000000..5c6e84c1 --- /dev/null +++ b/code/directory.rb @@ -0,0 +1,66 @@ +# A Class that contains data about directories +class Directory + class LoadStatus + # @n contains a three bit number: x3x2x1 + # x1: + # 0 = not scheduled + # 1 = scheduled + # x3x2: + # 00 = nothing loaded + # 01 = got the list of files + # 10 = + # 11 = got the list of files and entry objects + def initialize(n = 0) + @n = 0 + end + + def got_files? + # is bit 2 nd 3 == 01 + return n & 2 == 2 + end + + def scheduled? + # is the first bit 1? + return n & 1 == 1 + end + + def got_objects? + return n & 4 == 4 + end + attr_accessor :n + end + + def initialize(path) + @path = path + @status = LoadStatus.new(0) + @files = [] + @sort_time = nil + @mtime = nil +# @width = 1000 + @read = false + @free_space = nil + @empty = true + @scheduled = false + end + + # {{{ Trivial + def inspect + return "" + end + alias to_s inspect + + def size + return @files.size + end + + def not_loaded? + return @level == 0 + end + def file_list_loaded? + return @level >= 1 + end + def ready? + return @level >= 2 + end + # }}} +end -- cgit 1.4.1-2-gfad0