提交 ae4fa4fc 编写于 作者: B bernard.xiong@gmail.com

add seekdir_test.

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1449 bbd45198-f89e-11dd-88c7-29a3b14d5316
上级 d37f7b61
/*
* File : seekdir.c
* This file is part of RT-TestCase in RT-Thread RTOS
* COPYRIGHT (C) 2011, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
*
* Change Logs:
* Date Author Notes
* 2011-06-02 Bernard first version
*/
#include <dfs_posix.h>
void seekdir_test(void)
{
DIR * dirp;
long save3 = 0;
long cur;
int i = 0;
struct dirent *dp;
dirp = opendir ("/");
save3 = telldir(dirp);
for (dp = readdir(dirp); dp != RT_NULL; dp = readdir(dirp))
{
rt_kprintf("direntry: %s\n", dp->d_name);
/* 保存第三个目录项的目录指针 */
if (i++ == 3)
{
save3 = telldir(dirp);
}
}
/* 回到刚才保存的第三个目录项的目录指针 */
seekdir (dirp, save3);
rt_kprintf("seek dientry to: %d\n", save3);
for (dp = readdir(dirp); dp != RT_NULL; dp = readdir(dirp))
{
rt_kprintf("direntry: %s\n", dp->d_name);
}
/* 关闭目录 */
closedir (dirp);
}
#include <finsh.h>
FINSH_FUNCTION_EXPORT(seekdir_test, perform directory seek test);
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册