3 #include "bcnewfolder.h"
5 #include "filesystem.h"
16 BC_NewFolder::BC_NewFolder(int x, int y, BC_FileBox *filebox)
17 : BC_Window(filebox->get_newfolder_title(),
30 BC_NewFolder::~BC_NewFolder()
35 int BC_NewFolder::create_objects()
38 add_tool(new BC_Title(x, y, _("Enter the name of the folder:")));
40 add_subwindow(textbox = new BC_TextBox(x, y, 300, 1, _("Untitled")));
42 add_subwindow(new BC_OKButton(this));
44 add_subwindow(new BC_CancelButton(this));
49 char* BC_NewFolder::get_text()
51 return textbox->get_text();
55 BC_NewFolderThread::BC_NewFolderThread(BC_FileBox *filebox)
58 this->filebox = filebox;
60 change_lock = new Mutex("BC_NewFolderThread::change_lock");
61 completion_lock = new Condition(1, "BC_NewFolderThread::completion_lock");
64 BC_NewFolderThread::~BC_NewFolderThread()
68 delete completion_lock;
71 void BC_NewFolderThread::run()
73 int x = filebox->get_abs_cursor_x(1);
74 int y = filebox->get_abs_cursor_y(1);
75 change_lock->lock("BC_NewFolderThread::run 1");
76 window = new BC_NewFolder(x,
79 window->create_objects();
80 change_lock->unlock();
83 int result = window->run_window();
87 char new_folder[BCTEXTLEN];
88 filebox->fs->join_names(new_folder, filebox->fs->get_current_dir(), window->get_text());
89 mkdir(new_folder, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
90 filebox->lock_window("BC_NewFolderThread::run");
92 filebox->unlock_window();
95 change_lock->lock("BC_NewFolderThread::run 2");
98 change_lock->unlock();
100 completion_lock->unlock();
103 int BC_NewFolderThread::interrupt()
105 change_lock->lock("BC_NewFolderThread::interrupt");
108 window->lock_window("BC_NewFolderThread::interrupt");
110 window->unlock_window();
113 change_lock->unlock();
115 completion_lock->lock("BC_NewFolderThread::interrupt");
116 completion_lock->unlock();
120 int BC_NewFolderThread::start_new_folder()
126 window->lock_window("BC_NewFolderThread::start_new_folder");
127 window->raise_window();
128 window->unlock_window();
129 change_lock->unlock();
133 change_lock->unlock();
134 completion_lock->lock("BC_NewFolderThread::start_new_folder");