* this function is a POSIX compliant version, which will set position of * next directory structure in the directory stream. * * @param d the directory stream. * @param offset the offset in directory stream. */
| 1074 | * @param offset the offset in directory stream. |
| 1075 | */ |
| 1076 | void seekdir(DIR *d, long offset) |
| 1077 | { |
| 1078 | struct dfs_file *file; |
| 1079 | |
| 1080 | if (d == NULL) |
| 1081 | { |
| 1082 | rt_set_errno(-EBADF); |
| 1083 | return; |
| 1084 | } |
| 1085 | |
| 1086 | file = fd_get(d->fd); |
| 1087 | if (file == NULL) |
| 1088 | { |
| 1089 | rt_set_errno(-EBADF); |
| 1090 | |
| 1091 | return; |
| 1092 | } |
| 1093 | |
| 1094 | if (d && d->fd > 0) |
| 1095 | { |
| 1096 | if (file->fpos > offset) |
| 1097 | { |
| 1098 | /* seek to the offset position of directory */ |
| 1099 | if (dfs_file_lseek(fd_get(d->fd), 0, SEEK_SET) >= 0) |
| 1100 | d->num = d->cur = 0; |
| 1101 | } |
| 1102 | |
| 1103 | while(file->fpos < offset) |
| 1104 | { |
| 1105 | if (!readdir(d)) |
| 1106 | { |
| 1107 | break; |
| 1108 | } |
| 1109 | } |
| 1110 | } |
| 1111 | } |
| 1112 | RTM_EXPORT(seekdir); |
| 1113 | |
| 1114 | /** |
nothing calls this directly
no test coverage detected