relocatetree.html

来自「perl教程」· HTML 代码 · 共 281 行

HTML
281
字号
<?xml version="1.0" ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<!-- saved from url=(0017)http://localhost/ -->
<script language="JavaScript" src="../../displayToc.js"></script>
<script language="JavaScript" src="../../tocParas.js"></script>
<script language="JavaScript" src="../../tocTab.js"></script>
<link rel="stylesheet" type="text/css" href="../../scineplex.css">
<title>ActiveState::RelocateTree - copy tree substituting paths at the same time</title>
<link rel="stylesheet" href="../../Active.css" type="text/css" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rev="made" href="mailto:" />
</head>

<body>

<script>writelinks('__top__',2);</script>
<h1><a>ActiveState::RelocateTree - copy tree substituting paths at the same time</a></h1>
<p><a name="__index__"></a></p>

<!-- INDEX BEGIN -->

<ul>

	<li><a href="#name">NAME</a></li>
	<li><a href="#synopsis">SYNOPSIS</a></li>
	<li><a href="#description">DESCRIPTION</a></li>
	<li><a href="#see_also">SEE ALSO</a></li>
	<li><a href="#copyright">COPYRIGHT</a></li>
</ul>
<!-- INDEX END -->

<hr />
<p>
</p>
<h1><a name="name">NAME</a></h1>
<p>ActiveState::RelocateTree - copy tree substituting paths at the same time</p>
<p>
</p>
<hr />
<h1><a name="synopsis">SYNOPSIS</a></h1>
<pre>
   <span class="keyword">use</span> <span class="variable">ActiveState::RelocateTree</span> <span class="string">qw(relocate)</span><span class="operator">;</span>
   <span class="variable">relocate</span><span class="operator">(</span><span class="string">from</span> <span class="operator">=&gt;</span> <span class="string">'C:\Perl'</span><span class="operator">,</span> <span class="string">to</span> <span class="operator">=&gt;</span> <span class="string">'D:\lang\perl'</span><span class="operator">);</span>
</pre>
<p>
</p>
<hr />
<h1><a name="description">DESCRIPTION</a></h1>
<p>When a perl installation is copied into a new location, some of its
files need to be modified accordingly.  The
<code>ActiveState::RelocateTree</code> module provide functions that helps you
do this.</p>
<p>The following functions are provided.  None of them are exported by
default.</p>
<dl>
<dt><strong><a name="item_relocate">relocate( %options )</a></strong>

<dd>
<p>This is the main entry point that applications will use.  The
following options are recognized:</p>
</dd>
<dl>
<dt><strong><a name="item_to"><code>to</code></a></strong>

<dd>
<p>The tree which must be transformed. Unless the <a href="#item_inplace"><code>inplace</code></a> option is
true, it will copy the tree at <a href="#item_from"><code>from</code></a> to <a href="#item_to"><code>to</code></a> before transforming
it. This option is the only one required.  The other options have
reasonable defaults, so in most cases this is the only option you need
to provide.</p>
</dd>
</li>
<dt><strong><a name="item_from"><code>from</code></a></strong>

<dd>
<p>The path from which to copy the perl tree. Defaults to <code>$Config{prefix}</code>, the
home of the currently executing perl interpreter.</p>
</dd>
</li>
<dt><strong><a name="item_search"><code>search</code></a></strong>

<dd>
<p>This is the path which will be searched for and replaced in <a href="#item_to"><code>to</code></a>. This
defaults to the value of <a href="#item_from"><code>from</code></a>.</p>
</dd>
</li>
<dt><strong><a name="item_replace"><code>replace</code></a></strong>

<dd>
<p>The replacement value for <a href="#item_search"><code>search</code></a>. This defaults to the value of <a href="#item_to"><code>to</code></a>.</p>
</dd>
</li>
<dt><strong><a name="item_inplace"><code>inplace</code></a></strong>

<dd>
<p>If the tree at <a href="#item_to"><code>to</code></a> already exists and you just want to transform it in-situ,
use this option. It skips the copying step and just transforms the tree.
If <a href="#item_from"><code>from</code></a> equals <a href="#item_to"><code>to</code></a>, it is set to true and cannot be unset. Otherwise it
defaults to false.</p>
</dd>
</li>
<dt><strong><a name="item_killorig"><code>killorig</code></a></strong>

<dd>
<p>If you're really moving the tree, this option will remove <a href="#item_from"><code>from</code></a> after
copying and transforming <a href="#item_to"><code>to</code></a>. Use with care! Defaults to false.</p>
</dd>
</li>
<dt><strong><a name="item_bak"><code>bak</code></a></strong>

<dd>
<p>While relocating the tree, <a href="#item_relocate"><code>relocate()</code></a> creates a backup file for each file
being edited. This option allows you to specify the extension of backup files.
Defaults to <code>.~1~</code>.</p>
</dd>
</li>
<dt><strong><a name="item_savebaks"><code>savebaks</code></a></strong>

<dd>
<p>Normally <a href="#item_relocate"><code>relocate()</code></a> deletes the backup files before returning. <a href="#item_savebaks"><code>savebaks</code></a>
skips that step, leaving the backup files alone. Defaults to false (backups
are deleted).</p>
</dd>
</li>
<dt><strong><a name="item_textonly"><code>textonly</code></a></strong>

<dd>
<p>Normally <a href="#item_relocate"><code>relocate()</code></a> edits both text and binary files. Text files are replaced
using a normal search-and-replace algorithm, but binary files are NULL-padded
so that all offsets remain the same. By default, <a href="#item_textonly"><code>textonly</code></a> is false, i.e.
<a href="#item_relocate"><code>relocate()</code></a> operates on both text and binary files.</p>
</dd>
</li>
<dt><strong><a name="item_ranlib"><code>ranlib</code></a></strong>

