<tr><tdclass="mdescLeft"> </td><tdclass="mdescRight">Find out the base name of a file (i.e. without prefix path). <ahref="#ga1"></a><br></td></tr>
<tr><tdclass="mdescLeft"> </td><tdclass="mdescRight">Find out the root part of a basename (name without extension). <ahref="#ga2"></a><br></td></tr>
The following functions are useful to cut out a filename into its components. All functions work with statically allocated memory, i.e. the pointers they return are not permanent but likely to be overwritten at each function call. If you need a returned value later on, you should store it into a local variable.<p>
Example:<p>
<divclass="fragment"><preclass="fragment"><spanclass="keywordtype">char</span> * s ;
s = <aclass="code"href="group__qfits__filename.html#ga0">qfits_get_dir_name</a>(<spanclass="stringliteral">"/mnt/cdrom/data/image.fits"</span>)
</pre></div><p>
s contains now "/mnt/cdrom/data" but will loose these contents at the next function call. To retain its value, you can either do:<p>
s = strdup(<aclass="code"href="group__qfits__filename.html#ga0">qfits_get_dir_name</a>(<spanclass="stringliteral">"/mnt/cdrom/data/image.fits"</span>));
Find out the base name of a file (i.e. without prefix path).
<p>
<dlcompact><dt><b>Parameters:</b></dt><dd>
<tableborder="0"cellspacing="2"cellpadding="0">
<tr><tdvalign="top"></td><tdvalign="top"><em>filename</em> </td><td>Full path name to scan. </td></tr>
</table>
</dl>
<dlcompact><dt><b>Returns:</b></dt><dd>Pointer to char within the input string.</dd></dl>
Provide a full path name and you get in return a pointer to a statically allocated string containing the name of the file only, without prefixing directory names. If the input string does not contain a slash (i.e. it is not a full path), the returned string is a copy of the input string.<p>
This function does not check for the existence of the path or the file.<p>
<tr><tdvalign="top"></td><tdvalign="top"><em>filename</em> </td><td>Full path name to scan. </td></tr>
</table>
</dl>
<dlcompact><dt><b>Returns:</b></dt><dd>Pointer to statically allocated string.</dd></dl>
Provide a full path name and you get in return a pointer to a statically allocated string containing the name of the directory only, without trailing slash. If the input string does not contain a slash (i.e. it is not a full path), the returned string is '.', corresponding to the current working directory. Since the returned string is statically allocated, do not try to free it or modify it.<p>
This function does not check for the existence of the path or the file.<p>
<tr><tdvalign="top"></td><tdvalign="top"><em>filename</em> </td><td>File name without path prefix. </td></tr>
</table>
</dl>
<dlcompact><dt><b>Returns:</b></dt><dd>Pointer to char within the input string.</dd></dl>
Find out the extension of a given file name. Notice that the input character string must not contain a path prefix (typically, you feed in the output of <code>qfits_get_base_name</code>).<p>
Works with all kinds of extensions: returns the part of the string after the last dot. If no dot is found in the input string, NULL is returned.<p>
Find out the root part of a basename (name without extension).
<p>
<dlcompact><dt><b>Parameters:</b></dt><dd>
<tableborder="0"cellspacing="2"cellpadding="0">
<tr><tdvalign="top"></td><tdvalign="top"><em>filename</em> </td><td>File name to scan. </td></tr>
</table>
</dl>
<dlcompact><dt><b>Returns:</b></dt><dd>Pointer to statically allocated string.</dd></dl>
Find out the root part of a file name, i.e. the file name without extension. Since in Unix a file name can have several dots, only a number of extensions are supported. This includes:<p>
<ul>
<li>.fits and .FITS</li><li>.tfits and .TFITS</li><li>.paf and .PAF</li><li>.ascii and .ASCII</li><li>.dat and .DAT</li><li>.txt and .TXT</li></ul>
<p>
This function does not check for the existence of the path or the file.<p>