mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-02-08 17:22:18 +00:00
Made filesearch aware of symbolic links
(cherry picked from commit cbcbda1586d5a19cf17aabedb49bca3e5328fa4f)
This commit is contained in:
parent
dc02339cc9
commit
aa952051fd
1 changed files with 19 additions and 0 deletions
|
@ -23,6 +23,11 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#ifndef IGNORE_SYMLINKS
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <libgen.h>
|
||||||
|
#include <limits.h>
|
||||||
|
#endif
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "filesrch.h"
|
#include "filesrch.h"
|
||||||
|
@ -417,6 +422,9 @@ filestatus_t filesearch(char *filename, const char *startpath, const UINT8 *want
|
||||||
}
|
}
|
||||||
else if (!strcasecmp(searchname, dent->d_name))
|
else if (!strcasecmp(searchname, dent->d_name))
|
||||||
{
|
{
|
||||||
|
#ifndef IGNORE_SYMLINKS
|
||||||
|
struct stat statbuf;
|
||||||
|
#endif
|
||||||
switch (checkfilemd5(searchpath, wantedmd5sum))
|
switch (checkfilemd5(searchpath, wantedmd5sum))
|
||||||
{
|
{
|
||||||
case FS_FOUND:
|
case FS_FOUND:
|
||||||
|
@ -424,6 +432,17 @@ filestatus_t filesearch(char *filename, const char *startpath, const UINT8 *want
|
||||||
strcpy(filename,searchpath);
|
strcpy(filename,searchpath);
|
||||||
else
|
else
|
||||||
strcpy(filename,dent->d_name);
|
strcpy(filename,dent->d_name);
|
||||||
|
#ifndef IGNORE_SYMLINKS
|
||||||
|
if (lstat(filename, &statbuf) != -1) {
|
||||||
|
if (S_ISLNK(statbuf.st_mode)) {
|
||||||
|
char *tempbuf = realpath(filename, NULL);
|
||||||
|
if (!tempbuf)
|
||||||
|
I_Error("Error parsing link %s: %s", filename, strerror(errno));
|
||||||
|
strncpy(filename, tempbuf, MAX_WADPATH);
|
||||||
|
free(tempbuf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
retval = FS_FOUND;
|
retval = FS_FOUND;
|
||||||
found = 1;
|
found = 1;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue