Macaw OS C reference

Function listfolder

#include <macaw.h>
int listfolder(const char *path, int index, char *name, int size);

Gives the name of one thing in a folder. Call it with index 0, 1, 2 and so on until it returns 0, to go through them all.

Parameters

pathconst char *
The folder. A path without / at the start is from your program's folder.
indexint
Which thing, counting from 0. Folders come first, then files, each in order of name.
namechar *
Where its name goes. A folder's name has no / on the end, so use isfolder to tell.
sizeint
How many bytes name holds. A name that doesn't fit is cut short.

Returns int

1 if there's a thing at index, or 0 once there's nothing left or the folder isn't there.

In Folders and files, with fileexists, isfolder, makefolder, fileinfo.