<dd>
<p>If <a href="#item_ranlib"><code>ranlib</code></a> is true, <a href="#item_relocate"><code>relocate()</code></a> will call <a href="#item_ranlib"><code>ranlib</code></a> on binary files which
look like library files (have the <code>$Config{_a}</code> extension). Defaults to true.</p>
</dd>
</li>
<dt><strong><a name="item_verbose"><code>verbose</code></a></strong>

<dd>
<p>If <a href="#item_verbose"><code>verbose</code></a> is true, <a href="#item_relocate"><code>relocate()</code></a> emits warning messages as it performs
certain operations. This may be useful for debugging, or for command-line
tools, where user feedback is a good thing.</p>
</dd>
</li>
<dt><strong><a name="item_quiet"><code>quiet</code></a></strong>

<dd>
<p>Normally, <a href="#item_relocate"><code>relocate()</code></a> prints out some status messages even with <a href="#item_verbose"><code>verbose</code></a>
disabled. If <a href="#item_quiet"><code>quiet</code></a> is true, all messages (except error messages) are
temporarily silenced. This option overrides <a href="#item_verbose"><code>verbose</code></a>, so there isn't much
point calling <a href="#item_relocate"><code>relocate()</code></a> with both <a href="#item_quiet"><code>quiet</code></a> and <a href="#item_verbose"><code>verbose</code></a> set. By default,
<a href="#item_quiet"><code>quiet</code></a> is false.</p>
</dd>
</li>
<dt><strong><a name="item_filelist"><code>filelist</code></a></strong>

<dd>
<p>If specified, <a href="#item_relocate"><code>relocate()</code></a> will write a list of the files modified to
<a href="#item_filelist"><code>filelist</code></a>, one filename per line.  The lines are prefixed with &quot;B &quot;
for binary files and &quot;T &quot; for text files.</p>
</dd>
</li>
</dl>
<dt><strong><a name="item_move_tree">move_tree( $from, $to )</a></strong>

<dt><strong>move_tree( $from, $to, $delete_after, $verbose )</strong>

<dd>
<p>This function will copy the directory tree at $from to the location
$to.</p>
</dd>
<dd>
<p>If $delete_after is TRUE, then tree at $from will be removed after the
copy completes. If $verbose is TRUE, then print a message when
deleting the $from tree.</p>
</dd>
</li>
<dt><strong><a name="item_check">check( $file, $regexp, $is_binary )</a></strong>

<dd>
<p>Returns TRUE if there are occurrences of $regexp in $file. It is used
by <a href="#item_relocate"><code>relocate()</code></a> to search for files which should be edited.  If
$is_binary is TRUE, then read the file in binmode.</p>
</dd>
</li>
<dt><strong><a name="item_edit">edit( $regexp, $from, $dest, $bak, $are_binary, @files )</a></strong>

<dd>
<p><a href="#item_edit"><code>edit()</code></a> is designed to rip though a set of files, efficiently replacing $from
with $dest. It operates on the whole set of files, which all need to be of the
same type (binary or text). It accepts the following parameters:</p>
</dd>
<dl>
<dt><strong><a name="item__regexp">$regexp</a></strong>

<dd>
<p>The regular expression to search for. Matching text will be replaced with
$dest.</p>
</dd>
</li>
<dt><strong><a name="item__from">$from</a></strong>

<dd>
<p>The path to search for and replace. If $are_binary is true, this is used to
calculate the amount of NUL-padding required to preserve the length of strings.
It is not used otherwise.</p>
</dd>
</li>
<dt><strong><a name="item__dest">$dest</a></strong>

<dd>
<p>The replacement string. If $are_binary is true and $dest is shorter than
$from, then it inserts a NULL-pad to preserve the original length of the
strings.</p>
</dd>
</li>
<dt><strong><a name="item__bak">$bak</a></strong>

<dd>
<p>The extension to use when storing backup files.</p>
</dd>
</li>
<dt><strong><a name="item__are_binary">$are_binary</a></strong>

<dd>
<p>A boolean: if true, the files are edited with binary semantics: the
filehandles are set to binmode, and strings are NULL-padded. Otherwise
a plain-old substitution occurs.</p>
</dd>
</li>
<dt><strong><a name="item__files">@files</a></strong>

<dd>
<p>A list of files to edit.</p>
</dd>
</li>
</dl>
<dt><strong><a name="item_spongedir">spongedir( $name )</a></strong>

<dd>
<p>Returns the spongedir associated with a particular product.  The $name
is the spongedir you're interested in. It's case-insensitive.  The
following spongedirs are known:</p>
</dd>
<dl>
<dt><strong><a name="item_ppm">ppm</a></strong>

<dd>
<p>The sponge directory to be used in PPM packages.</p>
</dd>
</li>
<dt><strong><a name="item_thisperl">thisperl</a></strong>

<dd>
<p>The original directory in which this copy of Perl was built. This allows
<a href="#item_relocate"><code>relocate()</code></a> to detect when a replacement path will not fit into the binary.</p>
</dd>
</li>
</dl>
</dl>
<p>
</p>
<hr />
<h1><a name="see_also">SEE ALSO</a></h1>
<p><a href="../../bin/reloc_perl.html">the reloc_perl manpage</a></p>
<p>
</p>
<hr />
<h1><a name="copyright">COPYRIGHT</a></h1>
<p>Copyright 2002 ActiveState Software Inc.  All Rights Reserved.</p>

</body>

</html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?