Is there a ByteString or Text version of getDirectoryContents? I am writing a program which scans a filesystem and it runs out of memory using Strings for all the file names, and I would like to avoid the overhead of calling ByteString.pack on the results of getDirectoryContents.

I don't mind if it only works on POSIX, but System.Posix.Directory.readDirStream returns a String as well, and looking at how readDirStream is implemented I am left puzzled as it looks like it is using calls to native C functions but I can't find where the C string is turned into a String so I can change it to a ByteString or Text.

Thanks,
Jesse