File: directory.h.html

package info (click to toggle)
rudiments 0.32-2
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 5,932 kB
  • ctags: 3,047
  • sloc: cpp: 23,013; sh: 7,769; ansic: 1,769; makefile: 1,057; xml: 169; perl: 19
file content (124 lines) | stat: -rw-r--r-- 8,898 bytes parent folder | download | duplicates (2)
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<html>
<head>
<title>~/src/firstworks/rudiments-0.31/include/rudiments/directory.h.html</title>
<meta name="Generator" content="Vim/7.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body bgcolor="#ffffff" text="#000000">
<pre>
<font color="#0000ff">// Copyright (c) 2004 David Muse</font>
<font color="#0000ff">// See the COPYING file for more information.</font>

<font color="#a020f0">#ifndef RUDIMENTS_DIRECTORY_H</font>
<font color="#a020f0">#define RUDIMENTS_DIRECTORY_H</font>

<font color="#a020f0">#include </font><font color="#ff00ff">&lt;rudiments/private/directoryincludes.h&gt;</font>

<font color="#0000ff">// The directory class provides methods for opening/closing a directory and</font>
<font color="#0000ff">// traversing it's files and subdirectories.</font>

<font color="#a020f0">#ifdef RUDIMENTS_NAMESPACE</font>
<font color="#2e8b57"><b>namespace</b></font> rudiments {
<font color="#a020f0">#endif</font>

<font color="#2e8b57"><b>class</b></font> directoryprivate;

<font color="#2e8b57"><b>class</b></font> directory {
        <font color="#a52a2a"><b>public</b></font>:
                                directory();
                                ~directory();

                <font color="#2e8b57"><b>bool</b></font>  open(<font color="#2e8b57"><b>const</b></font> <font color="#2e8b57"><b>char</b></font> *path);
                        <font color="#0000ff">// opens directory &quot;path&quot;</font>
                <font color="#2e8b57"><b>bool</b></font>  close();
                        <font color="#0000ff">// closes the currently open directory</font>

                <font color="#2e8b57"><b>void</b></font>  rewind();
                        <font color="#0000ff">// Resets the current file/subdirectory inside the</font>
                        <font color="#0000ff">// open directory to the first one.</font>

                <font color="#2e8b57"><b>uint64_t</b></font>      getChildCount();
                        <font color="#0000ff">// Returns the number of files/subdirectories inside</font>
                        <font color="#0000ff">// the open directory.</font>

                <font color="#2e8b57"><b>char</b></font>  *getChildName(<font color="#2e8b57"><b>uint64_t</b></font> index);
                        <font color="#0000ff">// Returns the name of the file/subdirectory at &quot;index&quot;.</font>
                        <font color="#0000ff">//</font>
                        <font color="#0000ff">// This methods allocates a buffer internally and</font>
                        <font color="#0000ff">// returns it.  The calling program must deallocate the</font>
                        <font color="#0000ff">// buffer.</font>


                <font color="#2e8b57"><b>int64_t</b></font>       maxFileNameLength();
                        <font color="#0000ff">// Returns the length of the longest file name</font>
                        <font color="#0000ff">// that can be created in directory &quot;pathname&quot;.</font>
                <font color="#2e8b57"><b>int64_t</b></font>       maxPathLength();
                        <font color="#0000ff">// Returns the length of the longest relative</font>
                        <font color="#0000ff">// path name that can be created under the</font>
                        <font color="#0000ff">// directory &quot;pathname&quot;.</font>
                <font color="#2e8b57"><b>bool</b></font>  canAccessLongFileNames();
                        <font color="#0000ff">// Returns true if an attempt to access a</font>
                        <font color="#0000ff">// file in directory &quot;pathname&quot; longer than the</font>
                        <font color="#0000ff">// length returned by maxFileNameLength() will</font>
                        <font color="#0000ff">// succeed or false if it will fail.</font>



                <font color="#2e8b57"><b>static</b></font> <font color="#2e8b57"><b>bool</b></font>   create(<font color="#2e8b57"><b>const</b></font> <font color="#2e8b57"><b>char</b></font> *path, mode_t perms);
                                <font color="#0000ff">// creates a new directory &quot;path&quot; with </font>
                                <font color="#0000ff">// permissions &quot;perms&quot;</font>
                <font color="#2e8b57"><b>static</b></font> <font color="#2e8b57"><b>bool</b></font>   remove(<font color="#2e8b57"><b>const</b></font> <font color="#2e8b57"><b>char</b></font> *path);
                                <font color="#0000ff">// removes the directory &quot;path&quot; if it is empty</font>

                <font color="#2e8b57"><b>static</b></font> <font color="#2e8b57"><b>char</b></font>   *getCurrentWorkingDirectory();
                                <font color="#0000ff">// Returns the current working directory.</font>
                                <font color="#0000ff">//</font>
                                <font color="#0000ff">// This methods allocates a buffer internally</font>
                                <font color="#0000ff">// and returns it.  The calling program must</font>
                                <font color="#0000ff">// deallocate the buffer.</font>
                <font color="#2e8b57"><b>static</b></font> <font color="#2e8b57"><b>bool</b></font>   changeDirectory(<font color="#2e8b57"><b>const</b></font> <font color="#2e8b57"><b>char</b></font> *path);
                                <font color="#0000ff">// sets the current working directory to &quot;path&quot;</font>

                <font color="#2e8b57"><b>static</b></font> <font color="#2e8b57"><b>bool</b></font>   changeRoot(<font color="#2e8b57"><b>const</b></font> <font color="#2e8b57"><b>char</b></font> *path);
                                <font color="#0000ff">// changes root to &quot;path&quot;</font>

                <font color="#2e8b57"><b>static</b></font> <font color="#2e8b57"><b>int64_t</b></font>        maxFileNameLength(<font color="#2e8b57"><b>const</b></font> <font color="#2e8b57"><b>char</b></font> *pathname);
                                <font color="#0000ff">// Returns the length of the longest file name</font>
                                <font color="#0000ff">// that can be created in directory &quot;pathname&quot;.</font>

                <font color="#2e8b57"><b>static</b></font> <font color="#2e8b57"><b>int64_t</b></font>        maxPathLength(<font color="#2e8b57"><b>const</b></font> <font color="#2e8b57"><b>char</b></font> *pathname);
                                <font color="#0000ff">// Returns the length of the longest relative</font>
                                <font color="#0000ff">// path name that can be created under the</font>
                                <font color="#0000ff">// directory &quot;pathname&quot;.</font>

                <font color="#2e8b57"><b>static</b></font> <font color="#2e8b57"><b>bool</b></font>   canAccessLongFileNames(<font color="#2e8b57"><b>const</b></font> <font color="#2e8b57"><b>char</b></font> *pathname);
                                <font color="#0000ff">// Returns true if an attempt to access a</font>
                                <font color="#0000ff">// file in directory &quot;pathname&quot; longer than the</font>
                                <font color="#0000ff">// length returned by maxFileNameLength() will</font>
                                <font color="#0000ff">// succeed or false if it will fail.</font>


                <font color="#2e8b57"><b>static</b></font> <font color="#2e8b57"><b>bool</b></font>   needsMutex();
                        <font color="#0000ff">// If your system doesn't support readdir_r()</font>
                        <font color="#0000ff">// then this class needs a mutex to assure thread</font>
                        <font color="#0000ff">// safety.</font>
                        <font color="#0000ff">//</font>
                        <font color="#0000ff">// This method returns true if this class needs a mutex</font>
                        <font color="#0000ff">// to operate safely in a threaded environment and false</font>
                        <font color="#0000ff">// otherwise.</font>
                <font color="#2e8b57"><b>static</b></font> <font color="#2e8b57"><b>void</b></font>   setMutex(mutex *mtx);
                        <font color="#0000ff">// Allows you to supply a mutex is the class needs it.</font>
                        <font color="#0000ff">// If your application is not multithreaded, then</font>
                        <font color="#0000ff">// there is no need to supply a mutex.</font>

<font color="#a020f0">        #include </font><font color="#ff00ff">&lt;rudiments/private/directory.h&gt;</font>
};

<font color="#a020f0">#ifdef RUDIMENTS_NAMESPACE</font>
}
<font color="#a020f0">#endif</font>

<font color="#a020f0">#endif</font>
</pre>
</body>
</html>