Sicherstellen, dass keien hardlinks automatisch übermeiert werden (unlink).

Schnelleres Backup ohne system() mit Hardlinks.
This commit is contained in:
Enno Rehling 2005-12-18 21:53:12 +00:00
parent a18ca097b9
commit 945a60a20c
4 changed files with 38 additions and 32 deletions

View File

@ -718,7 +718,7 @@ typus2race(unsigned char typus)
void
create_backup(char *file)
{
#if defined(HAVE_ACCESS)
#ifdef HAVE_UNISTD_H
char bfile[MAX_PATH];
char command[MAX_PATH*2+10];
int c = 1;
@ -726,8 +726,7 @@ create_backup(char *file)
sprintf(bfile, "%s.backup%d", file, c);
c++;
} while(access(bfile, R_OK) == 0);
sprintf(command, "cp %s %s", file, bfile);
system(command);
link(file, bfile);
#endif
}
@ -2017,6 +2016,12 @@ writegame(const char *filename, char quiet)
#endif
sprintf(buf, "%s/%s", datapath(), filename);
#ifdef HAVE_UNISTD_H
if (access(buf, R_OK) == 0) {
/* make sure we don't overwrite some hardlinkedfile */
unlink(buf);
}
#endif
F = cfopen(buf, "w");
if (F==NULL)
return -1;

View File

@ -161,13 +161,13 @@ cinfo_calm(const struct locale * lang, const void * obj, typ_t typ, struct curse
assert(typ == TYP_UNIT);
u = (unit *)obj;
if (c->magician){
if (c->magician && c->magician->faction) {
rc = c->magician->irace;
f = c->magician->faction;
if (self != 0) {
if (f!=NULL && self != 0) {
sprintf(buf, "%s mag %s", u->name, factionname(f));
} else {
sprintf(buf, "%s scheint %s zu mögen", u->name, LOC(f->locale, rc_name(rc, 1)));
sprintf(buf, "%s scheint %s zu mögen", u->name, LOC(lang, rc_name(rc, 1)));
}
scat(". (");
scat(itoa36(c->no));

View File

@ -94,6 +94,7 @@ extern "C" {
#if defined(__USE_SVID) || defined(_BSD_SOURCE) || defined(__USE_XOPEN_EXTENDED) || defined(_BE_SETUP_H) || defined(CYGWIN)
# include <unistd.h>
# define HAVE_UNISTD_H
# define HAVE_STRCASECMP
# define HAVE_STRNCASECMP
# define HAVE_ACCESS

View File

@ -8,7 +8,7 @@ end
function change_locales()
-- local localechange = { }
local localechange = { de = { "2xwr" } }
local localechange = { de = { "bLub" } }
for loc, flist in localechange do
for index, name in flist do