Debian Codegraph @

HercUtilities/SystemUtils.cpp

raw symbols SCIP
1 /*
2 * File: SystemUtils.h
3 *
4 * Author: Jacob Dekel
5 * Created on: Aug 24, 2009
6 *
7 * Copyright (c) 2009-2013 Jacob Dekel
8 * $Id:
9 *
10 * This program is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 *
23 */
24
25
26 #include "SystemUtils.h"
27 #include "HerculesStudio.h"
28
29 #include <QFile>
30
31 #include <sstream>
32 #include <sys/types.h>
33 #include <sys/stat.h>
34 #ifndef hFramework
35 #include <unistd.h>
36 #endif
37
38 SystemUtils::SystemUtils()
39 {
40 }
41
42 SystemUtils::~SystemUtils()
43 {
44 }
45
46 bool SystemUtils::processIsRunning(int pid)
47 {
48 if (pid <= 1) return false;
49 std::stringstream procPath;// TODO: merge with Watchdog (same function!)
50 procPath << "/proc/" << pid;
51 return (fileExists(procPath.str()));
52 }
53
54 bool SystemUtils::fileExists(const std::string & fileName)
55 {
56 static struct stat dstat;
57 return (stat(fileName.c_str(), &dstat) == 0);
58 }
59
60 bool SystemUtils::fileExists(const QString & fileName)
61 {
62 return (QFile::exists(fileName));
63 }