*** empty log message ***

git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@1059 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
Lee Salzman
2007-06-01 15:48:55 +00:00
parent e166318c5e
commit 20252c19fd
15 changed files with 90 additions and 50 deletions
+39 -5
View File
@@ -9,8 +9,25 @@
char *path(char *s)
{
for(char *t = s; (t = strpbrk(t, "/\\")); *t++ = PATHDIV);
for(char *prevdir = NULL, *curdir = s;;)
{
prevdir = curdir[0]==PATHDIV ? curdir+1 : curdir;
curdir = strchr(prevdir, PATHDIV);
if(!curdir) break;
if(prevdir+1==curdir && prevdir[0]=='.')
{
memmove(prevdir, curdir+1, strlen(curdir+1)+1);
curdir = prevdir;
}
else if(curdir[1]=='.' && curdir[2]=='.' && curdir[3]==PATHDIV)
{
if(prevdir+2==curdir && prevdir[0]=='.' && prevdir[1]=='.') continue;
memmove(prevdir, curdir+4, strlen(curdir+4)+1);
curdir = prevdir;
}
}
return s;
};
}
char *parentdir(char *directory)
{
@@ -20,7 +37,7 @@ char *parentdir(char *directory)
char *parent = new char[len];
s_strncpy(parent, directory, len);
return parent;
};
}
char *loadfile(char *fn, int *size)
{
@@ -39,10 +56,27 @@ char *loadfile(char *fn, int *size)
{
delete[] buf;
return NULL;
};
}
if(size!=NULL) *size = len;
return buf;
};
}
bool cmpb(void *b, int n, enet_uint32 c)
{
ENetBuffer buf;
buf.data = b;
buf.dataLength = n;
return enet_crc32(&buf, 1)==c;
}
bool cmpf(char *fn, enet_uint32 c)
{
int n = 0;
char *b = loadfile(fn, &n);
bool r = cmpb(b, n, c);
delete[] b;
return r;
}
void endianswap(void *memory, int stride, int length) // little endian as storage format
{
@@ -53,6 +87,6 @@ void endianswap(void *memory, int stride, int length) // little endian as stor
uchar t = p[i];
p[i] = p[stride-i-1];
p[stride-i-1] = t;
};
}
#endif
}