aboutsummaryrefslogtreecommitdiff
path: root/src/fluxbox.cc
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2003-08-12 21:00:54 (GMT)
committerfluxgen <fluxgen>2003-08-12 21:00:54 (GMT)
commit72b654992d5c38b4bc5d19cfe0e580b2bdbc5eca (patch)
tree84290c23b017c0483167ea1b6e20c6ab9b3a9936 /src/fluxbox.cc
parent1f4944abb4c3c1076391412f61c1bb9579e73a12 (diff)
downloadfluxbox_pavel-72b654992d5c38b4bc5d19cfe0e580b2bdbc5eca.zip
fluxbox_pavel-72b654992d5c38b4bc5d19cfe0e580b2bdbc5eca.tar.bz2
minor cleaning
Diffstat (limited to 'src/fluxbox.cc')
-rw-r--r--src/fluxbox.cc76
1 files changed, 25 insertions, 51 deletions
diff --git a/src/fluxbox.cc b/src/fluxbox.cc
index b6a0019..182e330 100644
--- a/src/fluxbox.cc
+++ b/src/fluxbox.cc
@@ -22,7 +22,7 @@
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23// DEALINGS IN THE SOFTWARE. 23// DEALINGS IN THE SOFTWARE.
24 24
25// $Id: fluxbox.cc,v 1.183 2003/08/12 01:04:16 fluxgen Exp $ 25// $Id: fluxbox.cc,v 1.184 2003/08/12 21:00:54 fluxgen Exp $
26 26
27#include "fluxbox.hh" 27#include "fluxbox.hh"
28 28
@@ -357,7 +357,21 @@ getString() {
357} 357}
358 358
359static Window last_bad_window = None; 359static Window last_bad_window = None;
360namespace {
361void copyFile(const std::string &from, const std::string &to) {
362 ifstream from_file(from.c_str());
363 ofstream to_file(to.c_str());
364
365 if (! to_file.good()) {
366 cerr<<"Can't write file: "<<to<<endl;
367 } else if (from_file.good()) {
368 to_file<<from_file.rdbuf(); //copy file
369 } else {
370 cerr<<"Can't copy from "<<from<<" to "<<to<<endl;
371 }
372}
360 373
374};
361 375
362static int handleXErrors(Display *d, XErrorEvent *e) { 376static int handleXErrors(Display *d, XErrorEvent *e) {
363#ifdef DEBUG 377#ifdef DEBUG
@@ -651,7 +665,7 @@ void Fluxbox::setupConfigFiles() {
651 665
652 bool create_init = false, create_keys = false, create_menu = false; 666 bool create_init = false, create_keys = false, create_menu = false;
653 667
654 string dirname = getenv("HOME")+string("/.")+string(m_RC_PATH) + "/"; 668 string dirname = getenv("HOME") + string("/.") + string(m_RC_PATH) + "/";
655 string init_file, keys_file, menu_file, slitlist_file; 669 string init_file, keys_file, menu_file, slitlist_file;
656 init_file = dirname + m_RC_INIT_FILE; 670 init_file = dirname + m_RC_INIT_FILE;
657 keys_file = dirname + "keys"; 671 keys_file = dirname + "keys";
@@ -686,58 +700,18 @@ void Fluxbox::setupConfigFiles() {
686 } 700 }
687 701
688 702
689 // should we copy key configuraion? 703 // copy key configuration
690 if (create_keys) { 704 if (create_keys)
691 ifstream from(DEFAULTKEYSFILE); 705 copyFile(DEFAULTKEYSFILE, keys_file);
692 ofstream to(keys_file.c_str());
693 706
694 if (! to.good()) { 707 // copy menu configuration
695 cerr << "Can't write file" << endl; 708 if (create_menu)
696 } else if (from.good()) { 709 copyFile(DEFAULTMENU, menu_file);
697#ifdef DEBUG
698 cerr << "Copying file: " << DEFAULTKEYSFILE << endl;
699#endif // DEBUG
700 to<<from.rdbuf(); //copy file
701
702 } else {
703 cerr<<"Can't copy default keys file."<<endl;
704 }
705 }
706 710
707 // should we copy menu configuraion? 711 // copy init file
708 if (create_menu) { 712 if (create_init)
709 ifstream from(DEFAULTMENU); 713 copyFile(DEFAULT_INITFILE, init_file);
710 ofstream to(menu_file.c_str());
711 714
712 if (! to.good()) {
713 cerr << "Can't open " << menu_file.c_str() << "for writing" << endl;
714 } else if (from.good()) {
715#ifdef DEBUG
716 cerr << "Copying file: " << DEFAULTMENU << endl;
717#endif // DEBUG
718 to<<from.rdbuf(); //copy file
719
720 } else {
721 cerr<<"Can't copy default menu file."<<endl;
722 }
723 }
724
725 // should we copy default init file?
726 if (create_init) {
727 ifstream from(DEFAULT_INITFILE);
728 ofstream to(init_file.c_str());
729
730 if (! to.good()) {
731 cerr << "Can't open " << init_file.c_str() << "for writing" << endl;
732 } else if (from.good()) {
733#ifdef DEBUG
734 cerr << "Copying file: " << DEFAULT_INITFILE << endl;
735#endif // DEBUG
736 to<<from.rdbuf(); //copy file
737 } else {
738 cerr<<"Can't copy default init file."<<endl;
739 }
740 }
741} 715}
742 716
743void Fluxbox::handleEvent(XEvent * const e) { 717void Fluxbox::handleEvent(XEvent * const e) {