Exemplo n.º 1
0
static int boxflist(flist_t **fl,char *path)
{
	DIR *d;
	struct dirent *de;
	struct stat sb;
	char mn[MAX_PATH],*p;
	int len;
	DEBUG(('S',2,"Add filebox '%s'",path));
	if(!(d=opendir(path)))return 0;
	    else {
		while((de=readdir(d))) {
			len=strlen(path)+2+strlen(de->d_name);
			p=xmalloc(len);
			snprintf(p,len,"%s/%s",path,de->d_name);
			if(!stat(p,&sb)&&(S_ISREG(sb.st_mode)||S_ISLNK(sb.st_mode))) {
				xstrcpy(mn,de->d_name,MAX_PATH);
				mapname(mn,cfgs(CFG_MAPOUT),MAX_PATH);
				addflist(fl,p,xstrdup(mn),'^',0,NULL,0);
				totalf+=sb.st_size;totaln++;
			} else xfree(p);
		}
		closedir(d);
	}
	return 1;
}
Exemplo n.º 2
0
void G_ReadSnapshots(FResourceFile *resf)
{
	FString MapName;
	level_info_t *i;

	G_ClearSnapshots();

	for (unsigned j = 0; j < resf->LumpCount(); j++)
	{
		FResourceLump * resl = resf->GetLump(j);
		if (resl != nullptr)
		{
			auto ptr = strstr(resl->FullName, ".map.json");
			if (ptr != nullptr)
			{
				ptrdiff_t maplen = ptr - resl->FullName.GetChars();
				FString mapname(resl->FullName.GetChars(), (size_t)maplen);
				i = FindLevelInfo(mapname);
				if (i != nullptr)
				{
					i->Snapshot = resl->GetRawData();
				}
			}
			else
			{
				auto ptr = strstr(resl->FullName, ".mapd.json");
				if (ptr != nullptr)
				{
					ptrdiff_t maplen = ptr - resl->FullName.GetChars();
					FString mapname(resl->FullName.GetChars(), (size_t)maplen);
					TheDefaultLevelInfo.Snapshot = resl->GetRawData();
				}
			}
		}
	}
}