MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / seekdir_test

Function seekdir_test

examples/file/seekdir.c:17–47  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15#include <sys/statfs.h>
16
17void seekdir_test(void)
18{
19 DIR * dirp;
20 long save3 = 0;
21 int i = 0;
22 struct dirent *dp;
23
24 dirp = opendir ("/");
25 save3 = telldir(dirp);
26 for (dp = readdir(dirp); dp != RT_NULL; dp = readdir(dirp))
27 {
28 rt_kprintf("direntry: %s\n", dp->d_name);
29
30 /* save the pointer of the third directory */
31 if (i++ == 3)
32 {
33 save3 = telldir(dirp);
34 }
35 }
36
37 /* get back to the third directory */
38 seekdir (dirp, save3);
39 rt_kprintf("seek dientry to: %d\n", save3);
40 for (dp = readdir(dirp); dp != RT_NULL; dp = readdir(dirp))
41 {
42 rt_kprintf("direntry: %s\n", dp->d_name);
43 }
44
45 /* close the directory */
46 closedir (dirp);
47}
48
49#ifdef RT_USING_FINSH
50#include <finsh.h>

Callers

nothing calls this directly

Calls 6

rt_kprintfFunction · 0.85
opendirFunction · 0.50
telldirFunction · 0.50
readdirFunction · 0.50
seekdirFunction · 0.50
closedirFunction · 0.50

Tested by

no test coverage detected