What is the difference between open and opendir calls on UNIX?

Asked

Viewed 160 times

2

If the open file uses the open system call, why is there another system call to open files directory (opendir), if a directory is a file type? It wasn’t supposed to be a call just for all kinds of files?

  • Take a look at [tour]. You can accept an answer if it solved your problem. You can vote on every post on the site as well. Did any help you more? You need something to be improved?

2 answers

1

In thesis could but you would have to filter what is directory or not, could err or not pay attention to all the details. A opendir treats a directory in a more specific way. It is essentially a facilitator in relation to open for a specific situation.

0

As far as I know open opens all file types, except directories.

Already opendir returns DIR* from the open directory that is passed to readdir() to read its contents.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.