Fix FileUtil stack overflow problem
(cherry picked from commit 4f6187f)