--- deliantra/server/common/porting.C 2007/05/28 21:21:40 1.17
+++ deliantra/server/common/porting.C 2008/09/29 08:52:35 1.21
@@ -1,25 +1,24 @@
/*
- * This file is part of Crossfire TRT, the Multiplayer Online Role Playing Game.
+ * This file is part of Deliantra, the Roguelike Realtime MMORPG.
*
- * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team
+ * 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
*
- * Crossfire TRT 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.
+ * 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.
+ * 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 Crossfire TRT; if not, write to the Free Software Foundation, Inc. 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ * 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
+ * The authors can be reached via e-mail to
*/
/* This file contains various functions that are not really unique for
@@ -50,52 +49,6 @@
/* Has to be after above includes so we don't redefine some values */
#include "global.h"
-/* 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)
@@ -125,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.
@@ -168,32 +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;
-
- assign (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 = '/';
- }
-}