Close file descriptors
Signed-off-by: James Ketrenos <james_gitlab@ketrenos.com>
This commit is contained in:
parent
4d81ce1aca
commit
78ab17acd8
51
scanner.c
51
scanner.c
@ -24,6 +24,7 @@ Face *readFaceDescriptor(int id, char *path) {
|
||||
return NULL;
|
||||
}
|
||||
size_t s = fread(buf, 1, sizeof(buf), f);
|
||||
fclose(f);
|
||||
|
||||
char *p = buf;
|
||||
buf[s] = 0;
|
||||
@ -67,33 +68,35 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
if (!faceDir) {
|
||||
printf("Can not open %s\n", buf);
|
||||
} else {
|
||||
struct dirent *ent;
|
||||
while ((ent = readdir(faceDir)) != NULL) {
|
||||
if (strstr(ent->d_name, ".json") == NULL) {
|
||||
continue;
|
||||
}
|
||||
int id = 0;
|
||||
char *p = ent->d_name;
|
||||
while (*p && *p != '-') {
|
||||
id *= 10;
|
||||
id += *p - '0';
|
||||
p++;
|
||||
}
|
||||
char path[1028*2];
|
||||
sprintf(path, "%s/%s", buf, ent->d_name);
|
||||
Face *pFace = readFaceDescriptor(id, path);
|
||||
if (!pFace) {
|
||||
continue;
|
||||
}
|
||||
if (pChain) {
|
||||
pFace->next = pChain;
|
||||
}
|
||||
pChain = pFace;
|
||||
continue;
|
||||
}
|
||||
|
||||
struct dirent *ent;
|
||||
while ((ent = readdir(faceDir)) != NULL) {
|
||||
if (strstr(ent->d_name, ".json") == NULL) {
|
||||
continue;
|
||||
}
|
||||
closedir(faceDir);
|
||||
int id = 0;
|
||||
char *p = ent->d_name;
|
||||
while (*p && *p != '-') {
|
||||
id *= 10;
|
||||
id += *p - '0';
|
||||
p++;
|
||||
}
|
||||
char path[1028*2];
|
||||
sprintf(path, "%s/%s", buf, ent->d_name);
|
||||
Face *pFace = readFaceDescriptor(id, path);
|
||||
if (!pFace) {
|
||||
continue;
|
||||
}
|
||||
if (pChain) {
|
||||
pFace->next = pChain;
|
||||
}
|
||||
pChain = pFace;
|
||||
}
|
||||
closedir(faceDir);
|
||||
}
|
||||
|
||||
Face *pLink = pChain;
|
||||
int len = 0;
|
||||
while (pLink) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user