repository_infos: Enable automatic updates on the main Haiku repostiory.
[haiku.git] / src / tests / system / libroot / posix / dirent_test.cpp
blobda5a4709c4bf757d1ea8a09fca9748600dde0dca
1 /*
2 * Copyright 2008-2009, Axel Dörfler, axeld@pinc-software.de.
3 * Distributed under the terms of the MIT License.
4 */
7 #include <dirent.h>
8 #include <stdio.h>
9 #include <stdlib.h>
12 int
13 main(int argc, char** argv)
15 dirent *buf, *dirent;
16 DIR* dir = opendir(".");
18 printf("first pass:\n");
19 while (true) {
20 dirent = readdir(dir);
21 if (dirent == NULL)
22 break;
24 printf("Entry: dev %ld, ino %Ld, name \"%s\"\n", dirent->d_dev,
25 dirent->d_ino, dirent->d_name);
26 //printf(" left: %u, next: %d\n", dir->entries_left, dir->next_entry);
29 rewinddir(dir);
30 printf("second pass:\n");
31 while (true) {
32 dirent = readdir(dir);
33 if (dirent == NULL)
34 break;
36 printf("Entry: dev %ld, ino %Ld, name \"%s\"\n", dirent->d_dev,
37 dirent->d_ino, dirent->d_name);
38 //printf(" left: %u, next: %d\n", dir->entries_left, dir->next_entry);
42 closedir(dir);
44 dirent = NULL;
45 buf = (struct dirent*)malloc(sizeof(struct dirent) + NAME_MAX);
47 dir = opendir(".");
49 printf("first pass:\n");
50 while (true) {
51 if (readdir_r(dir, buf, &dirent) != 0 || dirent == NULL)
52 break;
54 printf("Entry: dev %ld, ino %Ld, name \"%s\"\n", dirent->d_dev,
55 dirent->d_ino, dirent->d_name);
56 //printf(" left: %u, next: %d\n", dir->entries_left, dir->next_entry);
59 rewinddir(dir);
60 printf("second pass:\n");
61 while (true) {
62 if (readdir_r(dir, buf, &dirent) != 0 || dirent == NULL)
63 break;
65 printf("Entry: dev %ld, ino %Ld, name \"%s\"\n", dirent->d_dev,
66 dirent->d_ino, dirent->d_name);
67 //printf(" left: %u, next: %d\n", dir->entries_left, dir->next_entry);
70 closedir(dir);
72 return 0;