Lines 32-37
Link Here
|
32 |
#include "graphisme.h" |
32 |
#include "graphisme.h" |
33 |
#include "gst_fichier.h" |
33 |
#include "gst_fichier.h" |
34 |
#include <dirent.h> |
34 |
#include <dirent.h> |
|
|
35 |
#include <sys/stat.h> |
35 |
using namespace Wormux; |
36 |
using namespace Wormux; |
36 |
using namespace std; |
37 |
using namespace std; |
37 |
|
38 |
|
Lines 84-124
Link Here
|
84 |
|
85 |
|
85 |
//----------------------------------------------------------------------------- |
86 |
//----------------------------------------------------------------------------- |
86 |
|
87 |
|
87 |
void InitAvatars() |
|
|
88 |
{ |
89 |
Avatar avatar; |
90 |
std::string repertoire = DATADIR+"avatar/"; |
91 |
std::string nom_avatar, nomfich, rep_avatar; |
92 |
struct dirent *fichier; |
93 |
DIR *dir; |
94 |
|
95 |
dir = opendir(repertoire.c_str()); |
96 |
if (dir == NULL) |
97 |
Erreur ("Impossible d'ouvrir le répertoire des avatars ("+repertoire+")"); |
98 |
|
99 |
// Parcours le répertoire des avatars |
100 |
while ((fichier = readdir(dir)) != NULL) |
101 |
{ |
102 |
// On a trouvé un répertoire ? |
103 |
if ((fichier -> d_type == DT_DIR) && (fichier -> d_name[0] != '.')) |
104 |
{ |
105 |
nom_avatar = fichier -> d_name; |
106 |
rep_avatar = repertoire+nom_avatar+'/'; |
107 |
|
108 |
// Si on arrive à le charger correctement, l'ajoute à la liste |
109 |
if (FichierExiste(rep_avatar+NOMFICH_CONFIG) |
110 |
&& avatar.Charge (nom_avatar, rep_avatar)) |
111 |
{ |
112 |
lst_avatar.insert (paire_avatar(nom_avatar, avatar)); |
113 |
} |
114 |
} |
115 |
} |
116 |
|
117 |
closedir (dir); |
118 |
} |
119 |
|
120 |
//----------------------------------------------------------------------------- |
121 |
|
122 |
bool Avatar::Charge (const std::string &nom, const std::string &repertoire) |
88 |
bool Avatar::Charge (const std::string &nom, const std::string &repertoire) |
123 |
{ |
89 |
{ |
124 |
try |
90 |
try |
Lines 221-226
Link Here
|
221 |
Xml_LitArme (baseball, LitDocXml::AccesBalise (armes, "baseball")); |
187 |
Xml_LitArme (baseball, LitDocXml::AccesBalise (armes, "baseball")); |
222 |
} |
188 |
} |
223 |
return true; |
189 |
return true; |
|
|
190 |
} |
191 |
|
192 |
//----------------------------------------------------------------------------- |
193 |
|
194 |
void InitAvatars() |
195 |
{ |
196 |
Avatar avatar; |
197 |
std::string repertoire = DATADIR+"avatar/"; |
198 |
struct dirent *fichier; |
199 |
DIR *dir; |
200 |
|
201 |
dir = opendir(repertoire.c_str()); |
202 |
if (dir == NULL) |
203 |
Erreur ("Impossible d'ouvrir le répertoire des avatars ("+repertoire+")"); |
204 |
|
205 |
// Parcours le répertoire des avatars |
206 |
while ((fichier = readdir(dir)) != NULL) |
207 |
{ |
208 |
std::string nomfich_complet = repertoire+fichier -> d_name; |
209 |
struct stat stat_file; |
210 |
|
211 |
// On a trouvé un répertoire ? |
212 |
if ((fichier -> d_name[0] != '.') |
213 |
&& (stat(nomfich_complet.c_str(), &stat_file) == 0) |
214 |
&& (S_ISDIR(stat_file.st_mode))) |
215 |
{ |
216 |
std::string rep_avatar = nomfich_complet+'/'; |
217 |
|
218 |
// Si on arrive à le charger correctement, l'ajoute à la liste |
219 |
if (FichierExiste(rep_avatar+NOMFICH_CONFIG) |
220 |
&& avatar.Charge (fichier -> d_name, rep_avatar)) |
221 |
{ |
222 |
lst_avatar.insert (paire_avatar(fichier -> d_name, avatar)); |
223 |
} |
224 |
} |
225 |
} |
226 |
|
227 |
closedir (dir); |
224 |
} |
228 |
} |
225 |
|
229 |
|
226 |
//----------------------------------------------------------------------------- |
230 |
//----------------------------------------------------------------------------- |