From: Matze B. <mat...@us...> - 2003-03-04 13:30:22
|
Update of /cvsroot/planeshift/planeshift/src/updater/httpclient In directory sc8-pr-cvs1:/tmp/cvs-serv32432 Added Files: fileutil.cpp Removed Files: system.cpp Log Message: added GPL header to updater files --- NEW FILE: fileutil.cpp --- /* * fileutil.cpp by Matthias Braun <ma...@br...> * * Copyright (C) 2002 PlaneShift Team (in...@pl..., * http://www.planeshift.it) * * 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 (version 2 of the License) * 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. * */ // All OS specific stuff should be in this file #include <config.h> #include <dirent.h> #include <sys/stat.h> #include <csutil/util.h> #include "error.h" #include "path.h" #include "fileutil.h" namespace updater { FileStat* StatFile (const char* path) { struct stat filestats; if (stat (path, &filestats) < 0) return NULL; FileStat* filestat = new FileStat; if (S_ISDIR (filestats.st_mode)) filestat->type = FileStat::TYPE_DIRECTORY; else filestat->type = FileStat::TYPE_FILE; // XXX: Need support for symbolic links and executable filestat->link = false; filestat->executable = false; filestat->timestamp.Set (filestats.st_mtime); filestat->size = (uint32_t) filestats.st_size; return filestat; } void RemoveFile (const char* filename) throw(Error) { int rc = remove(filename); if (rc < 0) throw Error("Removal of '%s' failed.", filename); } #ifdef OS_UNIX #include <sys/stat.h> char* ConvertToSystemPath (const char* path) { return csStrNew (path); } void MakeDirectory (const char* directory) throw(Error) { if (mkdir (directory, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) < 0) throw Error("Couldn't create directory '%s'.", directory); } #endif #ifdef OS_WIN32 #include <direct.h> char* ConvertToSystemPath (const char* path) { char* newpath = csStrNew(path); for (char*p = newpath; *p != 0; p++) { if (*p == '/') *p = '\\'; } return newpath; } void MakeDirectory (const char* directory) throw(Error) { char* path = ConvertToSystemPath (directory); int rc = mkdir(path); delete[] path; if (rc < 0) throw Error("Couldn't create directory '%s'.", directory); } #endif } // end of namespace updater --- system.cpp DELETED --- |