📄 cpl__vsi_8h.html
字号:
<tr><td valign="top"></td><td valign="top"><em>bUnlinkAndSeize</em> </td><td>TRUE to remove the file, or FALSE to leave unaltered.</td></tr> </table></dl><dl class="return" compact><dt><b>Returns:</b></dt><dd>pointer to memory buffer or NULL on failure. </dd></dl></div></div><p><a class="anchor" name="66e2e6f093fd42f8a941b962d4c8a19e"></a><!-- doxytag: member="cpl_vsi.h::VSIInstallMemFileHandler" ref="66e2e6f093fd42f8a941b962d4c8a19e" args="(void)" --><div class="memitem"><div class="memproto"> <table class="memname"> <tr> <td class="memname">void VSIInstallMemFileHandler </td> <td>(</td> <td class="paramtype">void </td> <td class="paramname"> </td> <td> ) </td> <td width="100%"></td> </tr> </table></div><div class="memdoc"><p>Install "memory" file system handler. <p>A special file handler is installed that allows block of memory to be treated as files. All portions of the file system underneath the base path "/vsimem/" will be handled by this driver.<p>Normal VSI*L functions can be used freely to create and destroy memory arrays treating them as if they were real file system objects. Some additional methods exist to efficient create memory file system objects without duplicating original copies of the data or to "steal" the block of memory associated with a memory file.<p>At this time the memory handler does not properly handle directory semantics for the memory portion of the filesystem. The VSIReadDir() function is not supported though this will be corrected in the future.<p>Calling this function repeatedly should do no harm, though it is not necessary. It is already called the first time a virtualizable file access function (ie. <a class="el" href="cpl__vsi_8h.html#48b5fab6cc22a9d0a543c095ee358634">VSIFOpenL()</a>, VSIMkDir(), etc) is called.<p>This code example demonstrates using GDAL to translate from one memory buffer to another.<p><div class="fragment"><pre class="fragment"> GByte *ConvertBufferFormat( GByte *pabyInData, vsi_l_offset nInDataLength, vsi_l_offset *pnOutDataLength ) { <span class="comment">// create memory file system object from buffer.</span> <a class="code" href="cpl__vsi_8h.html#b1fc5cbfff98db8f5aa912606b07e8d9">VSIFCloseL</a>( <a class="code" href="cpl__vsi_8h.html#1ecb3a78729ecea4d2ce22065a605244">VSIFileFromMemBuffer</a>( <span class="stringliteral">"/vsimem/work.dat"</span>, pabyInData, nInDataLength, FALSE ) ); <span class="comment">// Open memory buffer for read.</span> GDALDatasetH hDS = GDALOpen( <span class="stringliteral">"/vsimem/work.dat"</span>, GA_ReadOnly ); <span class="comment">// Get output format driver. </span> GDALDriverH hDriver = GDALGetDriverByName( <span class="stringliteral">"GTiff"</span> ); GDALDatasetH hOutDS; hOutDS = GDALCreateCopy( hDriver, <span class="stringliteral">"/vsimem/out.tif"</span>, hDS, TRUE, NULL, NULL, NULL ); <span class="comment">// close source file, and "unlink" it. </span> GDALClose( hDS ); <a class="code" href="cpl__vsi_8h.html#69dad1bd6f1af9935c1523db0c6c212f">VSIUnlink</a>( <span class="stringliteral">"/vsimem/work.dat"</span> ); <span class="comment">// seize the buffer associated with the output file.</span> <span class="keywordflow">return</span> <a class="code" href="cpl__vsi_8h.html#eaf26bcc4a5314371f426bb2a5e6ce7a">VSIGetMemFileBuffer</a>( <span class="stringliteral">"/vsimem/out.tif"</span>, pnOutDataLength, TRUE ); }</pre></div> </div></div><p><a class="anchor" name="ef0a5243bbc47cf9645a135d0c7d26df"></a><!-- doxytag: member="cpl_vsi.h::VSIMkdir" ref="ef0a5243bbc47cf9645a135d0c7d26df" args="(const char *pathname, long mode)" --><div class="memitem"><div class="memproto"> <table class="memname"> <tr> <td class="memname">int VSIMkdir </td> <td>(</td> <td class="paramtype">const char * </td> <td class="paramname"> <em>pszPathname</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">long </td> <td class="paramname"> <em>mode</em></td><td> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td><td width="100%"></td> </tr> </table></div><div class="memdoc"><p>Create a directory. <p>Create a new directory with the indicated mode. The mode is ignored on some platforms. A reasonable default mode value would be 0666. This method goes through the VSIFileHandler virtualization and may work on unusual filesystems such as in memory.<p>Analog of the POSIX mkdir() function.<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>pszPathname</em> </td><td>the path to the directory to create. </td></tr> <tr><td valign="top"></td><td valign="top"><em>mode</em> </td><td>the permissions mode.</td></tr> </table></dl><dl class="return" compact><dt><b>Returns:</b></dt><dd>0 on success or -1 on an error. </dd></dl></div></div><p><a class="anchor" name="26cae93b5a32e11bef9ec7c118f8cca4"></a><!-- doxytag: member="cpl_vsi.h::VSIRename" ref="26cae93b5a32e11bef9ec7c118f8cca4" args="(const char *oldpath, const char *newpath)" --><div class="memitem"><div class="memproto"> <table class="memname"> <tr> <td class="memname">int VSIRename </td> <td>(</td> <td class="paramtype">const char * </td> <td class="paramname"> <em>oldpath</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const char * </td> <td class="paramname"> <em>newpath</em></td><td> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td><td width="100%"></td> </tr> </table></div><div class="memdoc"><p>Rename a file. <p>Renames a file object in the file system. It should be possible to rename a file onto a new filesystem, but it is safest if this function is only used to rename files that remain in the same directory.<p>This method goes through the VSIFileHandler virtualization and may work on unusual filesystems such as in memory.<p>Analog of the POSIX rename() function.<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>oldpath</em> </td><td>the name of the file to be renamed. </td></tr> <tr><td valign="top"></td><td valign="top"><em>newpath</em> </td><td>the name the file should be given.</td></tr> </table></dl><dl class="return" compact><dt><b>Returns:</b></dt><dd>0 on success or -1 on an error. </dd></dl></div></div><p><a class="anchor" name="763cceaa0966f37b71a0185c92bb3ad8"></a><!-- doxytag: member="cpl_vsi.h::VSIRmdir" ref="763cceaa0966f37b71a0185c92bb3ad8" args="(const char *pathname)" --><div class="memitem"><div class="memproto"> <table class="memname"> <tr> <td class="memname">int VSIRmdir </td> <td>(</td> <td class="paramtype">const char * </td> <td class="paramname"> <em>pszDirname</em> </td> <td> ) </td> <td width="100%"></td> </tr> </table></div><div class="memdoc"><p>Delete a directory. <p>Deletes a directory object from the file system. On some systems the directory must be empty before it can be deleted.<p>This method goes through the VSIFileHandler virtualization and may work on unusual filesystems such as in memory.<p>Analog of the POSIX rmdir() function.<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>pszDirname</em> </td><td>the path of the directory to be deleted.</td></tr> </table></dl><dl class="return" compact><dt><b>Returns:</b></dt><dd>0 on success or -1 on an error. </dd></dl></div></div><p><a class="anchor" name="c92fbd5e6fc143b026001b32c4c19ed1"></a><!-- doxytag: member="cpl_vsi.h::VSIStatL" ref="c92fbd5e6fc143b026001b32c4c19ed1" args="(const char *, VSIStatBufL *)" --><div class="memitem"><div class="memproto"> <table class="memname"> <tr> <td class="memname">int VSIStatL </td> <td>(</td> <td class="paramtype">const char * </td> <td class="paramname"> <em>pszFilename</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">VSIStatBufL * </td> <td class="paramname"> <em>psStatBuf</em></td><td> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td><td width="100%"></td> </tr> </table></div><div class="memdoc"><p>Get filesystem object info. <p>Fetches status information about a filesystem object (file, directory, etc). The returned information is placed in the VSIStatBufL structure. For portability only the st_size (size in bytes), and st_mode (file type). This method is similar to VSIStat(), but will work on large files on systems where this requires special calls.<p>This method goes through the VSIFileHandler virtualization and may work on unusual filesystems such as in memory.<p>Analog of the POSIX stat() function.<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>pszFilename</em> </td><td>the path of the filesystem object to be queried. </td></tr> <tr><td valign="top"></td><td valign="top"><em>psStatBuf</em> </td><td>the structure to load with information.</td></tr> </table></dl><dl class="return" compact><dt><b>Returns:</b></dt><dd>0 on success or -1 on an error. </dd></dl></div></div><p><a class="anchor" name="69dad1bd6f1af9935c1523db0c6c212f"></a><!-- doxytag: member="cpl_vsi.h::VSIUnlink" ref="69dad1bd6f1af9935c1523db0c6c212f" args="(const char *pathname)" --><div class="memitem"><div class="memproto"> <table class="memname"> <tr> <td class="memname">int VSIUnlink </td> <td>(</td> <td class="paramtype">const char * </td> <td class="paramname"> <em>pszFilename</em> </td> <td> ) </td> <td width="100%"></td> </tr> </table></div><div class="memdoc"><p>Delete a file. <p>Deletes a file object from the file system.<p>This method goes through the VSIFileHandler virtualization and may work on unusual filesystems such as in memory.<p>Analog of the POSIX unlink() function.<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>pszFilename</em> </td><td>the path of the file to be deleted.</td></tr> </table></dl><dl class="return" compact><dt><b>Returns:</b></dt><dd>0 on success or -1 on an error. </dd></dl></div></div><p><hr>Generated for GDAL by <a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.1.</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -