Answer the question
In order to leave comments, you need to log in
Library for reading directories?
Good day, I'm looking for a library to work with the Linux file system. I am writing an analogue of a dialog box with a choice of a directory for saving (such a task from the university). To draw the interface I use SDL2.
What is needed from the library:
Answer the question
In order to leave comments, you need to log in
distinguishes dirent folders from files
ent = readdir(curr_dir);
switch (ent->d_type)
{
// directory
case DT_DIR: break;
//files
case DT_REG: break;
}
unsigned char d_type; /* type of file; not supported
by all file system types */
www.gnu.org/software/libc/manual/html_node/Directo...
<skip>
DT_DIR
A directory.
<skip>
The stat() system call yields a structure in which all properties are specified.
The following symbolic names for the values of type mode_t shall also
be defined.
File type:
S_IFMT Type of file.
S_IFBLK
Block special.
S_IFCHR
Character special.
S_IFIFO
FIFO special.
S_IFREG
Regular.
S_IFDIR
Directory.
...
The following macros shall be provided to test whether a file is of the
specified type. The value m supplied to the macros is the value of
st_mode from a stat structure. The macro shall evaluate to a non-zero
value if the test is true; 0 if the test is false.
S_ISBLK(m)
Test for a block special file.
S_ISCHR(m)
Test for a character special file.
S_ISDIR(m)
Test for a directory.
S_ISFIFO(m)
Test for a pipe or FIFO special file.
S_ISREG(m)
Test for a regular file.
S_ISLNK(m)
Test for a symbolic link.
S_ISSOCK(m)
Test for a socket.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question