// $Id: system.cxx,v 1.6 2002/09/15 00:19:19 grumbel Exp $
//
// Pingus - A free Lemmings clone
// Copyright (C) 1999 Ingo Ruhnke
//
// 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.
#include
#include
#include
#include
#include
#include "globals.hxx"
#include "string_converter.hxx"
#include "system.hxx"
/* Headers needed for i18n / gettext */
#include
#include
#include "my_gettext.hxx"
System::Directory
System::opendir(const std::string& pathname, const std::string& pattern)
{
std::list dir_list;
WIN32_FIND_DATA coFindData;
std::string FindFileDir = pathname + "\\" + pattern;
std::string FileLocation;
HANDLE hFind = FindFirstFile(TEXT(FindFileDir.c_str()),&coFindData);
if (hFind == INVALID_HANDLE_VALUE)
{
std::cout << _("System: Couldn't open: ") << pathname << std::endl;
}
do
{
dir_list.push_back(DirectoryEntry(coFindData.cFileName));
}
while (FindNextFile(hFind,&coFindData));
FindClose(hFind);
return dir_list;
}
bool
System::exist(std::string filename)
{
//don't know a better solution
std::ifstream check(filename.c_str());
if(!check) return false;
return true;
}
void
System::create_dir(std::string directory)
{
CreateDirectory(directory.c_str(), 0);
}
/** Change into the directory named dir, on error throw an PingusError */
void
System::change_dir (std::string dir)
{
_chdir (dir.c_str ());
}
std::string
System::get_statdir()
{
return "stat\\";
}
std::string
System::get_vardir()
{
return "var\\";
}
std::string
System::get_tmpdir()
{
// FIXME: Warning: these hardcoded values are most probably wrong!
return "c:\\windows\\temp\\";
}
/* EOF */