Fix directory I/O compilation on OS X

Possibly fixes errors on Linux as well.