Expose a fileFromStack private API and convert directoryFromStack to use it.