diff options
| author | [email protected] <[email protected]> | 2011-06-04 13:28:25 +0000 |
|---|---|---|
| committer | [email protected] <[email protected]> | 2011-06-04 13:28:25 +0000 |
| commit | ae4fa4fcbe8b0d51b8fa77231ba2bc239624dbeb (patch) | |
| tree | 8b3483e7464ab1af598e19340953dcc0340f2d69 /examples/file | |
| parent | d37f7b610074448e30bc35e5820e3831620a9edb (diff) | |
add seekdir_test.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1449 bbd45198-f89e-11dd-88c7-29a3b14d5316
Diffstat (limited to 'examples/file')
| -rw-r--r-- | examples/file/seekdir.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/examples/file/seekdir.c b/examples/file/seekdir.c new file mode 100644 index 0000000000..831023f8eb --- /dev/null +++ b/examples/file/seekdir.c @@ -0,0 +1,50 @@ +/*
+ * 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);
|
