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;
|
return NULL;
|
||||||
}
|
}
|
||||||
size_t s = fread(buf, 1, sizeof(buf), f);
|
size_t s = fread(buf, 1, sizeof(buf), f);
|
||||||
|
fclose(f);
|
||||||
|
|
||||||
char *p = buf;
|
char *p = buf;
|
||||||
buf[s] = 0;
|
buf[s] = 0;
|
||||||
@ -67,33 +68,35 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
if (!faceDir) {
|
if (!faceDir) {
|
||||||
printf("Can not open %s\n", buf);
|
printf("Can not open %s\n", buf);
|
||||||
} else {
|
continue;
|
||||||
struct dirent *ent;
|
}
|
||||||
while ((ent = readdir(faceDir)) != NULL) {
|
|
||||||
if (strstr(ent->d_name, ".json") == NULL) {
|
struct dirent *ent;
|
||||||
continue;
|
while ((ent = readdir(faceDir)) != NULL) {
|
||||||
}
|
if (strstr(ent->d_name, ".json") == NULL) {
|
||||||
int id = 0;
|
continue;
|
||||||
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);
|
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;
|
Face *pLink = pChain;
|
||||||
int len = 0;
|
int len = 0;
|
||||||
while (pLink) {
|
while (pLink) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user