3 #include "bcnewfolder.h"
5 #include "filesystem.h"
17 BC_NewFolder::BC_NewFolder(int x, int y, BC_FileBox *filebox)
18 : BC_Window(filebox->get_newfolder_title(),
31 BC_NewFolder::~BC_NewFolder()
36 int BC_NewFolder::create_objects()
39 add_tool(new BC_Title(x, y, _("Enter the name of the folder:")));
41 add_subwindow(textbox = new BC_TextBox(x, y, 300, 1, _("Untitled")));
43 add_subwindow(new BC_OKButton(this));
45 add_subwindow(new BC_CancelButton(this));
50 char* BC_NewFolder::get_text()
52 return textbox->get_text();
56 BC_NewFolderThread::BC_NewFolderThread(BC_FileBox *filebox)
59 this->filebox = filebox;
61 change_lock = new Mutex("BC_NewFolderThread::change_lock");
62 completion_lock = new Condition(1, "BC_NewFolderThread::completion_lock");
65 BC_NewFolderThread::~BC_NewFolderThread()
69 delete completion_lock;
72 void BC_NewFolderThread::run()
74 int x = filebox->get_abs_cursor_x(1);
75 int y = filebox->get_abs_cursor_y(1);
76 change_lock->lock("BC_NewFolderThread::run 1");
77 window = new BC_NewFolder(x,
80 window->create_objects();
81 change_lock->unlock();
84 int result = window->run_window();
88 char new_folder[BCTEXTLEN];
89 filebox->fs->join_names(new_folder, filebox->fs->get_current_dir(), window->get_text());
90 mkdir(new_folder, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
91 filebox->lock_window("BC_NewFolderThread::run");
93 filebox->unlock_window();
96 change_lock->lock("BC_NewFolderThread::run 2");
99 change_lock->unlock();
101 completion_lock->unlock();
104 int BC_NewFolderThread::interrupt()
106 change_lock->lock("BC_NewFolderThread::interrupt");
109 window->lock_window("BC_NewFolderThread::interrupt");
111 window->unlock_window();
114 change_lock->unlock();
116 completion_lock->lock("BC_NewFolderThread::interrupt");
117 completion_lock->unlock();
121 int BC_NewFolderThread::start_new_folder()
127 window->lock_window("BC_NewFolderThread::start_new_folder");
128 window->raise_window();
129 window->unlock_window();
130 change_lock->unlock();
134 change_lock->unlock();
135 completion_lock->lock("BC_NewFolderThread::start_new_folder");
148 // c-file-style: "linux"