TORCS  1.3.10
The Open Racing Car Simulator
Loading...
Searching...
No Matches
directory.cpp
Go to the documentation of this file.
1/***************************************************************************
2 directory.cpp -- directory management
3 -------------------
4 created : Fri Aug 13 21:58:55 CEST 1999
5 copyright : (C) 1999-2014 by Eric Espie, Bernhard Wymann
6 email : torcs@free.fr
7 version : $Id$
8 ***************************************************************************/
9
10/***************************************************************************
11 * *
12 * This program is free software; you can redistribute it and/or modify *
13 * it under the terms of the GNU General Public License as published by *
14 * the Free Software Foundation; either version 2 of the License, or *
15 * (at your option) any later version. *
16 * *
17 ***************************************************************************/
18
24
25#include <stdlib.h>
26#ifdef WIN32
27#include <windows.h>
28#endif
29#include <tgf.h>
30#include "os.h"
31
32void
34{
35}
36
37
43tFList * GfDirGetList(const char *dir)
44{
45 if (GfOs.dirGetList) {
46 return GfOs.dirGetList(dir);
47 } else {
48 return (tFList*)NULL;
49 }
50}
51
52
59tFList * GfDirGetListFiltered(const char *dir, const char *suffix)
60{
61 if (GfOs.dirGetListFiltered) {
62 return GfOs.dirGetListFiltered(dir, suffix);
63 } else {
64 return (tFList*)NULL;
65 }
66}
67
75void GfDirFreeList(tFList *list, tfDirfreeUserData freeUserData, bool freename, bool freedispname)
76{
77 if (list) {
78 // The list contains at least one element, checked above.
79 tFList *rl = list;
80 do {
81 tFList *tmp = rl;
82 rl = rl->next;
83 if ((freeUserData) && (tmp->userData)) {
84 freeUserData(tmp->userData);
85 }
86 if (freename && tmp->name != NULL) {
87 freez(tmp->name);
88 }
89 if (freedispname && tmp->dispName != NULL) {
90 freez(tmp->dispName);
91 }
92 free(tmp);
93 } while (rl != list);
94 }
95}
void gfDirInit(void)
Definition directory.cpp:33
tFList * GfDirGetListFiltered(const char *dir, const char *suffix)
Get the list of files with matching suffix of a given directory.
Definition directory.cpp:59
void GfDirFreeList(tFList *list, tfDirfreeUserData freeUserData, bool freename, bool freedispname)
Free a directory list.
Definition directory.cpp:75
tFList * GfDirGetList(const char *dir)
Get the list of files of a given directory.
Definition directory.cpp:43
tGfOs GfOs
Definition os.cpp:37
struct FList * next
Next entry.
Definition tgf.h:230
char * name
File name.
Definition tgf.h:232
char * dispName
Name to display on screen.
Definition tgf.h:233
void * userData
User data.
Definition tgf.h:234
The Gaming Framework API.
void(* tfDirfreeUserData)(void *)
Function to call for releasing the user data associated with file entry.
Definition tgf.h:239
#define freez
Definition tgf.h:66
struct FList tFList
List of (DLL) files for a Directory.