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"><rudiments/private/directoryincludes.h></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 "path"</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 "index".</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 "pathname".</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 "pathname".</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 "pathname" 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 "path" with </font>
<font color="#0000ff">// permissions "perms"</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 "path" 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 "path"</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 "path"</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 "pathname".</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 "pathname".</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 "pathname" 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"><rudiments/private/directory.h></font>
};
<font color="#a020f0">#ifdef RUDIMENTS_NAMESPACE</font>
}
<font color="#a020f0">#endif</font>
<font color="#a020f0">#endif</font>
</pre>
</body>
</html>
|