def writeOut(self,dir,hashfile,toplevel,var,folder):
		""" walks a directory, and executes a callback on each file """
		dir = os.path.abspath(dir)
		for file in [file for file in os.listdir(dir) if not file in [".",".."]]:
			nfile = os.path.join(dir,file)
			if os.path.isdir(nfile): # is a directory
				hashfile.write("F::"+nfile.replace(toplevel,"") + "\n")
				hashfile.write("X::\n")
				var.set("Generating... " + "F::"+nfile.replace(toplevel,""))
				root.update()
				if not os.path.exists(folder + '\\' + nfile.replace(toplevel,"")):
					os.mkdir(folder + '\\' + nfile.replace(toplevel,""))

				self.writeOut(nfile,hashfile,toplevel,var,folder)
			else: # is a file
				# Generate the hash and add to hash file
				h=(hashlib.sha1(open(nfile, 'rb').read()).hexdigest())
				hashfile.write(nfile.replace(toplevel,"") + "\n")
				var.set("Generating... " + nfile.replace(toplevel,""))
				root.update()
				hashfile.write(h + "\n")

				# Generate a smaller, gzipped version of the file
				with open(nfile, 'rb') as f_in:
					with gzip.open(folder + '\\' + nfile.replace(toplevel,"") + '.gz', 'wb') as f_out:
						f_out.writelines(f_in)