summary refs log tree commit diff stats
path: root/code/directory.py
diff options
context:
space:
mode:
Diffstat (limited to 'code/directory.py')
-rw-r--r--code/directory.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/code/directory.py b/code/directory.py
index d8855432..e28bf35c 100644
--- a/code/directory.py
+++ b/code/directory.py
@@ -1,8 +1,10 @@
 class FrozenException(Exception): pass
+class NotLoadedYet(Exception): pass
 
 class Directory():
 	def __init__(self, path):
 		self.path = path
+		self.accessible = False
 		self.files_loaded = False
 		self.scheduled = False
 		self.files = None
@@ -17,9 +19,11 @@ class Directory():
 		try:
 			self.files = os.listdir(self.path)
 			self.exists = True
+			self.accessible = True
 		except OSError:
-			self.files = []
+			self.files = None
 			self.exists = False
+			self.accessible = False
 		self.files_loaded = True
 
 	def clone(self):
@@ -34,9 +38,11 @@ class Directory():
 		return clone
 
 	def __len__(self):
+		if not self.accessible: raise NotLoadedYet()
 		return len(self.files)
 	
 	def __getitem__(self, key):
+		if not self.accessible: raise NotLoadedYet()
 		return self.files[key]
 
 if __name__ == '__main__':