From the course: Complete Guide to C Programming Foundations
Unlock the full course today
Join today to access over 24,500 courses taught by industry experts.
Reading a directory - C Tutorial
From the course: Complete Guide to C Programming Foundations
Reading a directory
- [Narrator] A directory is a special type of file, like a database. Its contents reference files on the storage media as managed by the operating system. Just as you can open a file, you can open a directory to examine its contents and obtain information about the files stored there. To open a directory, you use the opendir function. This function is prototyped in the dirent.h header file. Its argument is a string representing the path to a directory to open. The value returned is a dir pointer, which is like the file pointer used to reference open files. Once a directory is opened, you use the read dir function to read its contents. This function is prototyped in the dirent header file. Its argument is the directory handle. The dir address returned from the open dir function. The read dir function returns the address of a dirent structure, which contains information about a file in the directory's database. Members of the dirent structure can be examined to describe files stored in…
Contents
-
-
-
-
-
-
-
-
-
-
-
(Locked)
Reading from a file3m 31s
-
(Locked)
Writing to a file3m 40s
-
(Locked)
Challenge: Writing and reading files1m
-
(Locked)
Solution: Writing and reading files4m 4s
-
(Locked)
Working with raw data3m 4s
-
(Locked)
Using random file access3m 21s
-
(Locked)
Challenge: Access database records56s
-
(Locked)
Solution: Access database records2m 51s
-
(Locked)
Manipulating files2m 34s
-
(Locked)
Exploring the path1m 50s
-
(Locked)
Reading a directory3m 36s
-
(Locked)
Getting file information3m 26s
-
(Locked)
Chapter challenge: Managing files1m 46s
-
(Locked)
Chapter solution: Managing files2m 50s
-
(Locked)
-
-