[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Enigma-cvs] enigma/src/px system.hh, NONE, 1.1 system_unix.cc, NONE, 1
From: |
Ralf Westram <address@hidden> |
Subject: |
[Enigma-cvs] enigma/src/px system.hh, NONE, 1.1 system_unix.cc, NONE, 1.1 |
Date: |
Mon, 27 Oct 2003 11:45:50 +0000 |
Update of /cvsroot/enigma/enigma/src/px
In directory subversions:/tmp/cvs-serv11829/src/px
Added Files:
system.hh system_unix.cc
Log Message:
- moved to px
--- NEW FILE: system.hh ---
/*
* Copyright (C) 2002,2003 Daniel Heck
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* $Id: system.hh,v 1.1 2003/10/27 11:45:48 reallysoft Exp $
*/
#ifndef SYSTEM_HH
#define SYSTEM_HH
#include <string>
#include <ctime>
namespace px
{
namespace sysdep
{
extern const char *path_separator;
std::string expand_path(const std::string &path);
bool FileExists(const std::string &fname);
std::time_t FileModTime(const std::string &fname);
bool FolderExists(const std::string &fname);
bool FolderCreate(const std::string &fname);
}
}
#endif
--- NEW FILE: system_unix.cc ---
/*
* Copyright (C) 2002,2003 Daniel Heck
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* $Id: system_unix.cc,v 1.1 2003/10/27 11:45:48 reallysoft Exp $
*/
#include "system.hh"
#include "tools.hh"
#include <cstdlib>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
using namespace std;
const char *px::sysdep::path_separator = "/";
string
px::sysdep::expand_path(const string &pth)
{
string path = pth;
string::size_type p=path.find("~");
if (p != string::npos) {
string home;
if (char *h = getenv("HOME"))
home = h;
path.replace(p, 1, home);
}
return path;
}
bool
px::sysdep::FileExists(const std::string &fname)
{
struct stat s;
return (stat(fname.c_str(), &s)==0 && S_ISREG(s.st_mode));
}
time_t
px::sysdep::FileModTime(const std::string &fname)
{
struct stat s;
if (stat(fname.c_str(), &s) == 0) {
return s.st_mtime;
}
return 0; // beginning of time
}
bool
px::sysdep::FolderExists(const std::string &fname)
{
struct stat s;
return (stat(fname.c_str(), &s)==0 && S_ISDIR(s.st_mode));
}
bool
px::sysdep::FolderCreate(const std::string &fname)
{
fprintf(stderr, "FolderCreate('%s')\n", fname.c_str());
string parent_folder;
string sub_folder;
bool ok = true;
assert(!FolderExists(fname));
if (split_path(fname, &parent_folder, &sub_folder)) {
if (!FolderExists(parent_folder)) {
ok = FolderCreate(parent_folder);
}
}
if (ok) {
ok = mkdir(fname.c_str(), 0777) == 0;
}
return ok;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Enigma-cvs] enigma/src/px system.hh, NONE, 1.1 system_unix.cc, NONE, 1.1,
Ralf Westram <address@hidden> <=
- Prev by Date:
[Enigma-cvs] enigma/src floors.cc, 1.5, 1.6 items.cc, 1.91, 1.92 stones_complex.cc, 1.50, 1.51 stones_simple.cc, 1.58, 1.59
- Next by Date:
[Enigma-cvs] enigma/src gui.cc,1.19,1.20
- Previous by thread:
[Enigma-cvs] enigma/src floors.cc, 1.5, 1.6 items.cc, 1.91, 1.92 stones_complex.cc, 1.50, 1.51 stones_simple.cc, 1.58, 1.59
- Next by thread:
[Enigma-cvs] enigma/src gui.cc,1.19,1.20
- Index(es):