+mount_list_text_variable.set("yaffs2/")
+current_directory_dict={}
+open_windows_list=[]
+
+class editor():
+ yaffs_handle=0
+ file_editor_root =0
+ save_button=[]
+ file_contents=0
+ file_path=0
+ def save_file(self):
+ #global current_directory_dict
+ print "saving the file"
+ print self.file_editor_text.get("1.0", tk.END) ##"1.0" is the index of the first line of text
+ yaffs_lseek(self.yaffs_handle, 0, 0)
+ data_to_be_written=self.file_editor_text.get("1.0", tk.END)
+ print "data to be saved", data_to_be_written
+ x=len(data_to_be_written)
+ print "length of data to be written",x
+ output=yaffs_write(self.yaffs_handle,data_to_be_written , x)
+ print "output", output
+ yaffs_close(self.yaffs_handle)
+ self.yaffs_handle = yaffs_open(self.file_path,66,0666)
+
+ def __init__(self):
+ global current_directory_dict
+ x=name_list_box.curselection()
+ self.id=int(x[0])
+ self.file_editor_root =tk.Toplevel()
+ self.save_button=tk.Button(self.file_editor_root, text="save", command=self.save_file)
+ self.save_button.pack()
+
+ self.file_path=current_directory_dict[self.id]["path"]
+ print "file path", self.file_path
+ self.file_editor_root.title(current_directory_dict[self.id]["path"])
+ self.file_editor_text=tk.Text(self.file_editor_root)
+ self.yaffs_handle = yaffs_open(current_directory_dict[self.id]["path"],66,0666)
+ length_of_file=yaffs_lseek(self.yaffs_handle, 0, 2) ##seeks to the end of the file
+ yaffs_lseek(self.yaffs_handle, 0, 0)## returns the handle to the front of th file
+ self.file_contents=ctypes.create_string_buffer(length_of_file)
+ yaffs_read(self.yaffs_handle,self.file_contents,length_of_file)
+ print "file contents", self.file_contents.raw
+ self.file_editor_text.insert(tk.END, self.file_contents.raw)
+ self.file_editor_text.pack()
+
+
+def load_dir():
+ global current_directory_dict
+ print "loading a new directory*******************************************************************"
+ name_list_box.delete(0, tk.END)
+ current_directory_dict=yaffs_ls(mount_list_text_variable.get())
+ print "new directory", current_directory_dict
+ ##copy directory into file box
+ for x in range(0,len(current_directory_dict)):
+ name_list_box.insert(x,(current_directory_dict[x]["inodes"]+" "+ current_directory_dict[x]["type"]+" "+ current_directory_dict[x]["size"]+" "+ current_directory_dict[x]["path"]))
+ name_list_box.grid(column=0, row=1)
+ return current_directory_dict
+def save_file():
+ print file_editor_text.get(0, end)