2013-01-08 21:05:02 +08:00
|
|
|
|
/*
|
|
|
|
|
* 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);
|
|
|
|
|
|
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ¼<C4BF><C2BC><EFBFBD><EFBFBD>Ŀ¼ָ<C2BC><D6B8> */
|
|
|
|
|
if (i++ == 3)
|
|
|
|
|
{
|
|
|
|
|
save3 = telldir(dirp);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* <20>ص<EFBFBD><D8B5>ղű<D5B2><C5B1><EFBFBD><EFBFBD>ĵ<EFBFBD><C4B5><EFBFBD><EFBFBD><EFBFBD>Ŀ¼<C4BF><C2BC><EFBFBD><EFBFBD>Ŀ¼ָ<C2BC><D6B8> */
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* <20>ر<EFBFBD>Ŀ¼ */
|
|
|
|
|
closedir (dirp);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#include <finsh.h>
|
|
|
|
|
FINSH_FUNCTION_EXPORT(seekdir_test, perform directory seek test);
|