1SVK::Util(3)          User Contributed Perl Documentation         SVK::Util(3)
2
3
4

NAME

6       SVK::Util - Utility functions for SVK classes
7

SYNOPSIS

9           use SVK::Util qw( func1 func2 func3 )
10

DESCRIPTION

12       This is yet another abstraction function set for portable file, buffer
13       and IO handling, tailored to SVK's specific needs.
14
15       No symbols are exported by default; the user module needs to specify
16       the list of functions to import.
17

CONSTANTS

19   Constant Functions
20       IS_WIN32
21
22       Boolean flag to indicate whether this system is running Microsoft
23       Windows.
24
25       DEFAULT_EDITOR
26
27       The default program to invoke for editing buffers: "notepad.exe" on
28       Win32, "vi" otherwise.
29
30       TEXT_MODE
31
32       The I/O layer for text files: ":crlf" on Win32, empty otherwise.
33
34       HAS_SYMLINK
35
36       Boolean flag to indicate whether this system supports "symlink()".
37
38       HAS_SVN_MIRROR
39
40       Boolean flag to indicate whether we can successfully load SVN::Mirror.
41
42   Constant Scalars
43       $SEP
44
45       Native path separator: platform: "\" on dosish platforms, "/"
46       otherwise.
47
48       $EOL
49
50       End of line marker: "\015\012" on Win32, "\012" otherwise.
51

FUNCTIONS

53   User Interactivity
54       get_prompt ($prompt, $pattern)
55
56       Repeatedly prompt the user for a line of answer, until it matches the
57       regular expression pattern.  Returns the chomped answer line.
58
59       edit_file ($file_name)
60
61       Launch editor to edit a file.
62
63       get_buffer_from_editor ($what, $sep, $content, $filename, $anchor,
64       $targets_ref)
65
66       XXX Undocumented
67
68       get_encoding
69
70       Get the current encoding from locale
71
72       get_encoder ([$encoding])
73
74       from_native ($octets, $what, [$encoding])
75
76       to_native ($octets, $what, [$encoding])
77
78   File Content Manipulation
79       read_file ($filename)
80
81       Read from a file and returns its content as a single scalar.
82
83       write_file ($filename, $content)
84
85       Write out content to a file, overwriting existing content if present.
86
87       slurp_fh ($input_fh, $output_fh)
88
89       Read all data from the input filehandle and write them to the output
90       filehandle.  The input may also be a scalar, or reference to a scalar.
91
92       md5_fh ($input_fh)
93
94       Calculate MD5 checksum for data in the input filehandle.
95
96       mimetype ($file)
97
98       Return the MIME type for the file, or "undef" if the MIME database is
99       missing on the system.
100
101       mimetype_is_text ($mimetype)
102
103       Return whether a MIME type string looks like a text file.
104
105       is_binary_file ($filename OR $filehandle)
106
107       Returns true if the given file or filehandle contains binary data.
108       Otherwise, returns false.
109
110   Path and Filename Handling
111       abspath ($path)
112
113       Return paths with components in symlink resolved, but keep the final
114       path even if it's symlink.  Returns "undef" if the base directory does
115       not exist.
116
117       abs_path_noexist ($path)
118
119       Return paths with components in symlink resolved, but keep the final
120       path even if it's symlink.  Unlike abs_path(), returns a valid value
121       even if the base directory doesn't exist.
122
123       abs2rel ($pathname, $old_basedir, $new_basedir, $sep)
124
125       Replace the base directory in the native pathname to another base
126       directory and return the result.
127
128       If the pathname is not under $old_basedir, it is returned unmodified.
129
130       If $new_basedir is an empty string, removes the old base directory but
131       keeps the leading slash.  If $new_basedir is "undef", also removes the
132       leading slash.
133
134       By default, the return value of this function will use $SEP as its path
135       separator.  Setting $sep to "/" will turn native path separators into
136       "/" instead.
137
138       catdir (@directories)
139
140       Concatenate directory names to form a complete path; also removes the
141       trailing slash from the resulting string, unless it is the root
142       directory.
143
144       catfile (@directories, $pathname)
145
146       Concatenate one or more directory names and a filename to form a
147       complete path, ending with a filename.  If $pathname contains
148       directories, they will be splitted off to the end of @directories.
149
150       catpath ($volume, $directory, $filename)
151
152       XXX Undocumented - See File::Spec
153
154       devnull ()
155
156       Return a file name suitable for reading, and guaranteed to be empty.
157
158       get_anchor ($need_target, @paths)
159
160       Returns the (anchor, target) pairs for native path @paths.  Discard the
161       targets being returned unless $need_target.
162
163       get_depot_anchor ($need_target, @paths)
164
165       Returns the (anchor, target) pairs for depotpaths @paths.  Discard the
166       targets being returned unless $need_target.
167
168       catdepot ($depot_name, @paths)
169
170       make_path ($path)
171
172       Create a directory, and intermediate directories as required.
173
174       splitpath ($path)
175
176       Splits a path in to volume, directory, and filename portions.  On
177       systems with no concept of volume, returns an empty string for volume.
178
179       splitdir ($path)
180
181       The opposite of "catdir()"; return a list of path components.
182
183       tmpdir ()
184
185       Return the name of the first writable directory from a list of possible
186       temporary directories.
187
188       tmpfile (TEXT => $is_textmode, %args)
189
190       In scalar context, return the filehandle of a temporary file.  In list
191       context, return the filehandle and the filename.
192
193       If $is_textmode is true, the returned file handle is marked with
194       "TEXT_MODE".
195
196       See File::Temp for valid keys of %args.
197
198       is_symlink ($filename)
199
200       Return whether a file is a symbolic link, as determined by "-l".  If
201       $filename is not specified, return "-l _" instead.
202
203       is_executable ($filename)
204
205       Return whether a file is likely to be an executable file.  Unlike
206       "is_symlink()", the $filename argument is not optional.
207
208       can_run ($filename)
209
210       Check if we can run some command.
211
212       is_uri ($string)
213
214       Check if a string is a valid URI.
215
216       move_path ($source, $target)
217
218       Move a path to another place, creating intermediate directories in the
219       target path if neccessary.  If move failed, tell the user to move it
220       manually.
221
222       traverse_history (root => $fs_root, path => $path, cross => $cross,
223       callback => $cb($path, $revision))
224
225       Traverse the history of $path in $fs_root backwards until the first
226       copy, unless $cross is true.  We do cross renames regardless of the
227       value of $cross being non-zero, but not -1.  We invoke $cb for each
228       $path, $revision we encounter.  If cb returns a nonzero value we stop
229       traversing as well.
230
231       is_path_inside($path, $parent)
232
233       Returns true if unix path $path is inside $parent.  If they are the
234       same, return true as well.
235
236       uri_escape($uri)
237
238       Returns escaped URI.
239
240       uri_unescape($uri)
241
242       Unescape escaped URI and return it.
243
244       is_depotpath($path)
245
246       Check if a string is a valid depotpath.
247
248
249
250perl v5.28.0                      2009-12-21                      SVK::Util(3)
Impressum