summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--code/directory.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/code/directory.py b/code/directory.py
index 4cb9fd72..d8855432 100644
--- a/code/directory.py
+++ b/code/directory.py
@@ -1,3 +1,4 @@
+class FrozenException(Exception): pass
 
 class Directory():
 	def __init__(self, path):
@@ -8,8 +9,11 @@ class Directory():
 		self.mtime = None
 		self.exists = True
 
+		self.frozen = False
+
 	def load_files(self):
 		import os
+		if self.frozen: raise FrozenException()
 		try:
 			self.files = os.listdir(self.path)
 			self.exists = True
@@ -18,6 +22,17 @@ class Directory():
 			self.exists = False
 		self.files_loaded = True
 
+	def clone(self):
+		clone = Directory(self.path)
+		for key in iter(self.__dict__):
+			clone.__dict__[key] = self.__dict__[key]
+		return clone
+
+	def frozenClone(self):
+		clone = self.clone()
+		clone.frozen = True
+		return clone
+
 	def __len__(self):
 		return len(self.files)