Hello, I am developing a server program for Alpine Linux, and I want to traverse file hierarchies, so I look up functions to do just that, and I find nftw which apparently sucks (stupid callback) so I saw the fts family of functions from BSD. Turns out musl does not support it but this package should, so I write a function using fts and it doesn't work at all and I don't know why.
Here is the relevant function I wrote. The output is just . Am I doing something wrong or is this fts implementation broken on Alpine Linux?
I rewrote it in nftw and that works, but I don't like nftw's design and that it requires global variables.
/*
* Free after use with xmlFree
*/
xmlChar *
generate_tracks_xml_fts(void)
{
xmlNodePtr root_node;
xmlChar *xmlbuf;
FTS *fts;
FTSENT *parent;
FTSENT *child;
doc = xmlNewDoc(BAD_CAST "1.0");
root_node = xmlNewNode(NULL, BAD_CAST "releases");
xmlDocSetRootElement(doc, root_node);
char *path_argv[] = { (char*) MUSIC_PATH, NULL };
fts = fts_open(path_argv, FTS_NOCHDIR | FTS_XDEV, NULL);
if (fts == NULL) {
if (errno != ENOENT) {
fprintf(stderr, "Failed to fts_open %s", MUSIC_PATH);
}
return 0;
}
while ((parent = fts_read(fts)) != NULL) {
child = fts_children(fts, 0);
if (errno != 0) {
perror("fts_children");
}
while ((child != NULL)
&& (child->fts_link != NULL)) {
child = child->fts_link;
switch (child->fts_info) {
case FTS_F:
xmlNewTextChild(root_node, NULL, BAD_CAST "track", BAD_CAST child->fts_name);
puts(child->fts_name);
break;
}
}
}
fts_close(fts);
xmlDocDumpFormatMemory(doc, &xmlbuf, NULL, 1);
return xmlbuf;
}
Hello, I am developing a server program for Alpine Linux, and I want to traverse file hierarchies, so I look up functions to do just that, and I find nftw which apparently sucks (stupid callback) so I saw the fts family of functions from BSD. Turns out musl does not support it but this package should, so I write a function using fts and it doesn't work at all and I don't know why.
Here is the relevant function I wrote. The output is just . Am I doing something wrong or is this fts implementation broken on Alpine Linux?
I rewrote it in nftw and that works, but I don't like nftw's design and that it requires global variables.