cygwin port & File IO refactoring