+def delete_selected(selected_dir=0):
+ if selected_dir==0:
+ print"using current_directory_dict"
+ global current_directory_dict
+ x=name_list_box.curselection()
+ x=int(x[0])
+ print current_directory_dict[x]["type"]
+ if current_directory_dict[x]["type"]=="file":
+ path=current_directory_dict[x]["path"]
+ path =path
+ output=yaffs_unlink(path)
+ print "unlinking output:", output
+ elif current_directory_dict[x]["type"]=="dir":
+ path=current_directory_dict[x]["path"]
+ inside_dir=yaffs_ls(path)
+ print "files and folder inside dir", inside_dir
+ print "len of dir", len(inside_dir)
+ if inside_dir!=[]: ##if the dir is not empty
+ ## remove stuff in dir
+ for i in range(0,len(inside_dir)):
+ print "calling self*****"
+ delete_selected(inside_dir[i])
+
+ path =path[0:len(path)-1] ##this is to remove the "/" off the end of the of the file
+ print "removing:", path
+ output=yaffs_rmdir(path)
+ print "rmdir output:", output
+ else :
+ print "using passed dir"
+ print "dir passed", selected_dir
+ current_directory_dict =selected_dir
+
+ print "after copying", current_directory_dict
+ print current_directory_dict["type"]
+ if current_directory_dict["type"]=="file":
+ path=current_directory_dict["path"]
+ path =path
+ output=yaffs_unlink(path)
+ print "unlinking output:", output
+ elif current_directory_dict["type"]=="dir":
+ path=current_directory_dict["path"]
+ inside_dir=yaffs_ls(path)
+ print "files and folder inside dir", inside_dir
+ print "len of dir", len(inside_dir)
+ if inside_dir!=[]: ##if the dir is not empty
+ ## remove stuff in dir
+ for i in range(0,len(inside_dir)):
+ print "calling self*****"
+ delete_selected(inside_dir[i])
+
+ path =path[0:len(path)-1] ##this is to remove the "/" off the end of the of the file
+ print "removing:", path
+ output=yaffs_rmdir(path)
+ print "rmdir output:", output
+
+
+
+ load_dir()
+
+
+
+class new_file():
+ path_entry_box=0
+ new_file_window=0
+ def open_the_file(self):
+ global mount_list_text_variable
+ print "trying to create", mount_list_text_variable.get()+self.path_entry_box.get()
+ yaffs_handle=yaffs_open(self.path_entry_box.get(),66,0666)
+ yaffs_close(yaffs_handle)
+ self.new_file_window.destroy()
+ load_dir()
+
+ def cancel(self):
+ ##del self
+ self.new_file_window.destroy()
+ def __init__(self):
+ global mount_list_text_variable
+ self.new_file_window =tk.Toplevel(takefocus=True)
+ path_frame=tk.Frame(self.new_file_window)
+ path_label=tk.Label(path_frame, text="file path")
+ path_label.pack(side=tk.LEFT)
+ text=tk.StringVar()
+ text.set(mount_list_text_variable.get())
+ print "############################",mount_list_text_variable.get()
+ self.path_entry_box= tk.Entry(path_frame, textvariable=text)
+ self.path_entry_box.pack(side=tk.RIGHT)
+ path_frame.pack()
+ button_frame=tk.Frame(self.new_file_window)
+ create_button=tk.Button(button_frame, text="Create", command=self.open_the_file)
+ create_button.pack(side=tk.LEFT)
+ cancel_button=tk.Button(button_frame, text="Cancel", command=self.cancel)
+ cancel_button.pack(side=tk.RIGHT)
+ button_frame.pack()
+
+class new_folder():
+ path_entry_box=0
+ new_folder_window=0
+ def create_the_folder(self):
+ global mount_list_text_variable
+ print "trying to create", mount_list_text_variable.get()+self.path_entry_box.get()
+ yaffs_mkdir(self.path_entry_box.get(),0666)
+ self.new_folder_window.destroy()
+
+ load_dir()
+
+ def cancel(self):
+ ##del self
+ self.new_folder_window.destroy()
+ def __init__(self):
+ global mount_list_text_variable
+ self.new_folder_window =tk.Toplevel(takefocus=True)
+ path_frame=tk.Frame(self.new_folder_window)
+ path_label=tk.Label(path_frame, text="directory path")
+ path_label.pack(side=tk.LEFT)
+ text=tk.StringVar()
+ text.set(mount_list_text_variable.get())
+ print "############################",mount_list_text_variable.get()
+ self.path_entry_box= tk.Entry(path_frame, textvariable=text)
+ self.path_entry_box.pack(side=tk.RIGHT)
+ path_frame.pack()
+ button_frame=tk.Frame(self.new_folder_window)
+ create_button=tk.Button(button_frame, text="Create", command=self.create_the_folder)
+ create_button.pack(side=tk.LEFT)
+ cancel_button=tk.Button(button_frame, text="Cancel", command=self.cancel)
+ cancel_button.pack(side=tk.RIGHT)
+ button_frame.pack()
+
+