<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> <title>File Utilities</title> <link href="doxygen.css" rel="stylesheet" type="text/css"> </head> <body bgcolor="#ffffff"> <table border="0" width="100%"> <tr> <td width="10%" height="40"><img src="../../images/gtkmm_logo.gif" alt="logo" border="0" width="100%" height="100%"/></td> <td width="90%" height="40"><img src="../../images/top.gif" alt="top" width="100%" height="40"/></td> </tr> </table> <center> <a class="qindex" href="../../index.html">Main Page</a> <a href="group__Widgets.html">Widgets</a> <a class="qindex" href="namespaces.html"> Namespaces</a> <a href="../../tutorial/html/index.html"> Book</a> </center> <hr width="100%"/> <!-- Generated by Doxygen 1.3-rc1 --> <h1>File Utilities</h1>Various file-related classes and functions. <a href="#_details">More...</a><table border=0 cellpadding=0 cellspacing=0> <tr><td></td></tr> <tr><td colspan=2><br><h2>Compounds</h2></td></tr> <tr><td nowrap align=right valign=top>class </td><td valign=bottom><a class="el" href="classGlib_1_1Dir.html">Dir</a></td></tr> <tr><td> </td><td><font size=-1><em>Utility class representing an open directory.</em> <a href="classGlib_1_1Dir.html#_details">More...</a><em></em></font><br><br></td></tr> <tr><td nowrap align=right valign=top>class </td><td valign=bottom><a class="el" href="classGlib_1_1DirIterator.html">DirIterator</a></td></tr> <tr><td> </td><td><font size=-1><em>The iterator type of <a class="el" href="classGlib_1_1Dir.html">Glib::Dir</a>.</em> <a href="classGlib_1_1DirIterator.html#_details">More...</a><em></em></font><br><br></td></tr> <tr><td nowrap align=right valign=top>class </td><td valign=bottom><a class="el" href="classGlib_1_1FileError.html">FileError</a></td></tr> <tr><td> </td><td><font size=-1><em><a class="el" href="classGlib_1_1Exception.html">Exception</a> class for file-related errors.</em> <a href="classGlib_1_1FileError.html#_details">More...</a><em></em></font><br><br></td></tr> <tr><td colspan=2><br><h2>Functions</h2></td></tr> <tr><td nowrap align=right valign=top>bool </td><td valign=bottom><a class="el" href="group__FileUtils.html#a0">file_test</a> (const std::string& filename, <a class="el" href="group__glibmmEnums.html#a38">FileTest</a> test)</td></tr> <tr><td> </td><td><font size=-1><em>Returns <code>true</code> if any of the tests in the bitfield <em>test</em> are true.</em> <a href="#a0"></a><em></em></font><br><br></td></tr> <tr><td nowrap align=right valign=top>int </td><td valign=bottom><a class="el" href="group__FileUtils.html#a1">mkstemp</a> (std::string& filename_template)</td></tr> <tr><td> </td><td><font size=-1><em>Opens a temporary file.</em> <a href="#a1"></a><em></em></font><br><br></td></tr> <tr><td nowrap align=right valign=top>int </td><td valign=bottom><a class="el" href="group__FileUtils.html#a2">file_open_tmp</a> (std::string& name_used, const std::string& prefix)</td></tr> <tr><td> </td><td><font size=-1><em>Opens a file for writing in the preferred directory for temporary files (as returned by Glib::get_tmp_dir()).</em> <a href="#a2"></a><em></em></font><br><br></td></tr> <tr><td nowrap align=right valign=top>int </td><td valign=bottom><a class="el" href="group__FileUtils.html#a3">file_open_tmp</a> (std::string& name_used)</td></tr> <tr><td> </td><td><font size=-1><em>Opens a file for writing in the preferred directory for temporary files (as returned by Glib::get_tmp_dir()).</em> <a href="#a3"></a><em></em></font><br><br></td></tr> <tr><td nowrap align=right valign=top>std::string </td><td valign=bottom><a class="el" href="group__FileUtils.html#a4">file_get_contents</a> (const std::string& filename)</td></tr> <tr><td> </td><td><font size=-1><em>Reads an entire file into a string, with good error checking.</em> <a href="#a4"></a><em></em></font><br><br></td></tr> </table> <hr><a name="_details"></a><h2>Detailed Description</h2> Various file-related classes and functions. <p> <hr><h2>Function Documentation</h2> <a name="a4" doxytag="Glib::file_get_contents"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> std::string file_get_contents </td> <td class="md" valign="top">(</td> <td class="md" nowrap valign="top">const std::string& </td> <td class="mdname1" valign="top" nowrap> <em>filename</em> </td> <td class="md" valign="top">) </td> <td class="md" nowrap></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> Reads an entire file into a string, with good error checking. <p> <dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign=top><em>filename</em> </td><td>A file to read contents from. </td></tr> </table> </dl> <dl compact><dt><b>Returns:</b></dt><dd>The file contents. </dd></dl> <dl compact><dt><b>Exceptions:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign=top><em>Glib::FileError</em> </td><td></td></tr> </table> </dl> </td> </tr> </table> <a name="a3" doxytag="Glib::file_open_tmp"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> int file_open_tmp </td> <td class="md" valign="top">(</td> <td class="md" nowrap valign="top">std::string& </td> <td class="mdname1" valign="top" nowrap> <em>name_used</em> </td> <td class="md" valign="top">) </td> <td class="md" nowrap></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> Opens a file for writing in the preferred directory for temporary files (as returned by Glib::get_tmp_dir()). <p> This function works like <a class="el" href="group__FileUtils.html#a2">file_open_tmp(std::string&, const std::string&)</a> but uses a default basename prefix. <p> <dl compact><dt><b>Return values:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign=top><em>name_used</em> </td><td>The actual name used. </td></tr> </table> </dl> <dl compact><dt><b>Returns:</b></dt><dd>A file handle (as from <code>open()</code>) to the file opened for reading and writing. The file is opened in binary mode on platforms where there is a difference. The file handle should be closed with <code>close()</code>. </dd></dl> <dl compact><dt><b>Exceptions:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign=top><em>Glib::FileError</em> </td><td></td></tr> </table> </dl> </td> </tr> </table> <a name="a2" doxytag="Glib::file_open_tmp"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> int file_open_tmp </td> <td class="md" valign="top">(</td> <td class="md" nowrap valign="top">std::string& </td> <td class="mdname" nowrap> <em>name_used</em>, </td> </tr> <tr> <td></td> <td></td> <td class="md" nowrap>const std::string& </td> <td class="mdname" nowrap> <em>prefix</em></td> </tr> <tr> <td></td> <td class="md">) </td> <td class="md" colspan="2"></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> Opens a file for writing in the preferred directory for temporary files (as returned by Glib::get_tmp_dir()). <p> <em>prefix</em> should a basename template; it'll be suffixed by 6 characters in order to form a unique filename. No directory components are allowed. <p> The actual name used is returned in <em>name_used.</em> <p> <dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign=top><em>prefix</em> </td><td>Template for file name, basename only. </td></tr> </table> </dl> <dl compact><dt><b>Return values:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign=top><em>name_used</em> </td><td>The actual name used. </td></tr> </table> </dl> <dl compact><dt><b>Returns:</b></dt><dd>A file handle (as from <code>open()</code>) to the file opened for reading and writing. The file is opened in binary mode on platforms where there is a difference. The file handle should be closed with <code>close()</code>. </dd></dl> <dl compact><dt><b>Exceptions:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign=top><em>Glib::FileError</em> </td><td></td></tr> </table> </dl> </td> </tr> </table> <a name="a0" doxytag="Glib::file_test"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> bool file_test </td> <td class="md" valign="top">(</td> <td class="md" nowrap valign="top">const std::string& </td> <td class="mdname" nowrap> <em>filename</em>, </td> </tr> <tr> <td></td> <td></td> <td class="md" nowrap><a class="el" href="group__glibmmEnums.html#a38">FileTest</a> </td> <td class="mdname" nowrap> <em>test</em></td> </tr> <tr> <td></td> <td class="md">) </td> <td class="md" colspan="2"></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> Returns <code>true</code> if any of the tests in the bitfield <em>test</em> are true. <p> For example, <code>(Glib::FILE_TEST_EXISTS | Glib::FILE_TEST_IS_DIR)</code> will return <code>true</code> if the file exists; the check whether it's a directory doesn't matter since the existence test is true. With the current set of available tests, there's no point passing in more than one test at a time. <p> Apart from <code><a class="el" href="group__glibmmEnums.html#a38a5">Glib::FILE_TEST_IS_SYMLINK</a></code> all tests follow symbolic links, so for a symbolic link to a regular file <a class="el" href="group__FileUtils.html#a0">file_test()</a> will return <code>true</code> for both <code><a class="el" href="group__glibmmEnums.html#a38a5">Glib::FILE_TEST_IS_SYMLINK</a></code> and <code><a class="el" href="group__glibmmEnums.html#a38a4">Glib::FILE_TEST_IS_REGULAR</a></code>. <p> <dl compact><dt><b>Note:</b></dt><dd>For a dangling symbolic link <a class="el" href="group__FileUtils.html#a0">file_test()</a> will return <code>true</code> for <code><a class="el" href="group__glibmmEnums.html#a38a5">Glib::FILE_TEST_IS_SYMLINK</a></code> and <code>false</code> for all other flags.</dd></dl> <dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign=top><em>filename</em> </td><td>A filename to test. </td></tr> <tr><td valign=top><em>test</em> </td><td>Bitfield of <a class="el" href="group__glibmmEnums.html#a38">Glib::FileTest</a> flags. </td></tr> </table> </dl> <dl compact><dt><b>Returns:</b></dt><dd>Whether a test was true. </dd></dl> </td> </tr> </table> <a name="a1" doxytag="Glib::mkstemp"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> int mkstemp </td> <td class="md" valign="top">(</td> <td class="md" nowrap valign="top">std::string& </td> <td class="mdname1" valign="top" nowrap> <em>filename_template</em> </td> <td class="md" valign="top">) </td> <td class="md" nowrap></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> Opens a temporary file. <p> See the mkstemp() documentation on most UNIX-like systems. This is a portability wrapper, which simply calls mkstemp() on systems that have it, and implements it in GLib otherwise. <dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign=top><em>filename_template</em> </td><td>A string that should match the rules for mkstemp(), i.e. end in <code>"XXXXXX"</code>. The <code>X</code> string will be modified to form the name of a file that didn't exist. </td></tr> </table> </dl> <dl compact><dt><b>Returns:</b></dt><dd>A file handle (as from open()) to the file opened for reading and writing. The file is opened in binary mode on platforms where there is a difference. The file handle should be closed with close(). In case of errors, <code>-1</code> is returned. </dd></dl> </td> </tr> </table> <hr><address><small> Generated for gtkmm by <a href="http://www.doxygen.org/index.html"> Doxygen</a> 1.3-rc1 © 1997-2001</small></address> </body> </html>