--- deliantra/server/common/porting.C 2007/01/15 01:25:41 1.12 +++ deliantra/server/common/porting.C 2008/09/29 08:52:35 1.21 @@ -1,26 +1,25 @@ /* - CrossFire, A Multiplayer game for X-windows - - Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team - Copyright (C) 2002 Mark Wedel & Crossfire Development Team - Copyright (C) 1992 Frank Tore Johansen - - 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., 675 Mass Ave, Cambridge, MA 02139, USA. - - The authors can be reached via e-mail at -*/ + * This file is part of Deliantra, the Roguelike Realtime MMORPG. + * + * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team + * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team + * Copyright (©) 1992,2007 Frank Tore Johansen + * + * Deliantra 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 3 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, see . + * + * The authors can be reached via e-mail to + */ /* This file contains various functions that are not really unique for * crossfire, but rather provides what should be standard functions @@ -50,54 +49,6 @@ /* Has to be after above includes so we don't redefine some values */ #include "global.h" -static unsigned int curtmp = 0; - -/* This function removes everything in the directory. */ -void -remove_directory (const char *path) -{ - DIR *dirp; - char buf[MAX_BUF]; - struct stat statbuf; - int status; - - if ((dirp = opendir (path)) != NULL) - { - struct dirent *de; - - for (de = readdir (dirp); de; de = readdir (dirp)) - { - /* Don't remove '.' or '..' In theory we should do a better - * check for .., but the directories we are removing are fairly - * limited and should not have dot files in them. - */ - if (de->d_name[0] == '.') - continue; - - /* Linux actually has a type field in the dirent structure, - * but that is not portable - stat should be portable - */ - status = stat (de->d_name, &statbuf); - if ((status != -1) && (S_ISDIR (statbuf.st_mode))) - { - sprintf (buf, "%s/%s", path, de->d_name); - remove_directory (buf); - continue; - } - sprintf (buf, "%s/%s", path, de->d_name); - if (unlink (buf)) - { - LOG (llevError, "Unable to remove directory %s\n", path); - } - } - closedir (dirp); - } - if (rmdir (path)) - { - LOG (llevError, "Unable to remove directory %s\n", path); - } -} - #define DIGIT(x) (isdigit(x) ? (x) - '0' : \ islower (x) ? (x) + 10 - 'a' : (x) + 10 - 'A') #define MBASE ('z' - 'a' + 1 + 10) @@ -127,28 +78,6 @@ return (char *) s; } -/* - * returns a char-pointer to a static array, in which a representation - * of the decimal number given will be stored. - */ -char * -ltostr10 (signed long n) -{ - static char buf[12]; /* maximum size is n=-2 billion, i.e. 11 characters+1 - character for the trailing nul character */ - snprintf (buf, sizeof (buf), "%ld", n); - return buf; -} - -char * -doubletostr10 (double v) -{ - static char tbuf[200]; - - sprintf (tbuf, "%f", v); - return tbuf; -} - /** * open_and_uncompress() first searches for the original filename. If it exist, * then it opens it and returns the file-pointer. @@ -170,31 +99,3 @@ fclose (fp); } -/* - * If any directories in the given path doesn't exist, they are created. - */ - -void -make_path_to_file (char *filename) -{ - char buf[MAX_BUF], *cp = buf; - struct stat statbuf; - - if (!filename || !*filename) - return; - strcpy (buf, filename); - - while ((cp = strchr (cp + 1, (int) '/'))) - { - *cp = '\0'; - if (stat (buf, &statbuf) || !S_ISDIR (statbuf.st_mode)) - { - if (mkdir (buf, SAVE_DIR_MODE)) - { - LOG (llevError, "Cannot mkdir %s: %s\n", buf, strerror (errno)); - return; - } - } - *cp = '/'; - } -}