34 size_t slen = strlen(
path) + 16;
35 char *
cmd = (
char *)malloc(slen);
37 snprintf(
cmd, slen,
"ls -1 \"%s\"",
path);
38 FILE *
fp = popen(
cmd,
"r");
41 while (fgets(line,
sizeof(line),
fp)) {
43 size_t l = strlen(line);
44 if (
l > 0 && line[
l - 1] ==
'\n') line[
l - 1] =
'\0';
45 if (
l > 1 && line[
l - 2] ==
'\r') line[
l - 2] =
'\0';
47 if (line[0] !=
'\0') {
Tagged union representing a Fun value.
Value make_string(const char *s)
Construct a string Value by duplicating the given C string.
char * value_to_string_alloc(const Value *v)
Allocate a printable C string for a Value.
int array_push(Value *v, Value newElem)
Append a Value to an array.
Value make_array_from_values(const Value *vals, int count)
Create an array Value by copying items from an input span.