merged branch
git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@7382 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
@@ -74,6 +74,12 @@ char *path(char *s)
|
||||
return s;
|
||||
}
|
||||
|
||||
char *unixpath(char *s)
|
||||
{
|
||||
for(char *t = s; (t = strchr(t, '\\')); *t++ = '/');
|
||||
return s;
|
||||
}
|
||||
|
||||
char *path(const char *s, bool copy)
|
||||
{
|
||||
static string tmp;
|
||||
@@ -304,6 +310,38 @@ 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(!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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user