dirread function and open connection function, now public api