Subversion Repositories public

Rev

Rev 88 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
88 andreas 1
/***************************************************************************
232 andreas 2
 *   Copyright (C) 2007 - 2009 by Andreas Theofilu                         *
3
 *   andreas@theosys.at                                                    *
88 andreas 4
 *                                                                         *
5
 *   This program is free software; you can redistribute it and/or modify  *
6
 *   it under the terms of the GNU General Public License as published by  *
7
 *   the Free Software Foundation version 3 of the License.                *
8
 *                                                                         *
9
 *   This program is distributed in the hope that it will be useful,       *
10
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
11
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
12
 *   GNU General Public License for more details.                          *
13
 *                                                                         *
14
 *   You should have received a copy of the GNU General Public License     *
15
 *   along with this program; if not, write to the                         *
16
 *   Free Software Foundation, Inc.,                                       *
17
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
18
 ***************************************************************************/
19
 
20
#include "managefile.h"
21
 
22
#include <kmessagebox.h>
23
 
24
#include <sys/types.h>
25
#include <sys/stat.h>
26
#include <fcntl.h>
27
#include <unistd.h>
28
#include <string.h>
29
#include <errno.h>
30
 
31
manageFile::manageFile ()
32
{
33
	fname = 0;
34
}
35
 
36
manageFile::manageFile(const char *name)
37
{
38
	fname = name;
39
	setFileName(name);
40
}
41
 
42
manageFile::~manageFile()
43
{
44
	destroy();
45
}
46
 
47
void manageFile::destroy()
48
{
49
	if (spw.handle() != -1)
50
	   spw.close();
51
 
52
	fname = 0;
53
}
54
 
55
int manageFile::setFileName(const char *name)
56
{
57
	if (name)
58
	{
59
	   if (spw.handle() != -1)
60
	      spw.close();
61
 
62
	   fname = name;
232 andreas 63
	   spw.setFileName(QString(name));
88 andreas 64
 
232 andreas 65
	   if (spw.open(QIODevice::ReadOnly) == false)
88 andreas 66
	      return -1;
67
 
68
	   return spw.handle();
69
	}
70
 
71
	return -1;
72
}
73
 
74
garmin_data *manageFile::readFile()
75
{
76
	return garmin_load (fname);
77
}