+class new_symlink():
+ path_entry_box=0
+ target_text=0
+ new_text=0
+ new_file_window=0
+ def create_the_symlink(self):
+ global mount_list_text_variable
+ ##check the symlink's target is a file.
+ target_path=self.target_text.get()
+ new_path=self.new_text.get()
+ print "creating a symlink \n target:", target_path
+ target_file_exists=yaffs_access(target_path, 0) ##yaffs_access will return 0 on success and -1 on failure.
+ if target_file_exists>=0:
+ ##file exists,create symlink
+ print "target file exist, creating symlink"
+ yaffs_symlink(target_path, new_path)
+ self.new_file_window.destroy()
+ else :
+ ##file does not exist
+ print "target file does not exist, cannot create symlink"
+ 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)
+ target_frame=tk.Frame(self.new_file_window)
+ target_label=tk.Label(target_frame, text="target")
+ target_label.pack(side=tk.LEFT)
+ self.target_text=tk.StringVar()
+ self.target_text.set(mount_list_text_variable.get())
+ #print "############################",mount_list_text_variable.get()
+ self.target_entry_box= tk.Entry(target_frame, textvariable=self.target_text)
+ self.target_entry_box.pack(side=tk.RIGHT)
+ target_frame.pack()
+
+ new_frame=tk.Frame(self.new_file_window)
+ new_label=tk.Label(new_frame, text="file path")
+ new_label.pack(side=tk.LEFT)
+ self.new_text=tk.StringVar()
+ self.new_text.set(mount_list_text_variable.get())
+ #print "############################",mount_list_text_variable.get()
+ self.new_entry_box= tk.Entry(new_frame, textvariable=self.new_text)
+ self.new_entry_box.pack(side=tk.RIGHT)
+ new_frame.pack()
+
+ button_frame=tk.Frame(self.new_file_window)
+ create_button=tk.Button(button_frame, text="Create", command=self.create_the_symlink)
+ 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_hardlink():
+ path_entry_box=0
+ target_text=0
+ new_text=0
+ new_file_window=0
+ def create_the_hardlink(self):
+ global mount_list_text_variable
+ ##check the symlink's target is a file.
+ target_path=self.target_text.get()
+ new_path=self.new_text.get()
+ print "creating a hardlink \n target:", target_path
+ target_file_exists=yaffs_access(target_path, 0) ##yaffs_access will return 0 on success and -1 on failure.
+ if target_file_exists>=0:
+ ##file exists,create symlink
+ print "target file exist, creating hardlink"
+ yaffs_link(target_path, new_path)
+ self.new_file_window.destroy()
+ else :
+ ##file does not exist
+ print "target file does not exist, cannot create hardlink"
+ 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)
+ target_frame=tk.Frame(self.new_file_window)
+ target_label=tk.Label(target_frame, text="target")
+ target_label.pack(side=tk.LEFT)
+ self.target_text=tk.StringVar()
+ self.target_text.set(mount_list_text_variable.get())
+ #print "############################",mount_list_text_variable.get()
+ self.target_entry_box= tk.Entry(target_frame, textvariable=self.target_text)
+ self.target_entry_box.pack(side=tk.RIGHT)
+ target_frame.pack()
+
+ new_frame=tk.Frame(self.new_file_window)
+ new_label=tk.Label(new_frame, text="file path")
+ new_label.pack(side=tk.LEFT)
+ self.new_text=tk.StringVar()
+ self.new_text.set(mount_list_text_variable.get())
+ #print "############################",mount_list_text_variable.get()
+ self.new_entry_box= tk.Entry(new_frame, textvariable=self.new_text)
+ self.new_entry_box.pack(side=tk.RIGHT)
+ new_frame.pack()
+
+ button_frame=tk.Frame(self.new_file_window)
+ create_button=tk.Button(button_frame, text="Create", command=self.create_the_hardlink)
+ 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()