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
|
<pre>
<font color="#0000ff">// Copyright (c) 2003 David Muse</font>
<font color="#0000ff">// See the file COPYING for more information</font>
<font color="#a020f0">#include </font><font color="#ff00ff"><rudiments/file.h></font>
<font color="#a020f0">#include </font><font color="#ff00ff"><rudiments/permissions.h></font>
<font color="#a020f0">#include </font><font color="#ff00ff"><rudiments/snooze.h></font>
<font color="#a020f0">#include </font><font color="#ff00ff"><stdio.h></font>
<font color="#a020f0">#ifdef RUDIMENTS_NAMESPACE</font>
<font color="#a52a2a"><b>using</b></font> <font color="#2e8b57"><b>namespace</b></font> rudiments;
<font color="#a020f0">#endif</font>
<font color="#2e8b57"><b>int</b></font> main(<font color="#2e8b57"><b>int</b></font> argc, <font color="#2e8b57"><b>const</b></font> <font color="#2e8b57"><b>char</b></font> **argv) {
file fl;
fl.create(<font color="#ff00ff">"testfile"</font>,permissions::evalPermString(<font color="#ff00ff">"rw-rw----"</font>),<font color="#ff00ff">"hello"</font>);
printf(<font color="#ff00ff">"locking...</font><font color="#6a5acd">\n</font><font color="#ff00ff">"</font>);
printf(<font color="#ff00ff">"locked=</font><font color="#6a5acd">%d</font><font color="#6a5acd">\n</font><font color="#ff00ff">"</font>,fl.lockFile(F_RDLCK|F_WRLCK));
printf(<font color="#ff00ff">"sleeping</font><font color="#6a5acd">\n</font><font color="#ff00ff">"</font>);
snooze::macrosnooze(<font color="#ff00ff">100</font>);
}
</pre>
|