File: pr_readdir.rst

package info (click to toggle)
firefox 149.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,767,760 kB
  • sloc: cpp: 7,416,064; javascript: 6,752,859; ansic: 3,774,850; python: 1,250,473; xml: 641,578; asm: 439,191; java: 186,617; sh: 56,634; makefile: 18,856; objc: 13,092; perl: 12,763; pascal: 5,960; yacc: 4,583; cs: 3,846; lex: 1,720; ruby: 1,002; php: 436; lisp: 258; awk: 105; sql: 66; sed: 53; csh: 10; exp: 6
file content (93 lines) | stat: -rw-r--r-- 2,224 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
PR_ReadDir
==========

Gets a pointer to the next entry in the directory.


Syntax
------

.. code::

   #include <prio.h>

   PRDirEntry* PR_ReadDir(
     PRDir *dir,
     PRDirFlags flags);


Parameters
~~~~~~~~~~

The function has the following parameters:

``dir``
   A pointer to a :ref:`PRDir` object that designates an open directory.
``flags``
   Specifies which directory entries, if any, to skip. Values can
   include the following:

    - ``PR_SKIP_NONE``. Do not skip any files.
    - ``PR_SKIP_DOT``. Skip the directory entry "." representing the
      current directory.
    - ``PR_SKIP_DOT_DOT``. Skip the directory entry ".." representing
      the parent directory.
    - ``PR_SKIP_BOTH``. Skip both "." and ".."
    - ``PR_SKIP_HIDDEN``. Skip hidden files. On Windows platforms and
      the Mac OS, this value identifies files with the "hidden"
      attribute set. On Unix platform, this value identifies files whose
      names begin with a period (".").


Returns
~~~~~~~

-  A pointer to the next entry in the directory.
-  If the end of the directory is reached or an error occurs, ``NULL``.
   The reason can be retrieved via :ref:`PR_GetError`.


Description
-----------

:ref:`PR_ReadDir` returns a pointer to a directory entry structure:

.. code::

   struct PRDirEntry {
     const char *name;
   };

   typedef struct PRDirEntry PRDirEntry;

The structure has the following field:

``name``
   Name of entry, relative to directory name.

The ``flags`` parameter is an enum of type ``PRDirFlags``:

.. code::

   typedef enum PRDirFlags {
     PR_SKIP_NONE    = 0x0,
     PR_SKIP_DOT     = 0x1,
     PR_SKIP_DOT_DOT = 0x2,
     PR_SKIP_BOTH    = 0x3,
     PR_SKIP_HIDDEN  = 0x4
   } PRDirFlags;

The memory associated with the returned PRDirEntry structure is managed
by NSPR. The caller must not free the ``PRDirEntry`` structure.
Moreover, the ``PRDirEntry`` structure returned by each :ref:`PR_ReadDir`
call is valid only until the next :ref:`PR_ReadDir` or :ref:`PR_CloseDir` call
on the same :ref:`PRDir` object.

If the end of the directory is reached, :ref:`PR_ReadDir` returns ``NULL``,
and :ref:`PR_GetError` returns ``PR_NO_MORE_FILES_ERROR``.


See Also
--------

:ref:`PR_OpenDir`