Ejemplo n.º 1
0
void listdirectory(stringlist_t *list, const char *basepath, const char *path)
{
	char fullpath[MAX_OSPATH];
	DIR *dir;
	struct dirent *ent;
	dpsnprintf(fullpath, sizeof(fullpath), "%s%s", basepath, path);
#ifdef __ANDROID__
	// SDL currently does not support listing assets, so we have to emulate
	// it. We're using relative paths for assets, so that will do.
	if (basepath[0] != '/')
	{
		char listpath[MAX_OSPATH];
		qfile_t *listfile;
		dpsnprintf(listpath, sizeof(listpath), "%sls.txt", fullpath);
		char *buf = (char *) FS_SysLoadFile(listpath, tempmempool, true, NULL);
		if (!buf)
			return;
		char *p = buf;
		for (;;)
		{
			char *q = strchr(p, '\n');
			if (q == NULL)
				break;
			*q = 0;
			adddirentry(list, path, p);
			p = q + 1;
		}
		Mem_Free(buf);
		return;
	}
#endif
	dir = opendir(fullpath);
	if (!dir)
		return;

	while ((ent = readdir(dir)))
		adddirentry(list, path, ent->d_name);
	closedir(dir);
}
Ejemplo n.º 2
0
void listdirectory(stringlist_t *list, const char *basepath, const char *path)
{
    char fullpath[MAX_OSPATH];
    DIR *dir;
    struct dirent *ent;
    dpsnprintf(fullpath, sizeof(fullpath), "%s%s", basepath, *path ? path : "./");
    dir = opendir(fullpath);
    if (!dir)
        return;
    while ((ent = readdir(dir)))
        adddirentry(list, path, ent->d_name);
    closedir(dir);
}
Ejemplo n.º 3
0
void listdirectory(stringlist_t *list, const char *basepath, const char *path)
{
	char pattern[4096];
	WIN32_FIND_DATA n_file;
	HANDLE hFile;
	strlcpy (pattern, basepath, sizeof(pattern));
	strlcat (pattern, path, sizeof (pattern));
	strlcat (pattern, "*", sizeof (pattern));
	// ask for the directory listing handle
	hFile = FindFirstFile(pattern, &n_file);
	if(hFile == INVALID_HANDLE_VALUE)
		return;
	do {
		adddirentry(list, path, n_file.cFileName);
	} while (FindNextFile(hFile, &n_file) != 0);
	FindClose(hFile);
}
Ejemplo n.º 4
0
void listdirectory(stringlist_t *list, const char *basepath, const char *path)
{
	int i;
	char pattern[4096], *c;
	WIN32_FIND_DATA n_file;
	HANDLE hFile;
	strlcpy (pattern, basepath, sizeof(pattern));
	strlcat (pattern, path, sizeof (pattern));
	strlcat (pattern, "*", sizeof (pattern));
	// ask for the directory listing handle
	hFile = FindFirstFile(pattern, &n_file);
	if(hFile == INVALID_HANDLE_VALUE)
		return;
	do {
		adddirentry(list, path, n_file.cFileName);
	} while (FindNextFile(hFile, &n_file) != 0);
	FindClose(hFile);

	// convert names to lowercase because windows does not care, but pattern matching code often does
	for (i = 0;i < list->numstrings;i++)
		for (c = list->strings[i];*c;c++)
			if (*c >= 'A' && *c <= 'Z')
				*c += 'a' - 'A';
}