added getopt and readdir