From bf56dc3b8001b6849111dc6f8606e952d7eb9258 Mon Sep 17 00:00:00 2001 From: Bastian Wissler Date: Sun, 22 Feb 2009 16:09:25 +0000 Subject: vmchooser source: * Added source support for .openslx-folder -> uses boost filesystem libs git-svn-id: http://svn.openslx.org/svn/openslx/openslx-src-tools/vmchooser/trunk@2629 95ad53e4-c205-0410-b2fa-d234c58c8868 --- vmchooser/Makefile | 2 +- vmchooser/userSession.cxx | 21 ++++++++++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/vmchooser/Makefile b/vmchooser/Makefile index 5c73108..e0c4107 100644 --- a/vmchooser/Makefile +++ b/vmchooser/Makefile @@ -8,7 +8,7 @@ CC = g++ DEBUG_CCFLAGS = -O0 -Wall -I/usr/include -I../fltk-2/include/ -I. `xml2-config --cflags` -ggdb #-ggdb #-Werror CCFLAGS = -O2 -Wall -I/usr/include -I../fltk-2/include/ -I. `xml2-config --cflags` LDFLAGS = -L../fltk-2/lib/ -L/usr/lib -LIBS = -lpng ../fltk-2/lib/libfltk2_images.a -ljpeg -lz -lXi -lXinerama -lpthread -lm -lXext -lsupc++ -lXrender -lfontconfig -lxml2 -lXft -lXdmcp -lXau -ldl -lz -lfreetype -lX11 ../fltk-2/lib/libfltk2.a /usr/lib/libboost_regex-s.a +LIBS = -lpng ../fltk-2/lib/libfltk2_images.a -ljpeg -lz -lXi -lXinerama -lpthread -lm -lXext -lsupc++ -lXrender -lfontconfig -lxml2 -lXft -lXdmcp -lXau -ldl -lz -lfreetype -lX11 ../fltk-2/lib/libfltk2.a /usr/lib/libboost_regex-s.a /usr/lib/libboost_filesystem-s.a .PHONY: all clean distclean all:: ${TARGET} diff --git a/vmchooser/userSession.cxx b/vmchooser/userSession.cxx index 9f0edaa..e390f95 100644 --- a/vmchooser/userSession.cxx +++ b/vmchooser/userSession.cxx @@ -9,7 +9,9 @@ #include #include #include +#include +namespace bfs=boost::filesystem; using namespace std; /** @@ -30,7 +32,13 @@ void saveSession(DataEntry* dat) { // build path string fname = home; - fname.append("/.vmchooser"); + string shome = home; + fname.append("/.openslx/vmchooser"); + if(!bfs::exists(fname) ) { + if(!bfs::exists(shome.append("/.openslx")) ) { + bfs::create_directory(shome); + } + } // write file with ofstream ofstream fout(fname.c_str(),ios::trunc); // overwrite file @@ -55,23 +63,30 @@ char* readSession() { // build file name string fname = home; - fname.append("/.vmchooser"); + fname.append("/.openslx/vmchooser"); // read presaved session with ifstream + if(!bfs::exists(fname)) { + return NULL; + } ifstream fin(fname.c_str()); if (!fin) { - cout << ".vmchooser file not found .. continue with global default" << endl; + cout << "some error occured reading file!" << endl; return NULL; } + string sessname; getline(fin,sessname); char* blub = (char*) malloc(sessname.size()); strncpy(blub,sessname.c_str(),sessname.size()+1); if(!sessname.empty()) { + // blub has to be freed ;-) + // but this is not very important here return blub; } else { + free(blub); return NULL; } -- cgit v1.2.3-55-g7522