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

Function closedir

components/dfs/dfs_v2/src/dfs_posix.c:1139–1171  ·  view source on GitHub ↗

* this function is a POSIX compliant version, which will close a directory * stream. * * @param d the directory stream. * * @return 0 on successful, -1 on failed. */

Source from the content-addressed store, hash-verified

1137 * @return 0 on successful, -1 on failed.
1138 */
1139int closedir(DIR *d)
1140{
1141 int result;
1142 struct dfs_file *file;
1143
1144 if (d == NULL)
1145 {
1146 rt_set_errno(-EBADF);
1147 return -1;
1148 }
1149
1150 file = fd_get(d->fd);
1151 if (file == NULL)
1152 {
1153 rt_set_errno(-EBADF);
1154 return -1;
1155 }
1156
1157 result = dfs_file_close(file);
1158 if (result < 0)
1159 {
1160 rt_set_errno(result);
1161
1162 return -1;
1163 }
1164 else
1165 {
1166 fd_release(d->fd);
1167 rt_free(d);
1168 }
1169
1170 return 0;
1171}
1172RTM_EXPORT(closedir);
1173
1174#ifdef DFS_USING_WORKDIR

Callers 2

rmdirFunction · 0.70
chdirFunction · 0.70

Calls 5

rt_set_errnoFunction · 0.85
rt_freeFunction · 0.85
fd_getFunction · 0.70
dfs_file_closeFunction · 0.70
fd_releaseFunction · 0.70

Tested by

no test coverage detected