简体   繁体   中英

Where is readdir in linux?

I'm editing linux v2.18.8 (CentOS5) to include file attributes for a project for school. One of the things we have to implement as a group is to list all attribute names (Attributes are text files stored in hidden directories at the same level as the file).

Just an example:

this.jpg is a file in /Desktop/Testing. When you add a custom user attribute a folder is created that holds the attributes. So if I add the attribute "Creator" and have it's value as "bob" you get a dir /Desktop/Testing/.this.jpg_attr/Creator (and if you open Creator, it's contents will be "bob").

What I'm interested in doing is listing all of the user created attributes in the attributes folder (or from the example all the files in /Desktop/Testing/.this.jpg_attr/) I know that I want to use the readdir call, but I don't know where to find it in the linux setup. If anyone could give me any guidance as to where to look for readdir, I think I can figure out how to manipulate it.

I'M NOT ASKING FOR ANY CODE. JUST A FILE PATH FOR WHERE READDIR IS, OR THE SYSTEM CALL THAT CALLS READDIR.

Thanks in advanced.

It's not exactly clear what you mean. The readdir function you want to use is part of the standard library and will be linked in automatically.

Perhaps you're asking how to include the header file that declares readdir . In that case:

#include <dirent.h>

You can get more information about the readdir function using this command:

man 3 readdir

系统调用是getdents(2) ,但是您应该继续使用readdir包装器以实现可移植性。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM