ibm-information-center/dist/eclipse/plugins/i5OS.ic.apis_5.4.0.1/renamekpu.htm

192 lines
5.8 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Copyright" content="Copyright (c) 2006 by IBM Corporation">
<title>QlgRenameKeep()--Rename File or Directory, Keep "new" If It Exists
(using NLS-enabled path name)</title>
<!-- Begin Header Records -->
<!-- All rights reserved. Licensed Materials Property of IBM -->
<!-- US Government Users Restricted Rights -->
<!-- Use, duplication or disclosure restricted by -->
<!-- GSA ADP Schedule Contract with IBM Corp. -->
<!-- file cleaned -->
<!-- Created by Yvonne Griffin for V5R1-->
<!-- This file has undergone html cleanup June 2002 by JET -->
<!-- End Header Records -->
<link rel="stylesheet" type="text/css" href="../rzahg/ic.css">
</head>
<body>
<a name="Top_Of_Page"></a>
<!--Java sync-link-->
<script language="Javascript" src="../rzahg/synch.js" type="text/javascript">
</script>
<h2>QlgRenameKeep()--Rename File or Directory, Keep "new" If It Exists (using
NLS-enabled path name)</h2>
<div class="box" style="width: 65%;">
<br>
&nbsp;&nbsp;Syntax<br>
<pre>
#include &lt;Qp0lstdi.h&gt;
int QlgRenameKeep(Qlg_Path_Name_T <em>*old</em>, Qlg_Path_Name_T <em>*new</em>);
</pre>
&nbsp;&nbsp;Service Program Name: QP0LLIB1<br>
<!-- iddvc RMBR -->
<br>
&nbsp;&nbsp;Default Public Authority: *USE<br>
<!-- iddvc RMBR -->
<br>
&nbsp;&nbsp;Threadsafe: Conditional; see Usage Notes for <a href=
"renamekp.htm">Qp0lRenameKeep()</a>.<br>
<!-- iddvc RMBR -->
<br>
</div>
<p>The <strong>QlgRenameKeep()</strong> function, like the <strong>
Qp0lRenameKeep()</strong> function, renames a file or a directory specified by
<em>old</em> to the name given by <em>new</em>. The difference is that the
<strong>QlgRenameKeep()</strong> function takes pointers to Qlg_Path_Name_T
structures, while <strong>Qp0lRenameKeep()</strong> takes pointers to character
strings.</p>
<p>Limited information on the <em>old</em> and <em>new</em> parameters is
provided here. For more information on these parameters and for a discussion of
the authorities required, return values, and related information, see <a href=
"renamekp.htm">Qp0lRenameKeep()</a>--Rename File or Directory, Keep "new" If It
Exists.</p>
<br>
<h3>Parameters</h3>
<dl>
<dt><strong><em>old</em></strong></dt>
<dd>(Input) A pointer to a Qlg_Path_Name_T structure that contains a path name
or a pointer to the path name of the file to be renamed. For more information
on the Qlg_Path_Name_T structure, see <a href="../apiref/pns.htm">Path name
format</a>.<br>
<br>
</dd>
<dt><strong><em>new</em></strong></dt>
<dd>(Input) A pointer to a Qlg_Path_Name_T structure that contains a path name
or a pointer to the path name of the new name for the file. For more
information on the Qlg_Path_Name_T structure, see <a href="../apiref/pns.htm">Path name
format</a>.</dd>
</dl>
<br>
<h3>Related Information</h3>
<ul>
<li><a href="renamekp.htm">Qp0lRenameKeep()</a>--Rename File or Directory, Keep
"new" If It Exists<br>
<br>
</li>
<li><a href="pathconfu.htm">QlgPathconf()</a>--Get Configurable Path Name
Variables (using NLS-enabled path name)<br>
<br>
</li>
<li><a href="renameunu.htm">QlgRenameUnlink()</a>--Rename File or Directory,
Unlink "new" If It Exists (using NLS-enabled path name)</li>
</ul>
<br>
<h3>Example</h3>
<p>See <a href="../apiref/aboutapis.htm#codedisclaimer">Code disclaimer information</a>
for information pertaining to code examples.</p>
<p>When you pass two file names to this example, it changes the first file name
to the second file name using <strong>QlgRenameKeep()</strong>.</p>
<pre>
#include &lt;Qp0lstdi.h&gt;
#include &lt;stdio.h&gt;
int main(int argc, char **argv)
{
if ( argc != 3 )
{
printf( "Usage: %s old_fn new_fn\n", argv[0]);
perror ( "Could not rename file" );
}
else
{
const char US_const[3]= "US";
const char Language_const[4]="ENU";
typedef struct pnstruct
{
Qlg_Path_Name_T qlg_struct;
/*** EXTRA STORAGE MAY BE NEEDED ***/
char pn[1025]; /* This size must be &gt;= the path */
/* name length or a pointer to */
/* the path name. */
};
struct pnstruct path_old;
struct pnstruct path_new;
struct pnstruct *path_old_ptr;
struct pnstruct *path_new_ptr;
memset((void*)&amp;path_old, 0x00, sizeof(struct pnstruct));
path_old_ptr = &amp;path_old;
path_old.qlg_struct.CCSID = 37;
memcpy(path_old.qlg_struct.Country_ID,US_const,2);
memcpy(path_old.qlg_struct.Language_ID,Language_const,3);;
path_old.qlg_struct.Path_Type = 0;
path_old.qlg_struct.Path_Length = strlen(argv[1]);
path_old.qlg_struct.Path_Name_Delimiter[0] = '/';
memcpy(path_old.pn,argv[1],sizeof(argv[1])-1);
memset((void*)&amp;path_new, 0x00, sizeof(struct pnstruct));
path_new_ptr = &amp;path_new;
path_new.qlg_struct.CCSID = 37;
memcpy(path_new.qlg_struct.Country_ID,US_const,2);
memcpy(path_new.qlg_struct.Language_ID,Language_const,3);;
path_new.qlg_struct.Path_Type = 0;
path_new.qlg_struct.Path_Length = strlen(argv[2]);
path_new.qlg_struct.Path_Name_Delimiter[0] = '/';
memcpy(path_new.pn,argv[2],sizeof(argv[2])-1);
if (QlgRenameKeep((Qlg_Path_Name_T *)path_old_ptr,
(Qlg_Path_Name_T *)path_new_ptr ) != 0)
{perror ( "Could not rename file." ); }
else {perror ( "File renamed." ); }
}
}
</pre>
<hr>
API introduced: V5R1
<hr>
<center>
<table cellpadding="2" cellspacing="2">
<tr align="center">
<td valign="middle" align="center"><a href="#Top_Of_Page">Top</a> | <a href=
"unix.htm">UNIX-Type APIs</a> | <a href="aplist.htm">APIs by category</a></td>
</tr>
</table>
</center>
</body>
</html>