summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBastian Wissler2009-02-22 17:09:25 +0100
committerBastian Wissler2009-02-22 17:09:25 +0100
commitbf56dc3b8001b6849111dc6f8606e952d7eb9258 (patch)
tree12fc82b6fa953e00c851629ac884019ae76e3350
parent * typo (diff)
downloadvmchooser-bf56dc3b8001b6849111dc6f8606e952d7eb9258.tar.gz
vmchooser-bf56dc3b8001b6849111dc6f8606e952d7eb9258.tar.xz
vmchooser-bf56dc3b8001b6849111dc6f8606e952d7eb9258.zip
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
-rw-r--r--vmchooser/Makefile2
-rw-r--r--vmchooser/userSession.cxx21
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 <string>
#include <iostream>
#include <fstream>
+#include<boost/filesystem/operations.hpp>
+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;
}