removed now redundant code

and substituted "copy file and delete original" with "move file"
This commit is contained in:
ac-stef
2014-05-19 18:48:54 +02:00
parent 2768012579
commit d81c884cea
4 changed files with 1 additions and 37 deletions
+1 -2
View File
@@ -1012,9 +1012,8 @@ int processdownload(package *pck)
case PCK_TEXTURE: case PCK_AUDIO:
{
const char *pckname = findfile(path(pck->name, true), "w+");
preparedir(pckname);
// with textures/sounds, the image/audio file itself is sent. Just need to copy it from the temporary file
if(!copyfile(tmpname, pckname)) conoutf(_("\f3failed to install"), pckname);
if(rename(tmpname, pckname)) conoutf(_("\f3failed to install"), pckname);
break;
}
-32
View File
@@ -306,38 +306,6 @@ bool delfile(const char *path)
return !remove(path);
}
bool copyfile(const char *source, const char *destination)
{
FILE *from = fopen(source, "rb");
FILE *dest = fopen(destination, "wb");
if(!from || !dest) return false;
size_t len;
uchar buf[1024];
while((len = fread(&buf, sizeof(uchar), 1024, from)))
{
fwrite(&buf, sizeof(uchar), len, dest);
}
fclose(from);
fclose(dest);
return true;
}
bool preparedir(const char *destination)
{
string dir;
copystring(dir, parentdir(destination));
vector<char *> dirs;
while(*dir && !fileexists(dir, "r"))
{
dirs.add(newstring(dir));
copystring(dir, parentdir(dir));
}
loopvrev(dirs) if(!createdir(dirs[i])) return false;
return true;
}
#ifndef STANDALONE
static int rwopsseek(SDL_RWops *rw, int offset, int whence)
{
-2
View File
@@ -949,8 +949,6 @@ extern bool listdir(const char *dir, const char *ext, vector<char *> &files);
extern int listfiles(const char *dir, const char *ext, vector<char *> &files);
extern int listzipfiles(const char *dir, const char *ext, vector<char *> &files);
extern bool delfile(const char *path);
extern bool copyfile(const char *source, const char *destination);
extern bool preparedir(const char *destination);
extern bool addzip(const char *name, const char *mount = NULL, const char *strip = NULL, bool extract = false, int type = -1);
extern bool removezip(const char *name);
extern struct mapstats *loadmapstats(const char *filename, bool getlayout);
-1
View File
@@ -552,7 +552,6 @@ bool extractzipfile(ziparchive *a, zipfile *f, const char *name)
zipstream *s = new zipstream;
FILE *target = NULL;
defformatstring(fname)("%s", findfile(name, "wb"));
preparedir(fname);
bool error = false;
if(s->open(a, f) && (target = fopen(fname, "wb")))
{