use stat to ensure file being truncated isn't dir
ensure creation succeeds before setting stat.isDir