Sophie

Sophie

distrib > Mandriva > 2010.0 > x86_64 > by-pkgid > 7f3e5f74d754b480ec33648905c4afae > files > 504

glibmm2.4-doc-2.22.1-1mdv2010.0.x86_64.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>glibmm: File Utilities</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.6.1 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="examples.html"><span>Examples</span></a></li>
    </ul>
  </div>
</div>
<div class="contents">
<h1>File Utilities</h1>
<p>Various file-related classes and functions. <a href="#_details">More...</a></p>
<table border="0" cellpadding="0" cellspacing="0">
<tr><td colspan="2"><h2>Classes</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">class&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1FileError.html">Glib::FileError</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight"><a class="el" href="classGlib_1_1Exception.html">Exception</a> class for file-related errors. <a href="classGlib_1_1FileError.html#_details">More...</a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">class&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1DirIterator.html">Glib::DirIterator</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">The iterator type of <a class="el" href="classGlib_1_1Dir.html" title="Utility class representing an open directory.">Glib::Dir</a>. <a href="classGlib_1_1DirIterator.html#_details">More...</a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">class&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1Dir.html">Glib::Dir</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Utility class representing an open directory. <a href="classGlib_1_1Dir.html#_details">More...</a><br/></td></tr>
<tr><td colspan="2"><h2>Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__FileUtils.html#ga0b2fce78896a9a84f7ea3a5646cc7d36">Glib::file_test</a> (const <a class="elRef" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00971.html#a32db3d9898c44d3b3a578b560f7758cc">std::string</a>&amp; filename, FileTest test)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns <code>true</code> if any of the tests in the bitfield <em>test</em> are true. <a href="#ga0b2fce78896a9a84f7ea3a5646cc7d36"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__FileUtils.html#gae4c8d716bd109b6b8e1420a8c20b3507">Glib::mkstemp</a> (<a class="elRef" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00971.html#a32db3d9898c44d3b3a578b560f7758cc">std::string</a>&amp; filename_template)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Opens a temporary file. <a href="#gae4c8d716bd109b6b8e1420a8c20b3507"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__FileUtils.html#gae91f239f1cf0123399374deed54fbf3a">Glib::file_open_tmp</a> (<a class="elRef" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00971.html#a32db3d9898c44d3b3a578b560f7758cc">std::string</a>&amp; name_used, const <a class="elRef" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00971.html#a32db3d9898c44d3b3a578b560f7758cc">std::string</a>&amp; prefix)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Opens a file for writing in the preferred directory for temporary files (as returned by <a class="el" href="group__MiscUtils.html#gac42272146fd9320958132f1591d28991" title="Gets the directory to use for temporary files.">Glib::get_tmp_dir()</a>). <a href="#gae91f239f1cf0123399374deed54fbf3a"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__FileUtils.html#ga682379de4ea119540b4bdc1759e93e1d">Glib::file_open_tmp</a> (<a class="elRef" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00971.html#a32db3d9898c44d3b3a578b560f7758cc">std::string</a>&amp; name_used)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Opens a file for writing in the preferred directory for temporary files (as returned by <a class="el" href="group__MiscUtils.html#gac42272146fd9320958132f1591d28991" title="Gets the directory to use for temporary files.">Glib::get_tmp_dir()</a>). <a href="#ga682379de4ea119540b4bdc1759e93e1d"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="elRef" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00971.html#a32db3d9898c44d3b3a578b560f7758cc">std::string</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__FileUtils.html#ga835da54212fe78e833ac55b49150b989">Glib::file_get_contents</a> (const <a class="elRef" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00971.html#a32db3d9898c44d3b3a578b560f7758cc">std::string</a>&amp; filename)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Reads an entire file into a string, with good error checking. <a href="#ga835da54212fe78e833ac55b49150b989"></a><br/></td></tr>
</table>
<hr/><a name="_details"></a><h2>Detailed Description</h2>
<p>Various file-related classes and functions. </p>
<hr/><h2>Function Documentation</h2>
<a class="anchor" id="ga835da54212fe78e833ac55b49150b989"></a><!-- doxytag: member="Glib::file_get_contents" ref="ga835da54212fe78e833ac55b49150b989" args="(const std::string &amp;filename)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="elRef" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00971.html#a32db3d9898c44d3b3a578b560f7758cc">std::string</a> Glib::file_get_contents </td>
          <td>(</td>
          <td class="paramtype">const <a class="elRef" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00971.html#a32db3d9898c44d3b3a578b560f7758cc">std::string</a> &amp;&#160;</td>
          <td class="paramname"> <em>filename</em></td>
          <td>&#160;)&#160;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Reads an entire file into a string, with good error checking. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>filename</em>&#160;</td><td>A file to read contents from. </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>The file contents. </dd></dl>
<dl><dt><b>Exceptions:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em><a class="el" href="classGlib_1_1FileError.html" title="Exception class for file-related errors.">Glib::FileError</a></em>&#160;</td><td></td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="ga682379de4ea119540b4bdc1759e93e1d"></a><!-- doxytag: member="Glib::file_open_tmp" ref="ga682379de4ea119540b4bdc1759e93e1d" args="(std::string &amp;name_used)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int Glib::file_open_tmp </td>
          <td>(</td>
          <td class="paramtype"><a class="elRef" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00971.html#a32db3d9898c44d3b3a578b560f7758cc">std::string</a> &amp;&#160;</td>
          <td class="paramname"> <em>name_used</em></td>
          <td>&#160;)&#160;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Opens a file for writing in the preferred directory for temporary files (as returned by <a class="el" href="group__MiscUtils.html#gac42272146fd9320958132f1591d28991" title="Gets the directory to use for temporary files.">Glib::get_tmp_dir()</a>). </p>
<p>This function works like <a class="el" href="group__FileUtils.html#gae91f239f1cf0123399374deed54fbf3a" title="Opens a file for writing in the preferred directory for temporary files (as returned...">file_open_tmp(std::string&amp;, const std::string&amp;)</a> but uses a default basename prefix.</p>
<dl><dt><b>Return values:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>name_used</em>&#160;</td><td>The actual name used. </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><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><dt><b>Exceptions:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em><a class="el" href="classGlib_1_1FileError.html" title="Exception class for file-related errors.">Glib::FileError</a></em>&#160;</td><td></td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="gae91f239f1cf0123399374deed54fbf3a"></a><!-- doxytag: member="Glib::file_open_tmp" ref="gae91f239f1cf0123399374deed54fbf3a" args="(std::string &amp;name_used, const std::string &amp;prefix)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int Glib::file_open_tmp </td>
          <td>(</td>
          <td class="paramtype"><a class="elRef" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00971.html#a32db3d9898c44d3b3a578b560f7758cc">std::string</a> &amp;&#160;</td>
          <td class="paramname"> <em>name_used</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="elRef" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00971.html#a32db3d9898c44d3b3a578b560f7758cc">std::string</a> &amp;&#160;</td>
          <td class="paramname"> <em>prefix</em></td><td>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Opens a file for writing in the preferred directory for temporary files (as returned by <a class="el" href="group__MiscUtils.html#gac42272146fd9320958132f1591d28991" title="Gets the directory to use for temporary files.">Glib::get_tmp_dir()</a>). </p>
<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>
<p>The actual name used is returned in <em>name_used</em>.</p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>prefix</em>&#160;</td><td>Template for file name, basename only. </td></tr>
  </table>
  </dd>
</dl>
<dl><dt><b>Return values:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>name_used</em>&#160;</td><td>The actual name used. </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><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><dt><b>Exceptions:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em><a class="el" href="classGlib_1_1FileError.html" title="Exception class for file-related errors.">Glib::FileError</a></em>&#160;</td><td></td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="ga0b2fce78896a9a84f7ea3a5646cc7d36"></a><!-- doxytag: member="Glib::file_test" ref="ga0b2fce78896a9a84f7ea3a5646cc7d36" args="(const std::string &amp;filename, FileTest test)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool Glib::file_test </td>
          <td>(</td>
          <td class="paramtype">const <a class="elRef" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00971.html#a32db3d9898c44d3b3a578b560f7758cc">std::string</a> &amp;&#160;</td>
          <td class="paramname"> <em>filename</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">FileTest&#160;</td>
          <td class="paramname"> <em>test</em></td><td>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Returns <code>true</code> if any of the tests in the bitfield <em>test</em> are true. </p>
<p>For example, <code>(<a class="el" href="group__glibmmEnums.html#gga33c24ccefbd130021f06708763e16ef2a37c8f223bda6b6ce2875490351989ddd">Glib::FILE_TEST_EXISTS</a> | <a class="el" href="group__glibmmEnums.html#gga33c24ccefbd130021f06708763e16ef2ad3679641c18e5e4d4578c2122492cea4">Glib::FILE_TEST_IS_DIR</a>)</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>
<p>Apart from <code><a class="el" href="group__glibmmEnums.html#gga33c24ccefbd130021f06708763e16ef2a86cda9ff0bf25358070a9bc8b4a186d6">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#ga0b2fce78896a9a84f7ea3a5646cc7d36" title="Returns true if any of the tests in the bitfield test are true.">file_test()</a> will return <code>true</code> for both <code><a class="el" href="group__glibmmEnums.html#gga33c24ccefbd130021f06708763e16ef2a86cda9ff0bf25358070a9bc8b4a186d6">Glib::FILE_TEST_IS_SYMLINK</a></code> and <code><a class="el" href="group__glibmmEnums.html#gga33c24ccefbd130021f06708763e16ef2a3181e2e655e765b00dfdb1e1ea443f62">Glib::FILE_TEST_IS_REGULAR</a></code>.</p>
<dl class="note"><dt><b>Note:</b></dt><dd>For a dangling symbolic link <a class="el" href="group__FileUtils.html#ga0b2fce78896a9a84f7ea3a5646cc7d36" title="Returns true if any of the tests in the bitfield test are true.">file_test()</a> will return <code>true</code> for <code><a class="el" href="group__glibmmEnums.html#gga33c24ccefbd130021f06708763e16ef2a86cda9ff0bf25358070a9bc8b4a186d6">Glib::FILE_TEST_IS_SYMLINK</a></code> and <code>false</code> for all other flags.</dd></dl>
<dl><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>filename</em>&#160;</td><td>A filename to test. </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>test</em>&#160;</td><td>Bitfield of <a class="el" href="group__glibmmEnums.html#ga33c24ccefbd130021f06708763e16ef2">Glib::FileTest</a> flags. </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>Whether a test was true. </dd></dl>

</div>
</div>
<a class="anchor" id="gae4c8d716bd109b6b8e1420a8c20b3507"></a><!-- doxytag: member="Glib::mkstemp" ref="gae4c8d716bd109b6b8e1420a8c20b3507" args="(std::string &amp;filename_template)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int Glib::mkstemp </td>
          <td>(</td>
          <td class="paramtype"><a class="elRef" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00971.html#a32db3d9898c44d3b3a578b560f7758cc">std::string</a> &amp;&#160;</td>
          <td class="paramname"> <em>filename_template</em></td>
          <td>&#160;)&#160;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Opens a temporary file. </p>
<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. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>filename_template</em>&#160;</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>
  </dd>
</dl>
<dl class="return"><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>

</div>
</div>
</div>
<hr size="1"/><address style="text-align: right;"><small>Generated on Mon Sep 21 11:07:19 2009 for glibmm by&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address>
</body>
</html>