Fix file header reading logic.
Fix file header reading logic.

- Default to text if file length is less than header size.
- Fix leaking of list directory objects.

Change-Id: Ia256a7eb45a9235e0ea830cc0e69ac9da938de5b
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/7198
Reviewed-by: Chao Sun <67a7c7fa38d7a5d78492d6f0626602205a411205@cloudera.com>
Tested-by: jenkins

cloudera/recordservice,cloudera/recordservice,cloudera/recordservice,cloudera/recordservice,cloudera/recordservice,cloudera/recordservice,cloudera/recordservice