implement ls command by using another way that do not need to malloc