fix open file bug and add directory features