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 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218
|
<html>
<head>
<meta name="keywords" content="eso, FITS format, C library">
<link href="doxygen.css" rel="stylesheet" type="text/css">
<title>QFITS Reference Manual 6.2.0</title>
</head>
<body text="#000000" bgcolor="#ffffff">
<!-- Generated by Doxygen 1.4.1 -->
<h1>Get various names (filenames, dir names,...)</h1><table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">char * </td><td class="memItemRight" valign="bottom"><a class="el" href="group__qfits__filename.html#ga0">qfits_get_dir_name</a> (const char *filename)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Find the directory name in the given string. <a href="#ga0"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">char * </td><td class="memItemRight" valign="bottom"><a class="el" href="group__qfits__filename.html#ga1">qfits_get_base_name</a> (const char *filename)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Find out the base name of a file (i.e. without prefix path). <a href="#ga1"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">char * </td><td class="memItemRight" valign="bottom"><a class="el" href="group__qfits__filename.html#ga2">qfits_get_root_name</a> (const char *filename)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Find out the root part of a basename (name without extension). <a href="#ga2"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">char * </td><td class="memItemRight" valign="bottom"><a class="el" href="group__qfits__filename.html#ga3">qfits_get_ext_name</a> (const char *filename)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Find out the extension of a file name. <a href="#ga3"></a><br></td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
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>
<div class="fragment"><pre class="fragment"> <span class="keywordtype">char</span> * s ;
s = <a class="code" href="group__qfits__filename.html#ga0">qfits_get_dir_name</a>(<span class="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>
<div class="fragment"><pre class="fragment"> <span class="keywordtype">char</span> s[1024];
strcpy(s, <a class="code" href="group__qfits__filename.html#ga0">qfits_get_dir_name</a>(<span class="stringliteral">"/mnt/cdrom/data/image.fits"</span>));
</pre></div><p>
or:<p>
<div class="fragment"><pre class="fragment"> <span class="keywordtype">char</span> * s;
s = strdup(<a class="code" href="group__qfits__filename.html#ga0">qfits_get_dir_name</a>(<span class="stringliteral">"/mnt/cdrom/data/image.fits"</span>));
...
free(s);
</pre></div> <hr><h2>Function Documentation</h2>
<a class="anchor" name="ga1" doxytag="qfits_filename.c::qfits_get_base_name"></a><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top">char* qfits_get_base_name </td>
<td class="md" valign="top">( </td>
<td class="md" nowrap valign="top">const char * </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>
Find out the base name of a file (i.e. without prefix path).
<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>filename</em> </td><td>Full path name to scan. </td></tr>
</table>
</dl>
<dl compact><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>
Examples: <div class="fragment"><pre class="fragment">
qfits_get_base_name("/cdrom/data/image.fits") returns "image.fits"
qfits_get_base_name("filename.fits") returns "filename.fits"
</pre></div> </td>
</tr>
</table>
<a class="anchor" name="ga0" doxytag="qfits_filename.c::qfits_get_dir_name"></a><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top">char* qfits_get_dir_name </td>
<td class="md" valign="top">( </td>
<td class="md" nowrap valign="top">const char * </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>
Find the directory name in the given string.
<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>filename</em> </td><td>Full path name to scan. </td></tr>
</table>
</dl>
<dl compact><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>
Examples: <div class="fragment"><pre class="fragment">
qfits_get_dir_name("/cdrom/data/image.fits") returns "/cdrom/data"
qfits_get_dir_name("filename.fits") returns "."
</pre></div> </td>
</tr>
</table>
<a class="anchor" name="ga3" doxytag="qfits_filename.c::qfits_get_ext_name"></a><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top">char* qfits_get_ext_name </td>
<td class="md" valign="top">( </td>
<td class="md" nowrap valign="top">const char * </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>
Find out the extension of a file name.
<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>filename</em> </td><td>File name without path prefix. </td></tr>
</table>
</dl>
<dl compact><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>
Examples: <div class="fragment"><pre class="fragment">
qfits_get_ext_name("filename.fits") returns "fits"
qfits_get_ext_name("hello.c") returns "c"
qfits_get_ext_name("readme") returns NULL
</pre></div> </td>
</tr>
</table>
<a class="anchor" name="ga2" doxytag="qfits_filename.c::qfits_get_root_name"></a><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top">char* qfits_get_root_name </td>
<td class="md" valign="top">( </td>
<td class="md" nowrap valign="top">const char * </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>
Find out the root part of a basename (name without extension).
<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>filename</em> </td><td>File name to scan. </td></tr>
</table>
</dl>
<dl compact><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>
Examples: <div class="fragment"><pre class="fragment">
qfits_get_root_name("/cdrom/filename.fits") returns "/cdrom/filename"
qfits_get_root_name("filename.paf") returns "filename"
qfits_get_root_name("filename") returns "filename"
qfits_get_root_name("filename.ext") returns "filename.ext"
</pre></div><p>
Since the returned string is statically allocated in this module, do not try to free it or modify its contents. </td>
</tr>
</table>
</body>
</html>
|