Subversion
Loading...
Searching...
No Matches
svn_io.h
Go to the documentation of this file.
1/**
2 * @copyright
3 * ====================================================================
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
19 * under the License.
20 * ====================================================================
21 * @endcopyright
22 *
23 * @file svn_io.h
24 * @brief General file I/O for Subversion
25 */
26
27/* ==================================================================== */
28
29
30#ifndef SVN_IO_H
31#define SVN_IO_H
32
33#include <apr.h>
34#include <apr_pools.h>
35#include <apr_time.h>
36#include <apr_hash.h>
37#include <apr_tables.h>
38#include <apr_file_io.h>
39#include <apr_file_info.h>
40#include <apr_thread_proc.h> /* for apr_proc_t, apr_exit_why_e */
41
42#include "svn_types.h"
43#include "svn_string.h"
44#include "svn_checksum.h"
45
46#ifdef __cplusplus
47extern "C" {
48#endif /* __cplusplus */
49
50
51␌
52/** Used as an argument when creating temporary files to indicate
53 * when a file should be removed.
54 *
55 * @since New in 1.4.
56 *
57 * Not specifying any of these means no removal at all. */
59{
60 /** No deletion ever */
62 /** Remove when the file is closed */
64 /** Remove when the associated pool is cleared */
67
68/** A set of directory entry data elements as returned by svn_io_get_dirents
69 *
70 * Note that the first two fields are exactly identical to svn_io_dirent_t
71 * to allow returning a svn_io_dirent2_t as a svn_io_dirent_t.
72 *
73 * Use svn_io_dirent2_create() to create new svn_dirent2_t instances or
74 * svn_io_dirent2_dup() to duplicate an existing instance.
75 *
76 * @since New in 1.7.
77 */
78typedef struct svn_io_dirent2_t {
79 /* New fields must be added at the end to preserve binary compatibility */
80
81 /** The kind of this entry. */
83
84 /** If @c kind is #svn_node_file, whether this entry is a special file;
85 * else FALSE.
86 *
87 * @see svn_io_check_special_path().
88 */
90
91 /** The filesize of this entry or undefined for a directory */
93
94 /** The time the file was last modified */
95 apr_time_t mtime;
96
97 /* Don't forget to update svn_io_dirent2_dup() when adding new fields */
99
100
101/** Creates a new #svn_io_dirent2_t structure
102 *
103 * @since New in 1.7.
104 */
106svn_io_dirent2_create(apr_pool_t *result_pool);
107
108/** Duplicates a @c svn_io_dirent2_t structure into @a result_pool.
109 *
110 * @since New in 1.7.
111 */
114 apr_pool_t *result_pool);
115
116/** Represents the kind and special status of a directory entry.
117 *
118 * Note that the first two fields are exactly identical to svn_io_dirent2_t
119 * to allow returning a svn_io_dirent2_t as a svn_io_dirent_t.
120 *
121 * @since New in 1.3.
122 */
123typedef struct svn_io_dirent_t {
124 /** The kind of this entry. */
126 /** If @c kind is #svn_node_file, whether this entry is a special file;
127 * else FALSE.
128 *
129 * @see svn_io_check_special_path().
130 */
133
134/** Determine the @a kind of @a path. @a path should be UTF-8 encoded.
135 *
136 * If @a path is a file, set @a *kind to #svn_node_file.
137 *
138 * If @a path is a directory, set @a *kind to #svn_node_dir.
139 *
140 * If @a path does not exist, set @a *kind to #svn_node_none.
141 *
142 * If @a path exists but is none of the above, set @a *kind to
143 * #svn_node_unknown.
144 *
145 * If @a path is not a valid pathname, set @a *kind to #svn_node_none. If
146 * unable to determine @a path's kind for any other reason, return an error,
147 * with @a *kind's value undefined.
148 *
149 * Use @a pool for temporary allocations.
150 *
151 * @see svn_node_kind_t
152 */
156 apr_pool_t *pool);
157
158/**
159 * Like svn_io_check_path(), but also set *is_special to @c TRUE if
160 * the path is not a normal file.
161 *
162 * @since New in 1.1.
163 */
167 svn_boolean_t *is_special,
168 apr_pool_t *pool);
169
170/** Like svn_io_check_path(), but resolve symlinks. This returns the
171 same varieties of @a kind as svn_io_check_path(). */
175 apr_pool_t *pool);
176
177
178/** Open a new file (for reading and writing) with a unique name based on
179 * utf-8 encoded @a filename, in the directory @a dirpath. The file handle is
180 * returned in @a *file, and the name, which ends with @a suffix, is returned
181 * in @a *unique_name, also utf8-encoded. Either @a file or @a unique_name
182 * may be @c NULL. If @a file is @c NULL, the file will be created but not
183 * open.
184 *
185 * The file will be deleted according to @a delete_when. If that is
186 * #svn_io_file_del_on_pool_cleanup, it refers to @a result_pool.
187 *
188 * The @c APR_BUFFERED flag will always be used when opening the file.
189 *
190 * The first attempt will just append @a suffix. If the result is not
191 * a unique name, then subsequent attempts will append a dot,
192 * followed by an iteration number ("2", then "3", and so on),
193 * followed by the suffix. For example, successive calls to
194 *
195 * svn_io_open_uniquely_named(&f, &u, "tests/t1/A/D/G", "pi", ".tmp", ...)
196 *
197 * will open
198 *
199 * tests/t1/A/D/G/pi.tmp
200 * tests/t1/A/D/G/pi.2.tmp
201 * tests/t1/A/D/G/pi.3.tmp
202 * tests/t1/A/D/G/pi.4.tmp
203 * tests/t1/A/D/G/pi.5.tmp
204 * ...
205 *
206 * Assuming @a suffix is non-empty, @a *unique_name will never be exactly
207 * the same as @a filename, even if @a filename does not exist.
208 *
209 * If @a dirpath is NULL, then the directory returned by svn_io_temp_dir()
210 * will be used.
211 *
212 * If @a filename is NULL, then "tempfile" will be used.
213 *
214 * If @a suffix is NULL, then ".tmp" will be used.
215 *
216 * Allocates @a *file and @a *unique_name in @a result_pool. All
217 * intermediate allocations will be performed in @a scratch_pool.
218 *
219 * If no unique name can be found, #SVN_ERR_IO_UNIQUE_NAMES_EXHAUSTED is
220 * the error returned.
221 *
222 * Claim of Historical Inevitability: this function was written
223 * because
224 *
225 * - tmpnam() is not thread-safe.
226 * - tempname() tries standard system tmp areas first.
227 *
228 * @since New in 1.6
229 */
232 const char **unique_name,
233 const char *dirpath,
234 const char *filename,
235 const char *suffix,
236 svn_io_file_del_t delete_when,
237 apr_pool_t *result_pool,
238 apr_pool_t *scratch_pool);
239
240
241/** Create a writable file, with an arbitrary and unique name, in the
242 * directory @a dirpath. Set @a *temp_path to its full path, and set
243 * @a *file to the file handle, both allocated from @a result_pool. Either
244 * @a file or @a temp_path may be @c NULL. If @a file is @c NULL, the file
245 * will be created but not open.
246 *
247 * If @a dirpath is @c NULL, use the path returned from svn_io_temp_dir().
248 * (Note that when using the system-provided temp directory, it may not
249 * be possible to atomically rename the resulting file due to cross-device
250 * issues.)
251 *
252 * The file will be deleted according to @a delete_when. If that is
253 * #svn_io_file_del_on_pool_cleanup, it refers to @a result_pool. If it
254 * is #svn_io_file_del_on_close and @a file is @c NULL, the file will be
255 * deleted before this function returns.
256 *
257 * When passing @c svn_io_file_del_none please don't forget to eventually
258 * remove the temporary file to avoid filling up the system temp directory.
259 * It is often appropriate to bind the lifetime of the temporary file to
260 * the lifetime of a pool by using @c svn_io_file_del_on_pool_cleanup.
261 *
262 * Temporary allocations will be performed in @a scratch_pool.
263 *
264 * @since New in 1.6
265 * @see svn_stream_open_unique()
266 */
268svn_io_open_unique_file3(apr_file_t **file,
269 const char **temp_path,
270 const char *dirpath,
271 svn_io_file_del_t delete_when,
272 apr_pool_t *result_pool,
273 apr_pool_t *scratch_pool);
274
275
276/** Like svn_io_open_uniquely_named(), but takes a joined dirpath and
277 * filename, and a single pool.
278 *
279 * @since New in 1.4
280 *
281 * @deprecated Provided for backward compatibility with the 1.5 API
282 */
286 const char **unique_name_p,
287 const char *path,
288 const char *suffix,
289 svn_io_file_del_t delete_when,
290 apr_pool_t *pool);
291
292/** Like svn_io_open_unique_file2, but can't delete on pool cleanup.
293 *
294 * @deprecated Provided for backward compatibility with the 1.3 API
295 *
296 * @note In 1.4 the API was extended to require either @a f or
297 * @a unique_name_p (the other can be NULL). Before that, both were
298 * required.
299 */
303 const char **unique_name_p,
304 const char *path,
305 const char *suffix,
306 svn_boolean_t delete_on_close,
307 apr_pool_t *pool);
308
309
310/**
311 * Like svn_io_open_unique_file(), except that instead of creating a
312 * file, a symlink is generated that references the path @a dest.
313 *
314 * @since New in 1.1.
315 */
317svn_io_create_unique_link(const char **unique_name_p,
318 const char *path,
319 const char *dest,
320 const char *suffix,
321 apr_pool_t *pool);
322
323
324/**
325 * Set @a *dest to the path that the symlink at @a path references.
326 * Allocate the string from @a pool.
327 *
328 * @since New in 1.1.
329 */
332 const char *path,
333 apr_pool_t *pool);
334
335
336/** Set @a *dir to a directory path (allocated in @a pool) deemed
337 * usable for the creation of temporary files and subdirectories.
338 */
340svn_io_temp_dir(const char **dir,
341 apr_pool_t *pool);
342
343
344/** Copy @a src to @a dst atomically, in a "byte-for-byte" manner.
345 * Overwrite @a dst if it exists, else create it. Both @a src and @a dst
346 * are utf8-encoded filenames. If @a copy_perms is TRUE, set @a dst's
347 * permissions to match those of @a src.
348 */
350svn_io_copy_file(const char *src,
351 const char *dst,
352 svn_boolean_t copy_perms,
353 apr_pool_t *pool);
354
355
356/** Copy permission flags from @a src onto the file at @a dst. Both
357 * filenames are utf8-encoded filenames.
358 *
359 * @since New in 1.6.
360 */
362svn_io_copy_perms(const char *src,
363 const char *dst,
364 apr_pool_t *pool);
365
366
367/**
368 * Copy symbolic link @a src to @a dst atomically. Overwrite @a dst
369 * if it exists, else create it. Both @a src and @a dst are
370 * utf8-encoded filenames. After copying, the @a dst link will point
371 * to the same thing @a src does.
372 *
373 * @since New in 1.1.
374 */
376svn_io_copy_link(const char *src,
377 const char *dst,
378 apr_pool_t *pool);
379
380
381/** Recursively copy directory @a src into @a dst_parent, as a new entry named
382 * @a dst_basename. If @a dst_basename already exists in @a dst_parent,
383 * return error. @a copy_perms will be passed through to svn_io_copy_file()
384 * when any files are copied. @a src, @a dst_parent, and @a dst_basename are
385 * all utf8-encoded.
386 *
387 * If @a cancel_func is non-NULL, invoke it with @a cancel_baton at
388 * various points during the operation. If it returns any error
389 * (typically #SVN_ERR_CANCELLED), return that error immediately.
390 */
393 const char *dst_parent,
394 const char *dst_basename,
395 svn_boolean_t copy_perms,
396 svn_cancel_func_t cancel_func,
397 void *cancel_baton,
398 apr_pool_t *pool);
399
400
401/** Create directory @a path on the file system, creating intermediate
402 * directories as required, like <tt>mkdir -p</tt>. Report no error if @a
403 * path already exists. @a path is utf8-encoded.
404 *
405 * This is essentially a wrapper for apr_dir_make_recursive(), passing
406 * @c APR_OS_DEFAULT as the permissions.
407 */
410 apr_pool_t *pool);
411
412
413/** Set @a *is_empty_p to @c TRUE if directory @a path is empty, else to
414 * @c FALSE if it is not empty. @a path must be a directory, and is
415 * utf8-encoded. Use @a pool for temporary allocation.
416 */
419 const char *path,
420 apr_pool_t *pool);
421
422
423/** Append @a src to @a dst. @a dst will be appended to if it exists, else it
424 * will be created. Both @a src and @a dst are utf8-encoded.
425 */
427svn_io_append_file(const char *src,
428 const char *dst,
429 apr_pool_t *pool);
430
431
432/** Make a file as read-only as the operating system allows.
433 * @a path is the utf8-encoded path to the file. If @a ignore_enoent is
434 * @c TRUE, don't fail if the target file doesn't exist.
435 *
436 * If @a path is a symlink, do nothing.
437 *
438 * @note If @a path is a directory, act on it as though it were a
439 * file, as described above, but note that you probably don't want to
440 * call this function on directories. We have left it effective on
441 * directories for compatibility reasons, but as its name implies, it
442 * should be used only for files.
443 */
446 svn_boolean_t ignore_enoent,
447 apr_pool_t *pool);
448
449
450/** Make a file as writable as the operating system allows.
451 * @a path is the utf8-encoded path to the file. If @a ignore_enoent is
452 * @c TRUE, don't fail if the target file doesn't exist.
453 * @warning On Unix this function will do the equivalent of chmod a+w path.
454 * If this is not what you want you should not use this function, but rather
455 * use apr_file_perms_set().
456 *
457 * If @a path is a symlink, do nothing.
458 *
459 * @note If @a path is a directory, act on it as though it were a
460 * file, as described above, but note that you probably don't want to
461 * call this function on directories. We have left it effective on
462 * directories for compatibility reasons, but as its name implies, it
463 * should be used only for files.
464 */
467 svn_boolean_t ignore_enoent,
468 apr_pool_t *pool);
469
470
471/** Similar to svn_io_set_file_read_* functions.
472 * Change the read-write permissions of a file.
473 * @since New in 1.1.
474 *
475 * When making @a path read-write on operating systems with unix style
476 * permissions, set the permissions on @a path to the permissions that
477 * are set when a new file is created (effectively honoring the user's
478 * umask).
479 *
480 * When making the file read-only on operating systems with unix style
481 * permissions, remove all write permissions.
482 *
483 * On other operating systems, toggle the file's "writability" as much as
484 * the operating system allows.
485 *
486 * @a path is the utf8-encoded path to the file. If @a enable_write
487 * is @c TRUE, then make the file read-write. If @c FALSE, make it
488 * read-only. If @a ignore_enoent is @c TRUE, don't fail if the target
489 * file doesn't exist.
490 *
491 * @deprecated Provided for backward compatibility with the 1.3 API.
492 */
496 svn_boolean_t enable_write,
497 svn_boolean_t ignore_enoent,
498 apr_pool_t *pool);
499
500/** Set @a path's "executability" (but do nothing if it is a symlink).
501 *
502 * @a path is the utf8-encoded path to the file. If @a executable
503 * is @c TRUE, then make the file executable. If @c FALSE, make it
504 * non-executable. If @a ignore_enoent is @c TRUE, don't fail if the target
505 * file doesn't exist.
506 *
507 * When making the file executable on operating systems with unix style
508 * permissions, never add an execute permission where there is not
509 * already a read permission: that is, only make the file executable
510 * for the user, group or world if the corresponding read permission
511 * is already set for user, group or world.
512 *
513 * When making the file non-executable on operating systems with unix style
514 * permissions, remove all execute permissions.
515 *
516 * On other operating systems, toggle the file's "executability" as much as
517 * the operating system allows.
518 *
519 * @note If @a path is a directory, act on it as though it were a
520 * file, as described above, but note that you probably don't want to
521 * call this function on directories. We have left it effective on
522 * directories for compatibility reasons, but as its name implies, it
523 * should be used only for files.
524 */
527 svn_boolean_t executable,
528 svn_boolean_t ignore_enoent,
529 apr_pool_t *pool);
530
531/** Determine whether a file is executable by the current user.
532 * Set @a *executable to @c TRUE if the file @a path is executable by the
533 * current user, otherwise set it to @c FALSE.
534 *
535 * On Windows and on platforms without userids, always returns @c FALSE.
536 */
539 const char *path,
540 apr_pool_t *pool);
541
542
543/** Read a line from @a file into @a buf, but not exceeding @a *limit bytes.
544 * Does not include newline, instead '\\0' is put there.
545 * Length (as in strlen) is returned in @a *limit.
546 * @a buf should be pre-allocated.
547 * @a file should be already opened.
548 *
549 * When the file is out of lines, @c APR_EOF will be returned.
550 */
552svn_io_read_length_line(apr_file_t *file,
553 char *buf,
554 apr_size_t *limit,
555 apr_pool_t *pool);
556
557
558/** Set @a *apr_time to the time of last modification of the contents of the
559 * file @a path. @a path is utf8-encoded.
560 *
561 * @note This is the APR mtime which corresponds to the traditional mtime
562 * on Unix, and the last write time on Windows.
563 */
565svn_io_file_affected_time(apr_time_t *apr_time,
566 const char *path,
567 apr_pool_t *pool);
568
569/** Set the timestamp of file @a path to @a apr_time. @a path is
570 * utf8-encoded.
571 *
572 * @note This is the APR mtime which corresponds to the traditional mtime
573 * on Unix, and the last write time on Windows.
574 */
577 const char *path,
578 apr_pool_t *pool);
579
580/** Sleep to ensure that any files modified after we exit have a different
581 * timestamp than the one we recorded. If @a path is not NULL, check if we
582 * can determine how long we should wait for a new timestamp on the filesystem
583 * containing @a path, an existing file or directory. If @a path is NULL or we
584 * can't determine the timestamp resolution, sleep until the next second.
585 *
586 * Use @a pool for any necessary allocations. @a pool can be null if @a path
587 * is NULL.
588 *
589 * Errors while retrieving the timestamp resolution will result in sleeping
590 * to the next second, to keep the working copy stable in error conditions.
591 *
592 * @since New in 1.6.
593 */
594void
595svn_io_sleep_for_timestamps(const char *path, apr_pool_t *pool);
596
597/** Set @a *different_p to TRUE if @a file1 and @a file2 have different
598 * sizes, else set to FALSE. Both @a file1 and @a file2 are utf8-encoded.
599 *
600 * Setting @a *different_p to zero does not mean the files definitely
601 * have the same size, it merely means that the sizes are not
602 * definitely different. That is, if the size of one or both files
603 * cannot be determined, then the sizes are not known to be different,
604 * so @a *different_p is set to FALSE.
605 */
608 const char *file1,
609 const char *file2,
610 apr_pool_t *pool);
611
612/** Set @a *different_p12 to non-zero if @a file1 and @a file2 have different
613 * sizes, else set to zero. Do the similar for @a *different_p23 with
614 * @a file2 and @a file3, and @a *different_p13 for @a file1 and @a file3.
615 * The filenames @a file1, @a file2 and @a file3 are utf8-encoded.
616 *
617 * Setting @a *different_p12 to zero does not mean the files definitely
618 * have the same size, it merely means that the sizes are not
619 * definitely different. That is, if the size of one or both files
620 * cannot be determined (due to stat() returning an error), then the sizes
621 * are not known to be different, so @a *different_p12 is set to 0.
622 *
623 * @since New in 1.8.
624 */
627 svn_boolean_t *different_p23,
628 svn_boolean_t *different_p13,
629 const char *file1,
630 const char *file2,
631 const char *file3,
632 apr_pool_t *scratch_pool);
633
634/** Return in @a *checksum the checksum of type @a kind of @a file
635 * Use @a pool for temporary allocations and to allocate @a *checksum.
636 *
637 * @since New in 1.6.
638 */
641 const char *file,
643 apr_pool_t *pool);
644
645
646/** Put the md5 checksum of @a file into @a digest.
647 * @a digest points to @c APR_MD5_DIGESTSIZE bytes of storage.
648 * Use @a pool only for temporary allocations.
649 *
650 * @deprecated Provided for backward compatibility with the 1.5 API.
651 */
654svn_io_file_checksum(unsigned char digest[],
655 const char *file,
656 apr_pool_t *pool);
657
658
659/** Set @a *same to TRUE if @a file1 and @a file2 have the same
660 * contents, else set it to FALSE. Use @a pool for temporary allocations.
661 */
664 const char *file1,
665 const char *file2,
666 apr_pool_t *pool);
667
668/** Set @a *same12 to TRUE if @a file1 and @a file2 have the same
669 * contents, else set it to FALSE. Do the similar for @a *same23
670 * with @a file2 and @a file3, and @a *same13 for @a file1 and @a
671 * file3. The filenames @a file1, @a file2 and @a file3 are
672 * utf8-encoded. Use @a scratch_pool for temporary allocations.
673 *
674 * @since New in 1.8.
675 */
678 svn_boolean_t *same23,
679 svn_boolean_t *same13,
680 const char *file1,
681 const char *file2,
682 const char *file3,
683 apr_pool_t *scratch_pool);
684
685/** Create a file at utf8-encoded path @a file with the contents given
686 * by the null-terminated string @a contents.
687 *
688 * @a file must not already exist. If an error occurs while writing or
689 * closing the file, attempt to delete the file before returning the error.
690 *
691 * Write the data in 'binary' mode (#APR_FOPEN_BINARY). If @a contents
692 * is @c NULL, create an empty file.
693 *
694 * Use @a pool for memory allocations.
695 */
697svn_io_file_create(const char *file,
698 const char *contents,
699 apr_pool_t *pool);
700
701/** Create a file at utf8-encoded path @a file with the contents given
702 * by @a contents of @a length bytes.
703 *
704 * @a file must not already exist. If an error occurs while writing or
705 * closing the file, attempt to delete the file before returning the error.
706 *
707 * Write the data in 'binary' mode (#APR_FOPEN_BINARY). If @a length is
708 * zero, create an empty file; in this case @a contents may be @c NULL.
709 *
710 * Use @a scratch_pool for temporary allocations.
711 *
712 * @since New in 1.9.
713 */
716 const void *contents,
717 apr_size_t length,
718 apr_pool_t *scratch_pool);
719
720/** Create an empty file at utf8-encoded path @a file.
721 *
722 * @a file must not already exist. If an error occurs while
723 * closing the file, attempt to delete the file before returning the error.
724 *
725 * Use @a scratch_pool for temporary allocations.
726 *
727 * @since New in 1.9.
728 */
731 apr_pool_t *scratch_pool);
732
733/**
734 * Lock file at @a lock_file. If @a exclusive is TRUE,
735 * obtain exclusive lock, otherwise obtain shared lock.
736 * Lock will be automatically released when @a pool is cleared or destroyed.
737 * Use @a pool for memory allocations.
738 *
739 * @deprecated Provided for backward compatibility with the 1.0 API.
740 */
743svn_io_file_lock(const char *lock_file,
744 svn_boolean_t exclusive,
745 apr_pool_t *pool);
746
747/**
748 * Lock file at @a lock_file. If @a exclusive is TRUE,
749 * obtain exclusive lock, otherwise obtain shared lock.
750 *
751 * If @a nonblocking is TRUE, do not wait for the lock if it
752 * is not available: throw an error instead.
753 *
754 * Lock will be automatically released when @a pool is cleared or destroyed.
755 * Use @a pool for memory allocations.
756 *
757 * @since New in 1.1.
758 */
760svn_io_file_lock2(const char *lock_file,
761 svn_boolean_t exclusive,
762 svn_boolean_t nonblocking,
763 apr_pool_t *pool);
764
765/**
766 * Lock the file @a lockfile_handle. If @a exclusive is TRUE,
767 * obtain exclusive lock, otherwise obtain shared lock.
768 *
769 * If @a nonblocking is TRUE, do not wait for the lock if it
770 * is not available: throw an error instead.
771 *
772 * Lock will be automatically released when @a pool is cleared or destroyed.
773 * You may also explicitly call svn_io_unlock_open_file().
774 * Use @a pool for memory allocations. @a pool must be the pool that
775 * @a lockfile_handle has been created in or one of its sub-pools.
776 *
777 * @since New in 1.8.
778 */
780svn_io_lock_open_file(apr_file_t *lockfile_handle,
781 svn_boolean_t exclusive,
782 svn_boolean_t nonblocking,
783 apr_pool_t *pool);
784
785/**
786 * Unlock the file @a lockfile_handle.
787 *
788 * Use @a pool for memory allocations. @a pool must be the pool that
789 * was passed to svn_io_lock_open_file().
790 *
791 * @since New in 1.8.
792 */
794svn_io_unlock_open_file(apr_file_t *lockfile_handle,
795 apr_pool_t *pool);
796
797/**
798 * Flush any unwritten data from @a file to disk. Use @a pool for
799 * memory allocations.
800 *
801 * @note This function uses advanced file control operations to flush buffers
802 * to disk that aren't always accessible and can be very expensive on systems
803 * that implement flushing on all IO layers, like Windows. Please avoid using
804 * this function in cases where the file should just work on any network
805 * filesystem. In many cases a normal svn_io_file_flush() will work just fine.
806 *
807 * @since New in 1.1.
808 */
811 apr_pool_t *pool);
812
813/** Copy the file whose basename (or relative path) is @a file within
814 * directory @a src_path to the same basename (or relative path) within
815 * directory @a dest_path. Overwrite the destination file if it already
816 * exists. The destination directory (including any directory
817 * components in @a name) must already exist. Set the destination
818 * file's permissions to match those of the source. Use @a pool for
819 * memory allocations.
820 */
822svn_io_dir_file_copy(const char *src_path,
823 const char *dest_path,
824 const char *file,
825 apr_pool_t *pool);
826
827␌
828/** Generic byte-streams
829 *
830 * @defgroup svn_io_byte_streams Generic byte streams
831 * @{
832 */
833
834/** An abstract stream of bytes--either incoming or outgoing or both.
835 *
836 * The creator of a stream sets functions to handle read and write.
837 * Both of these handlers accept a baton whose value is determined at
838 * stream creation time; this baton can point to a structure
839 * containing data associated with the stream. If a caller attempts
840 * to invoke a handler which has not been set, it will generate a
841 * runtime assertion failure. The creator can also set a handler for
842 * close requests so that it can flush buffered data or whatever;
843 * if a close handler is not specified, a close request on the stream
844 * will simply be ignored. Note that svn_stream_close() does not
845 * deallocate the memory used to allocate the stream structure; free
846 * the pool you created the stream in to free that memory.
847 *
848 * The read and write handlers accept length arguments via pointer.
849 * On entry to the handler, the pointed-to value should be the amount
850 * of data which can be read or the amount of data to write. When the
851 * handler returns, the value is reset to the amount of data actually
852 * read or written. The write and full read handler are obliged to
853 * complete a read or write to the maximum extent possible; thus, a
854 * short read with no associated error implies the end of the input
855 * stream, and a short write should never occur without an associated
856 * error. In Subversion 1.9 the stream api was extended to also support
857 * limited reads via the new svn_stream_read2() api.
858 *
859 * In Subversion 1.7 mark, seek and reset support was added as an optional
860 * feature of streams. If a stream implements resetting it allows reading
861 * the data again after a successful call to svn_stream_reset().
862 */
864
865
866
867/** Read handler function for a generic stream. @see svn_stream_t. */
868typedef svn_error_t *(*svn_read_fn_t)(void *baton,
869 char *buffer,
870 apr_size_t *len);
871
872/** Skip data handler function for a generic stream. @see svn_stream_t
873 * and svn_stream_skip().
874 * @since New in 1.7.
875 */
876typedef svn_error_t *(*svn_stream_skip_fn_t)(void *baton,
877 apr_size_t len);
878
879/** Write handler function for a generic stream. @see svn_stream_t. */
880typedef svn_error_t *(*svn_write_fn_t)(void *baton,
881 const char *data,
882 apr_size_t *len);
883
884/** Close handler function for a generic stream. @see svn_stream_t. */
885typedef svn_error_t *(*svn_close_fn_t)(void *baton);
886
887/** An opaque type which represents a mark on a stream. There is no
888 * concrete definition of this type, it is a named type for stream
889 * implementation specific baton pointers.
890 *
891 * @see svn_stream_mark().
892 * @since New in 1.7.
893 */
895
896/** Mark handler function for a generic stream. @see svn_stream_t and
897 * svn_stream_mark().
898 *
899 * @since New in 1.7.
900 */
901typedef svn_error_t *(*svn_stream_mark_fn_t)(void *baton,
902 svn_stream_mark_t **mark,
903 apr_pool_t *pool);
904
905/** Seek handler function for a generic stream. @see svn_stream_t and
906 * svn_stream_seek().
907 *
908 * @since New in 1.7.
909 */
910typedef svn_error_t *(*svn_stream_seek_fn_t)(void *baton,
911 const svn_stream_mark_t *mark);
912
913/** Poll handler for generic streams that support incomplete reads, @see
914 * svn_stream_t and svn_stream_data_available().
915 *
916 * @since New in 1.9.
917 */
918typedef svn_error_t *(*svn_stream_data_available_fn_t)(void *baton,
919 svn_boolean_t *data_available);
920
921/** Readline handler function for a generic stream. @see svn_stream_t and
922 * svn_stream_readline().
923 *
924 * @since New in 1.10.
925 */
926typedef svn_error_t *(*svn_stream_readline_fn_t)(void *baton,
927 svn_stringbuf_t **stringbuf,
928 const char *eol,
929 svn_boolean_t *eof,
930 apr_pool_t *pool);
931
932/** Create a generic stream. @see svn_stream_t. */
935 apr_pool_t *pool);
936
937/** Set @a stream's baton to @a baton */
938void
940 void *baton);
941
942/** Set @a stream's read functions to @a read_fn and @a read_full_fn. If
943 * @a read_full_fn is NULL a default implementation based on multiple calls
944 * to @a read_fn will be used.
945 *
946 * @since New in 1.9.
947 */
948void
950 svn_read_fn_t read_fn,
951 svn_read_fn_t read_full_fn);
952
953/** Set @a stream's read function to @a read_fn.
954 *
955 * This function sets only the full read function to read_fn.
956 *
957 * @deprecated Provided for backward compatibility with the 1.8 API.
958 */
960void
962 svn_read_fn_t read_fn);
963
964/** Set @a stream's skip function to @a skip_fn
965 *
966 * @since New in 1.7
967 */
968void
970 svn_stream_skip_fn_t skip_fn);
971
972/** Set @a stream's write function to @a write_fn */
973void
975 svn_write_fn_t write_fn);
976
977/** Set @a stream's close function to @a close_fn */
978void
980 svn_close_fn_t close_fn);
981
982/** Set @a stream's mark function to @a mark_fn
983 *
984 * @since New in 1.7.
985 */
986void
988 svn_stream_mark_fn_t mark_fn);
989
990/** Set @a stream's seek function to @a seek_fn
991 *
992 * @since New in 1.7.
993 */
994void
996 svn_stream_seek_fn_t seek_fn);
997
998/** Set @a stream's data available function to @a data_available_fn
999 *
1000 * @since New in 1.9.
1001 */
1002void
1004 svn_stream_data_available_fn_t data_available);
1005
1006/** Set @a stream's readline function to @a readline_fn
1007 *
1008 * @since New in 1.10.
1009 */
1010void
1012 svn_stream_readline_fn_t readline_fn);
1013
1014/** Create a stream that is empty for reading and infinite for writing. */
1016svn_stream_empty(apr_pool_t *pool);
1017
1018/** Return a stream allocated in @a pool which forwards all requests
1019 * to @a stream. Destruction is explicitly excluded from forwarding.
1020 *
1021 * @see https://subversion.apache.org/docs/community-guide/conventions.html#destruction-of-stacked-resources
1022 *
1023 * @since New in 1.4.
1024 */
1027 apr_pool_t *pool);
1028
1029
1030/** Create a stream to read the file at @a path. It will be opened using the
1031 * APR_BUFFERED flag, and APR_OS_DEFAULT for the perms. If you'd like to use
1032 * different values, then open the file yourself, and use the
1033 * svn_stream_from_aprfile2() interface.
1034 *
1035 * The stream will be returned in @a stream, and allocated from @a result_pool.
1036 * Temporary allocations will be performed in @a scratch_pool.
1037 *
1038 * @since New in 1.6
1039 */
1042 const char *path,
1043 apr_pool_t *result_pool,
1044 apr_pool_t *scratch_pool);
1045
1046
1047/** Create a stream to write a file at @a path. The file will be *created*
1048 * using the APR_BUFFERED flag, and APR_OS_DEFAULT for the perms. The file
1049 * will be created "exclusively", so if it already exists, then an error will
1050 * be thrown. If you'd like to use different values, or open an existing file,
1051 * then open the file yourself, and use the svn_stream_from_aprfile2()
1052 * interface.
1053 *
1054 * The stream will be returned in @a stream, and allocated from @a result_pool.
1055 * Temporary allocations will be performed in @a scratch_pool.
1056 *
1057 * @since New in 1.6
1058 */
1061 const char *path,
1062 apr_pool_t *result_pool,
1063 apr_pool_t *scratch_pool);
1064
1065
1066/** Create a writable stream to a file in the directory @a dirpath.
1067 * The file will have an arbitrary and unique name, and the full path
1068 * will be returned in @a temp_path. The stream will be returned in
1069 * @a stream. Both will be allocated from @a result_pool.
1070 *
1071 * If @a dirpath is @c NULL, use the path returned from svn_io_temp_dir().
1072 * (Note that when using the system-provided temp directory, it may not
1073 * be possible to atomically rename the resulting file due to cross-device
1074 * issues.)
1075 *
1076 * The file will be deleted according to @a delete_when. If that is
1077 * #svn_io_file_del_on_pool_cleanup, it refers to @a result_pool.
1078 *
1079 * Temporary allocations will be performed in @a scratch_pool.
1080 *
1081 * @since New in 1.6
1082 * @see svn_io_open_unique_file3()
1083 */
1086 const char **temp_path,
1087 const char *dirpath,
1088 svn_io_file_del_t delete_when,
1089 apr_pool_t *result_pool,
1090 apr_pool_t *scratch_pool);
1091
1092
1093/** Create a stream from an APR file. For convenience, if @a file is
1094 * @c NULL, an empty stream created by svn_stream_empty() is returned.
1095 *
1096 * This function should normally be called with @a disown set to FALSE,
1097 * in which case closing the stream will also close the underlying file.
1098 *
1099 * If @a disown is TRUE, the stream will disown the underlying file,
1100 * meaning that svn_stream_close() will not close the file.
1101 *
1102 * @since New in 1.4.
1103 */
1106 svn_boolean_t disown,
1107 apr_pool_t *pool);
1108
1109/** Similar to svn_stream_from_aprfile2(), except that the file will
1110 * always be disowned.
1111 *
1112 * @note The stream returned is not considered to "own" the underlying
1113 * file, meaning that svn_stream_close() on the stream will not
1114 * close the file.
1115 *
1116 * @deprecated Provided for backward compatibility with the 1.3 API.
1117 */
1121 apr_pool_t *pool);
1122
1123/** Set @a *in to a generic stream connected to stdin, allocated in
1124 * @a pool. If @a buffered is set, APR buffering will be enabled.
1125 * The stream and its underlying APR handle will be closed when @a pool
1126 * is cleared or destroyed.
1127 *
1128 * @note APR buffering will try to fill the whole internal buffer before
1129 * serving read requests. This may be inappropriate for interactive
1130 * applications where stdin will not deliver any more data unless
1131 * the application processed the data already received.
1132 *
1133 * @since New in 1.10.
1134 */
1137 svn_boolean_t buffered,
1138 apr_pool_t *pool);
1139
1140/** Similar to svn_stream_for_stdin2(), but with buffering being disabled.
1141 *
1142 * @since New in 1.7.
1143 *
1144 * @deprecated Provided for backward compatibility with the 1.9 API.
1145 */
1149 apr_pool_t *pool);
1150
1151/** Set @a *err to a generic stream connected to stderr, allocated in
1152 * @a pool. The stream and its underlying APR handle will be closed
1153 * when @a pool is cleared or destroyed.
1154 *
1155 * @since New in 1.7.
1156 */
1159 apr_pool_t *pool);
1160
1161/** Set @a *out to a generic stream connected to stdout, allocated in
1162 * @a pool. The stream and its underlying APR handle will be closed
1163 * when @a pool is cleared or destroyed.
1164 */
1167 apr_pool_t *pool);
1168
1169/** Read the contents of @a stream into memory, from its current position
1170 * to its end, returning the data in @a *result. This function does not
1171 * close the @a stream upon completion.
1172 *
1173 * @a len_hint gives a hint about the expected length, in bytes, of the
1174 * actual data that will be read from the stream. It may be 0, meaning no
1175 * hint is being provided. Efficiency in time and/or in space may be
1176 * better (and in general will not be worse) when the actual data length
1177 * is equal or approximately equal to the length hint.
1178 *
1179 * The returned memory is allocated in @a result_pool.
1180 *
1181 * @note The present implementation is efficient when @a len_hint is big
1182 * enough (but not vastly bigger than necessary), and also for actual
1183 * lengths up to 64 bytes when @a len_hint is 0. Otherwise it can incur
1184 * significant time and space overheads. See source code for details.
1185 *
1186 * @since New in 1.9.
1187 */
1190 svn_stream_t *stream,
1191 apr_size_t len_hint,
1192 apr_pool_t *result_pool);
1193
1194/** Return a generic stream connected to stringbuf @a str. Allocate the
1195 * stream in @a pool.
1196 */
1199 apr_pool_t *pool);
1200
1201/** Return a generic read-only stream connected to string @a str.
1202 * Allocate the stream in @a pool.
1203 */
1206 apr_pool_t *pool);
1207
1208/** Return a generic stream which implements buffered reads and writes.
1209 * The stream will preferentially store data in-memory, but may use
1210 * disk storage as backup if the amount of data is large.
1211 * Allocate the stream in @a result_pool
1212 *
1213 * @since New in 1.8.
1214 */
1216svn_stream_buffered(apr_pool_t *result_pool);
1217
1218/** Return a stream that decompresses all data read and compresses all
1219 * data written. The stream @a stream is used to read and write all
1220 * compressed data. All compression data structures are allocated on
1221 * @a pool. If compression support is not compiled in then
1222 * svn_stream_compressed() returns @a stream unmodified. Make sure you
1223 * call svn_stream_close() on the stream returned by this function,
1224 * so that all data are flushed and cleaned up.
1225 *
1226 * @note From 1.4, compression support is always compiled in.
1227 */
1230 apr_pool_t *pool);
1231
1232/** Return a stream that calculates checksums for all data read
1233 * and written. The stream @a stream is used to read and write all data.
1234 * The stream and the resulting digests are allocated in @a pool.
1235 *
1236 * When the stream is closed, @a *read_checksum and @a *write_checksum
1237 * are set to point to the resulting checksums, of type @a read_checksum_kind
1238 * and @a write_checksum_kind, respectively.
1239 *
1240 * Both @a read_checksum and @a write_checksum can be @c NULL, in which case
1241 * the respective checksum isn't calculated.
1242 *
1243 * If @a read_all is TRUE, make sure that all data available on @a
1244 * stream is read (and checksummed) when the stream is closed.
1245 *
1246 * Read and write operations can be mixed without interfering.
1247 *
1248 * The @a stream passed into this function is closed when the created
1249 * stream is closed.
1250 *
1251 * @since New in 1.6. Since 1.10, the resulting stream supports reset
1252 * via stream_stream_reset().
1253 */
1256 svn_checksum_t **read_checksum,
1257 svn_checksum_t **write_checksum,
1258 svn_checksum_kind_t checksum_kind,
1259 svn_boolean_t read_all,
1260 apr_pool_t *pool);
1261
1262/**
1263 * Similar to svn_stream_checksummed2(), but always returning the MD5
1264 * checksum in @a read_digest and @a write_digest.
1265 *
1266 * @since New in 1.4.
1267 * @deprecated Provided for backward compatibility with the 1.5 API.
1268 */
1272 const unsigned char **read_digest,
1273 const unsigned char **write_digest,
1274 svn_boolean_t read_all,
1275 apr_pool_t *pool);
1276
1277/** Read the contents of the readable stream @a stream and return its
1278 * checksum of type @a kind in @a *checksum.
1279 *
1280 * The stream will be closed before this function returns (regardless
1281 * of the result, or any possible error).
1282 *
1283 * Use @a scratch_pool for temporary allocations and @a result_pool
1284 * to allocate @a *checksum.
1285 *
1286 * @since New in 1.10.
1287 */
1290 svn_stream_t *stream,
1292 apr_pool_t *result_pool,
1293 apr_pool_t *scratch_pool);
1294
1295/** Read from a generic stream until @a buffer is filled upto @a *len or
1296 * until EOF is reached. @see svn_stream_t
1297 *
1298 * @since New in 1.9.
1299 */
1302 char *buffer,
1303 apr_size_t *len);
1304
1305
1306/** Returns @c TRUE if the generic @c stream supports svn_stream_read2().
1307 *
1308 * @since New in 1.9.
1309 */
1312
1313/** Read all currently available upto @a *len into @a buffer. Use
1314 * svn_stream_read_full() if you want to wait for the buffer to be filled
1315 * or EOF. If the stream doesn't support limited reads this function will
1316 * return an #SVN_ERR_STREAM_NOT_SUPPORTED error.
1317 *
1318 * A 0 byte read signals the end of the stream.
1319 *
1320 * @since New in 1.9.
1321 */
1324 char *buffer,
1325 apr_size_t *len);
1326
1327
1328/** Read from a generic stream until the buffer is completely filled or EOF.
1329 * @see svn_stream_t.
1330 *
1331 * @note This function is a wrapper of svn_stream_read_full() now, which name
1332 * better documents the behavior of this function.
1333 *
1334 * @deprecated Provided for backward compatibility with the 1.8 API
1335 */
1339 char *buffer,
1340 apr_size_t *len);
1341
1342/**
1343 * Skip @a len bytes from a generic @a stream. If the stream is exhausted
1344 * before @a len bytes have been read, return an error.
1345 *
1346 * @note No assumption can be made on the semantics of this function
1347 * other than that the stream read pointer will be advanced by *len
1348 * bytes. Depending on the capabilities of the underlying stream
1349 * implementation, this may for instance be translated into a sequence
1350 * of reads or a simple seek operation. If the stream implementation has
1351 * not provided a skip function, this will read from the stream and
1352 * discard the data.
1353 *
1354 * @since New in 1.7.
1355 */
1358 apr_size_t len);
1359
1360/** Write to a generic stream. @see svn_stream_t. */
1363 const char *data,
1364 apr_size_t *len);
1365
1366/** Close a generic stream. @see svn_stream_t. */
1369
1370/** Reset a generic stream back to its origin. (E.g. On a file this would be
1371 * implemented as a seek to position 0). This function returns a
1372 * #SVN_ERR_STREAM_SEEK_NOT_SUPPORTED error when the stream doesn't
1373 * implement resetting.
1374 *
1375 * @since New in 1.7.
1376 */
1379
1380/** Returns @c TRUE if the generic @a stream supports svn_stream_mark().
1381 *
1382 * @see svn_stream_mark()
1383 * @since New in 1.7.
1384 */
1387
1388/** Returns @c TRUE if the generic @a stream supports svn_stream_seek().
1389 *
1390 * @see svn_stream_seek()
1391 * @since New in 1.15.
1392 */
1395
1396/** Returns @c TRUE if the generic @a stream supports svn_stream_reset().
1397 *
1398 * @see svn_stream_reset()
1399 * @since New in 1.10.
1400 */
1403
1404/** Set a @a mark at the current position of a generic @a stream,
1405 * which can later be sought back to using svn_stream_seek().
1406 * The @a mark is allocated in @a pool.
1407 *
1408 * This function returns the #SVN_ERR_STREAM_SEEK_NOT_SUPPORTED error
1409 * if the stream doesn't implement seeking.
1410 *
1411 * @see svn_stream_seek()
1412 * @since New in 1.7.
1413 */
1416 svn_stream_mark_t **mark,
1417 apr_pool_t *pool);
1418
1419/** Seek to a @a mark in a generic @a stream.
1420 * This function returns the #SVN_ERR_STREAM_SEEK_NOT_SUPPORTED error
1421 * if the stream doesn't implement seeking. Passing NULL as @a mark,
1422 * seeks to the start of the stream.
1423 *
1424 * @see svn_stream_mark()
1425 * @since New in 1.7.
1426 */
1429
1430/** When a stream supports polling for available data, obtain a boolean
1431 * indicating whether data is waiting to be read. If the stream doesn't
1432 * support polling this function returns a #SVN_ERR_STREAM_NOT_SUPPORTED
1433 * error.
1434 *
1435 * If the data_available callback is implemented and the stream is at the end
1436 * the stream will set @a *data_available to FALSE.
1437 *
1438 * @since New in 1.9.
1439 */
1442 svn_boolean_t *data_available);
1443
1444/** Return a writable stream which, when written to, writes to both of the
1445 * underlying streams. Both of these streams will be closed upon closure of
1446 * the returned stream; use svn_stream_disown() if this is not the desired
1447 * behavior. One or both of @a out1 and @a out2 may be @c NULL. If both are
1448 * @c NULL, @c NULL is returned.
1449 *
1450 * @since New in 1.7.
1451 */
1454 svn_stream_t *out2,
1455 apr_pool_t *pool);
1456
1457/** Write NULL-terminated string @a str to @a stream.
1458 *
1459 * @since New in 1.8.
1460 *
1461 */
1464 const char *str);
1465
1466/** Write to @a stream using a printf-style @a fmt specifier, passed through
1467 * apr_psprintf() using memory from @a pool.
1468 */
1471 apr_pool_t *pool,
1472 const char *fmt,
1473 ...)
1474 __attribute__((format(printf, 3, 4)));
1475
1476/** Write to @a stream using a printf-style @a fmt specifier, passed through
1477 * apr_psprintf() using memory from @a pool. The resulting string
1478 * will be translated to @a encoding before it is sent to @a stream.
1479 *
1480 * @note Use @c APR_LOCALE_CHARSET to translate to the encoding of the
1481 * current locale.
1482 *
1483 * @since New in 1.3.
1484 */
1487 const char *encoding,
1488 apr_pool_t *pool,
1489 const char *fmt,
1490 ...)
1491 __attribute__((format(printf, 4, 5)));
1492
1493/** Allocate @a *stringbuf in @a pool, and read into it one line (terminated
1494 * by @a eol) from @a stream. The line-terminator is read from the stream,
1495 * but is not added to the end of the stringbuf. Instead, the stringbuf
1496 * ends with a usual '\\0'.
1497 *
1498 * If @a stream runs out of bytes before encountering a line-terminator,
1499 * then set @a *eof to @c TRUE, otherwise set @a *eof to FALSE.
1500 */
1503 svn_stringbuf_t **stringbuf,
1504 const char *eol,
1505 svn_boolean_t *eof,
1506 apr_pool_t *pool);
1507
1508/**
1509 * Read the contents of the readable stream @a from and write them to the
1510 * writable stream @a to calling @a cancel_func before copying each chunk.
1511 *
1512 * @a cancel_func may be @c NULL.
1513 *
1514 * @note both @a from and @a to will be closed upon successful completion of
1515 * the copy (but an error may still be returned, based on trying to close
1516 * the two streams). If the closure is not desired, then you can use
1517 * svn_stream_disown() to protect either or both of the streams from
1518 * being closed.
1519 *
1520 * @since New in 1.6.
1521 */
1524 svn_stream_t *to,
1525 svn_cancel_func_t cancel_func,
1526 void *cancel_baton,
1527 apr_pool_t *pool);
1528
1529/**
1530 * Same as svn_stream_copy3() but the streams are not closed.
1531 *
1532 * @since New in 1.5.
1533 * @deprecated Provided for backward compatibility with the 1.5 API.
1534 */
1538 svn_stream_t *to,
1539 svn_cancel_func_t cancel_func,
1540 void *cancel_baton,
1541 apr_pool_t *pool);
1542
1543/**
1544 * Same as svn_stream_copy3(), but without the cancellation function
1545 * or stream closing.
1546 *
1547 * @since New in 1.1.
1548 * @deprecated Provided for backward compatibility with the 1.4 API.
1549 */
1553 svn_stream_t *to,
1554 apr_pool_t *pool);
1555
1556
1557/** Set @a *same to TRUE if @a stream1 and @a stream2 have the same
1558 * contents, else set it to FALSE.
1559 *
1560 * Both streams will be closed before this function returns (regardless of
1561 * the result, or any possible error).
1562 *
1563 * Use @a scratch_pool for temporary allocations.
1564 *
1565 * @since New in 1.7.
1566 */
1569 svn_stream_t *stream1,
1570 svn_stream_t *stream2,
1571 apr_pool_t *pool);
1572
1573
1574/**
1575 * Same as svn_stream_contents_same2(), but the streams will not be closed.
1576 *
1577 * @since New in 1.4.
1578 * @deprecated Provided for backward compatibility with the 1.6 API.
1579 */
1583 svn_stream_t *stream1,
1584 svn_stream_t *stream2,
1585 apr_pool_t *pool);
1586
1587
1588/** Read the contents of @a stream into memory, from its current position
1589 * to its end, returning the data in @a *result. The stream will be closed
1590 * when it has been successfully and completely read.
1591 *
1592 * @a len_hint gives a hint about the expected length, in bytes, of the
1593 * actual data that will be read from the stream. It may be 0, meaning no
1594 * hint is being provided. Efficiency in time and/or in space may be
1595 * better (and in general will not be worse) when the actual data length
1596 * is equal or approximately equal to the length hint.
1597 *
1598 * The returned memory is allocated in @a result_pool, and any temporary
1599 * allocations may be performed in @a scratch_pool.
1600 *
1601 * @note The present implementation is efficient when @a len_hint is big
1602 * enough (but not vastly bigger than necessary), and also for actual
1603 * lengths up to 64 bytes when @a len_hint is 0. Otherwise it can incur
1604 * significant time and space overheads. See source code for details.
1605 *
1606 * @since New in 1.10
1607 */
1610 svn_stream_t *stream,
1611 apr_size_t len_hint,
1612 apr_pool_t *result_pool);
1613
1614/** Similar to svn_string_from_stream2(), but always passes 0 for
1615 * @a len_hint.
1616 *
1617 * @deprecated Provided for backwards compatibility with the 1.9 API.
1618 */
1622 svn_stream_t *stream,
1623 apr_pool_t *result_pool,
1624 apr_pool_t *scratch_pool);
1625
1626/** A function type provided for use as a callback from
1627 * @c svn_stream_lazyopen_create().
1628 *
1629 * The callback function shall open a new stream and set @a *stream to
1630 * the stream object, allocated in @a result_pool. @a baton is the
1631 * callback baton that was passed to svn_stream_lazyopen_create().
1632 *
1633 * @a result_pool is the result pool that was passed to
1634 * svn_stream_lazyopen_create(). The callback function may use
1635 * @a scratch_pool for temporary allocations; the caller may clear or
1636 * destroy @a scratch_pool any time after the function returns.
1637 *
1638 * @since New in 1.8.
1639 */
1642 void *baton,
1643 apr_pool_t *result_pool,
1644 apr_pool_t *scratch_pool);
1645
1646
1647/** Return a generic stream which wraps another primary stream,
1648 * delaying the "opening" of that stream until the first time the
1649 * returned stream is accessed.
1650 *
1651 * @a open_func and @a open_baton are a callback function/baton pair
1652 * which will be invoked upon the first access of the returned
1653 * stream (read, write, mark, seek, skip, or possibly close). The
1654 * callback shall open the primary stream.
1655 *
1656 * If the only "access" the returned stream gets is to close it
1657 * then @a open_func will only be called if @a open_on_close is TRUE.
1658 *
1659 * Allocate the returned stream in @a result_pool. Also arrange for
1660 * @a result_pool to be passed as the @c result_pool parameter to
1661 * @a open_func when it is called.
1662 *
1663 * @since New in 1.8.
1664 */
1667 void *open_baton,
1668 svn_boolean_t open_on_close,
1669 apr_pool_t *result_pool);
1670
1671/** @} */
1672
1673/** Set @a *result to a string containing the contents of @a
1674 * filename, which is either "-" (indicating that stdin should be
1675 * read) or the utf8-encoded path of a real file.
1676 *
1677 * @warning Callers should be aware of possible unexpected results
1678 * when using this function to read from stdin where additional
1679 * stdin-reading processes abound. For example, if a program tries
1680 * both to invoke an external editor and to read from stdin, stdin
1681 * could be trashed and the editor might act funky or die outright.
1682 *
1683 * @note due to memory pseudo-reallocation behavior (due to pools), this
1684 * can be a memory-intensive operation for large files.
1685 *
1686 * @since New in 1.5.
1687 */
1690 const char *filename,
1691 apr_pool_t *pool);
1692
1693/** Similar to svn_stringbuf_from_file2(), except that if @a filename
1694 * is "-", return the error #SVN_ERR_UNSUPPORTED_FEATURE and don't
1695 * touch @a *result.
1696 *
1697 * @deprecated Provided for backwards compatibility with the 1.4 API.
1698 */
1702 const char *filename,
1703 apr_pool_t *pool);
1704
1705/** Sets @a *result to a string containing the contents of the already opened
1706 * @a file. Reads from the current position in file to the end. Does not
1707 * close the file or reset the cursor position.
1708 *
1709 * @note due to memory pseudo-reallocation behavior (due to pools), this
1710 * can be a memory-intensive operation for large files.
1711 */
1714 apr_file_t *file,
1715 apr_pool_t *pool);
1716
1717/** Remove file @a path, a utf8-encoded path. This wraps apr_file_remove(),
1718 * converting any error to a Subversion error. If @a ignore_enoent is TRUE, and
1719 * the file is not present (APR_STATUS_IS_ENOENT returns TRUE), then no
1720 * error will be returned.
1721 *
1722 * The file will be removed even if it is not writable. (On Windows and
1723 * OS/2, this function first clears the file's read-only bit.)
1724 *
1725 * @since New in 1.7.
1726 */
1729 svn_boolean_t ignore_enoent,
1730 apr_pool_t *scratch_pool);
1731
1732/** Similar to svn_io_remove_file2(), except with @a ignore_enoent set to FALSE.
1733 *
1734 * @deprecated Provided for backwards compatibility with the 1.6 API.
1735 */
1739 apr_pool_t *pool);
1740
1741/** Recursively remove directory @a path. @a path is utf8-encoded.
1742 * If @a ignore_enoent is @c TRUE, don't fail if the target directory
1743 * doesn't exist. Use @a pool for temporary allocations.
1744 *
1745 * Because recursive delete of a directory tree can be a lengthy operation,
1746 * provide @a cancel_func and @a cancel_baton for interruptibility.
1747 *
1748 * @since New in 1.5.
1749 */
1752 svn_boolean_t ignore_enoent,
1753 svn_cancel_func_t cancel_func,
1754 void *cancel_baton,
1755 apr_pool_t *pool);
1756
1757/** Similar to svn_io_remove_dir2(), but with @a ignore_enoent set to
1758 * @c FALSE and @a cancel_func and @a cancel_baton set to @c NULL.
1759 *
1760 * @deprecated Provided for backward compatibility with the 1.4 API
1761 */
1765 apr_pool_t *pool);
1766
1767/** Read all of the disk entries in directory @a path, a utf8-encoded
1768 * path. Set @a *dirents to a hash mapping dirent names (<tt>char *</tt>) to
1769 * undefined non-NULL values, allocated in @a pool.
1770 *
1771 * @note The `.' and `..' directories normally returned by
1772 * apr_dir_read() are NOT returned in the hash.
1773 *
1774 * @since New in 1.4.
1775 * @deprecated Provided for backward compatibility with the 1.6 API.
1776 */
1779svn_io_get_dir_filenames(apr_hash_t **dirents,
1780 const char *path,
1781 apr_pool_t *pool);
1782
1783/** Read all of the disk entries in directory @a path, a utf8-encoded
1784 * path. Set @a *dirents to a hash mapping dirent names (<tt>char *</tt>) to
1785 * #svn_io_dirent2_t structures, allocated in @a pool.
1786 *
1787 * If @a only_check_type is set to @c TRUE, only the kind and special
1788 * fields of the svn_io_dirent2_t are filled.
1789 *
1790 * @note The `.' and `..' directories normally returned by
1791 * apr_dir_read() are NOT returned in the hash.
1792 *
1793 * @note The kind field in the @a dirents is set according to the mapping
1794 * as documented for svn_io_check_path().
1795 *
1796 * @since New in 1.7.
1797 */
1799svn_io_get_dirents3(apr_hash_t **dirents,
1800 const char *path,
1801 svn_boolean_t only_check_type,
1802 apr_pool_t *result_pool,
1803 apr_pool_t *scratch_pool);
1804
1805
1806/** Similar to svn_io_get_dirents3, but returns a mapping to svn_io_dirent_t
1807 * structures instead of svn_io_dirent2_t and with only a single pool.
1808 *
1809 * @since New in 1.3.
1810 * @deprecated Provided for backward compatibility with the 1.6 API.
1811 */
1814svn_io_get_dirents2(apr_hash_t **dirents,
1815 const char *path,
1816 apr_pool_t *pool);
1817
1818/** Similar to svn_io_get_dirents2(), but @a *dirents is a hash table
1819 * with #svn_node_kind_t values.
1820 *
1821 * @deprecated Provided for backwards compatibility with the 1.2 API.
1822 */
1825svn_io_get_dirents(apr_hash_t **dirents,
1826 const char *path,
1827 apr_pool_t *pool);
1828
1829/** Create a svn_io_dirent2_t instance for path. Specialized variant of
1830 * svn_io_stat() that directly translates node_kind and special.
1831 *
1832 * If @a verify_truename is @c TRUE, an additional check is performed to
1833 * verify the truename of the last path component on case insensitive
1834 * filesystems. This check is expensive compared to a just a stat,
1835 * but certainly cheaper than a full truename calculation using
1836 * apr_filepath_merge() which verifies all path components.
1837 *
1838 * If @a ignore_enoent is set to @c TRUE, set *dirent_p->kind to
1839 * svn_node_none instead of returning an error.
1840 *
1841 * @since New in 1.8.
1842 */
1845 const char *path,
1846 svn_boolean_t verify_truename,
1847 svn_boolean_t ignore_enoent,
1848 apr_pool_t *result_pool,
1849 apr_pool_t *scratch_pool);
1850
1851
1852/** Similar to svn_io_stat_dirent2(), but always passes FALSE for
1853 * @a verify_truename.
1854 *
1855 * @since New in 1.7.
1856 * @deprecated Provided for backwards compatibility with the 1.7 API.
1857 */
1861 const char *path,
1862 svn_boolean_t ignore_enoent,
1863 apr_pool_t *result_pool,
1864 apr_pool_t *scratch_pool);
1865
1866
1867/** Callback function type for svn_io_dir_walk() */
1868typedef svn_error_t * (*svn_io_walk_func_t)(void *baton,
1869 const char *path,
1870 const apr_finfo_t *finfo,
1871 apr_pool_t *pool);
1872
1873/** Recursively walk the directory rooted at @a dirname, a
1874 * utf8-encoded path, invoking @a walk_func (with @a walk_baton) for
1875 * each item in the tree. For a given directory, invoke @a walk_func
1876 * on the directory itself before invoking it on any children thereof.
1877 *
1878 * Deliver to @a walk_func the information specified by @a wanted,
1879 * which is a combination of @c APR_FINFO_* flags, plus the
1880 * information specified by @c APR_FINFO_TYPE and @c APR_FINFO_NAME.
1881 *
1882 * Use @a pool for all allocations.
1883 *
1884 * @note This function does not currently pass all file types to @a
1885 * walk_func -- only APR_DIR, APR_REG, and APR_LNK. We reserve the
1886 * right to pass additional file types through this interface in the
1887 * future, though, so implementations of this callback should
1888 * explicitly test FINFO->filetype. See the APR library's
1889 * apr_filetype_e enum for the various filetypes and their meanings.
1890 *
1891 * @since New in 1.7.
1892 */
1894svn_io_dir_walk2(const char *dirname,
1895 apr_int32_t wanted,
1896 svn_io_walk_func_t walk_func,
1897 void *walk_baton,
1898 apr_pool_t *pool);
1899
1900/** Similar to svn_io_dir_walk(), but only calls @a walk_func for
1901 * files of type APR_DIR (directory) and APR_REG (regular file).
1902 *
1903 * @deprecated Provided for backwards compatibility with the 1.6 API.
1904 */
1907svn_io_dir_walk(const char *dirname,
1908 apr_int32_t wanted,
1909 svn_io_walk_func_t walk_func,
1910 void *walk_baton,
1911 apr_pool_t *pool);
1912
1913/**
1914 * Start @a cmd with @a args, using utf8-encoded @a path as working
1915 * directory. Return the process handle for the invoked program in @a
1916 * *cmd_proc.
1917 *
1918 * If @a infile_pipe is TRUE, connect @a cmd's stdin to a pipe;
1919 * otherwise, connect it to @a infile (which may be NULL). If
1920 * @a outfile_pipe is TRUE, connect @a cmd's stdout to a pipe; otherwise,
1921 * connect it to @a outfile (which may be NULL). If @a errfile_pipe
1922 * is TRUE, connect @a cmd's stderr to a pipe; otherwise, connect it
1923 * to @a errfile (which may be NULL). (Callers must pass FALSE for
1924 * each of these boolean values for which the corresponding file
1925 * handle is non-NULL.)
1926 *
1927 * @a args is a list of utf8-encoded <tt>const char *</tt> arguments,
1928 * terminated by @c NULL. @a args[0] is the name of the program, though it
1929 * need not be the same as @a cmd.
1930 *
1931 * If @a inherit is TRUE, the invoked program inherits its environment from
1932 * the caller and @a cmd, if not absolute, is searched for in PATH.
1933 *
1934 * If @a inherit is FALSE @a cmd must be an absolute path and the invoked
1935 * program inherits the environment defined by @a env or runs with an empty
1936 * environment in @a env is NULL.
1937 *
1938 * @note On some platforms, failure to execute @a cmd in the child process
1939 * will result in error output being written to @a errfile, if non-NULL, and
1940 * a non-zero exit status being returned to the parent process.
1941 *
1942 * @note An APR bug affects Windows: passing a NULL @a env does not
1943 * guarantee the invoked program to run with an empty environment when
1944 * @a inherit is FALSE, the program may inherit its parent's environment.
1945 * Explicitly pass an empty @a env to get an empty environment.
1946 *
1947 * @since New in 1.8.
1948 */
1949svn_error_t *svn_io_start_cmd3(apr_proc_t *cmd_proc,
1950 const char *path,
1951 const char *cmd,
1952 const char *const *args,
1953 const char *const *env,
1954 svn_boolean_t inherit,
1955 svn_boolean_t infile_pipe,
1956 apr_file_t *infile,
1957 svn_boolean_t outfile_pipe,
1958 apr_file_t *outfile,
1959 svn_boolean_t errfile_pipe,
1960 apr_file_t *errfile,
1961 apr_pool_t *pool);
1962
1963
1964/**
1965 * Similar to svn_io_start_cmd3() but with @a env always set to NULL.
1966 *
1967 * @deprecated Provided for backward compatibility with the 1.7 API
1968 * @since New in 1.7.
1969 */
1971svn_error_t *svn_io_start_cmd2(apr_proc_t *cmd_proc,
1972 const char *path,
1973 const char *cmd,
1974 const char *const *args,
1975 svn_boolean_t inherit,
1976 svn_boolean_t infile_pipe,
1977 apr_file_t *infile,
1978 svn_boolean_t outfile_pipe,
1979 apr_file_t *outfile,
1980 svn_boolean_t errfile_pipe,
1981 apr_file_t *errfile,
1982 apr_pool_t *pool);
1983
1984/**
1985 * Similar to svn_io_start_cmd2() but with @a infile_pipe, @a
1986 * outfile_pipe, and @a errfile_pipe always FALSE.
1987 *
1988 * @deprecated Provided for backward compatibility with the 1.6 API
1989 * @since New in 1.3.
1990 */
1993svn_io_start_cmd(apr_proc_t *cmd_proc,
1994 const char *path,
1995 const char *cmd,
1996 const char *const *args,
1997 svn_boolean_t inherit,
1998 apr_file_t *infile,
1999 apr_file_t *outfile,
2000 apr_file_t *errfile,
2001 apr_pool_t *pool);
2002
2003/**
2004 * Wait for the process @a *cmd_proc to complete and optionally retrieve
2005 * its exit code. @a cmd is used only in error messages.
2006 *
2007 * If @a exitcode is not NULL, set @a *exitcode to the exit code of the
2008 * process and do not consider any exit code to be an error. If @a exitcode
2009 * is NULL, then if the exit code of the process is non-zero then return an
2010 * #SVN_ERR_EXTERNAL_PROGRAM error.
2011 *
2012 * If @a exitwhy is not NULL, set @a *exitwhy to indicate why the process
2013 * terminated and do not consider any reason to be an error. If @a exitwhy
2014 * is NULL, then if the termination reason is not @c APR_PROC_CHECK_EXIT()
2015 * then return an #SVN_ERR_EXTERNAL_PROGRAM error.
2016 *
2017 * @since New in 1.3.
2018 */
2020svn_io_wait_for_cmd(apr_proc_t *cmd_proc,
2021 const char *cmd,
2022 int *exitcode,
2023 apr_exit_why_e *exitwhy,
2024 apr_pool_t *pool);
2025
2026/** Run a command to completion, by first calling svn_io_start_cmd() and
2027 * then calling svn_io_wait_for_cmd(). The parameters correspond to
2028 * the same-named parameters of those two functions.
2029 */
2032 const char *cmd,
2033 const char *const *args,
2034 int *exitcode,
2035 apr_exit_why_e *exitwhy,
2036 svn_boolean_t inherit,
2037 apr_file_t *infile,
2038 apr_file_t *outfile,
2039 apr_file_t *errfile,
2040 apr_pool_t *pool);
2041
2042/** Invoke the configured @c diff program, with @a user_args (an array
2043 * of utf8-encoded @a num_user_args arguments) if they are specified
2044 * (that is, if @a user_args is non-NULL), or "-u" if they are not.
2045 * If @a user_args is NULL, the value of @a num_user_args is ignored.
2046 *
2047 * Diff runs in utf8-encoded @a dir, and its exit status is stored in
2048 * @a exitcode, if it is not @c NULL.
2049 *
2050 * If @a label1 and/or @a label2 are not NULL they will be passed to the diff
2051 * process as the arguments of "-L" options. @a label1 and @a label2 are also
2052 * in utf8, and will be converted to native charset along with the other args.
2053 *
2054 * @a from is the first file passed to diff, and @a to is the second. The
2055 * stdout of diff will be sent to @a outfile, and the stderr to @a errfile.
2056 *
2057 * @a diff_cmd must be non-NULL.
2058 *
2059 * Do all allocation in @a pool.
2060 * @since New in 1.6.0.
2061 */
2063svn_io_run_diff2(const char *dir,
2064 const char *const *user_args,
2065 int num_user_args,
2066 const char *label1,
2067 const char *label2,
2068 const char *from,
2069 const char *to,
2070 int *exitcode,
2071 apr_file_t *outfile,
2072 apr_file_t *errfile,
2073 const char *diff_cmd,
2074 apr_pool_t *pool);
2075
2076/** Similar to svn_io_run_diff2() but with @a diff_cmd encoded in internal
2077 * encoding used by APR.
2078 *
2079 * @deprecated Provided for backwards compatibility with the 1.5 API. */
2082svn_io_run_diff(const char *dir,
2083 const char *const *user_args,
2084 int num_user_args,
2085 const char *label1,
2086 const char *label2,
2087 const char *from,
2088 const char *to,
2089 int *exitcode,
2090 apr_file_t *outfile,
2091 apr_file_t *errfile,
2092 const char *diff_cmd,
2093 apr_pool_t *pool);
2094
2095
2096
2097/** Invoke the configured @c diff3 program, in utf8-encoded @a dir
2098 * like this:
2099 *
2100 * diff3 -E -m @a mine @a older @a yours > @a merged
2101 *
2102 * (See the diff3 documentation for details.)
2103 *
2104 * If @a user_args is non-NULL, replace "-E" with the <tt>const char*</tt>
2105 * elements that @a user_args contains.
2106 *
2107 * @a mine, @a older and @a yours are utf8-encoded paths (relative to
2108 * @a dir or absolute) to three files that already exist.
2109 *
2110 * @a merged is an open file handle, and is left open after the merge
2111 * result is written to it. (@a merged should *not* be the same file
2112 * as @a mine, or nondeterministic things may happen!)
2113 *
2114 * @a mine_label, @a older_label, @a yours_label are utf8-encoded label
2115 * parameters for diff3's -L option. Any of them may be @c NULL, in
2116 * which case the corresponding @a mine, @a older, or @a yours parameter is
2117 * used instead.
2118 *
2119 * Set @a *exitcode to diff3's exit status. If @a *exitcode is anything
2120 * other than 0 or 1, then return #SVN_ERR_EXTERNAL_PROGRAM. (Note the
2121 * following from the diff3 info pages: "An exit status of 0 means
2122 * `diff3' was successful, 1 means some conflicts were found, and 2
2123 * means trouble.")
2124 *
2125 * @a diff3_cmd must be non-NULL.
2126 *
2127 * Do all allocation in @a pool.
2128 *
2129 * @since New in 1.4.
2130 */
2132svn_io_run_diff3_3(int *exitcode,
2133 const char *dir,
2134 const char *mine,
2135 const char *older,
2136 const char *yours,
2137 const char *mine_label,
2138 const char *older_label,
2139 const char *yours_label,
2140 apr_file_t *merged,
2141 const char *diff3_cmd,
2142 const apr_array_header_t *user_args,
2143 apr_pool_t *pool);
2144
2145/** Similar to svn_io_run_diff3_3(), but with @a diff3_cmd encoded in
2146 * internal encoding used by APR.
2147 *
2148 * @deprecated Provided for backwards compatibility with the 1.5 API.
2149 * @since New in 1.4.
2150 */
2154 const char *dir,
2155 const char *mine,
2156 const char *older,
2157 const char *yours,
2158 const char *mine_label,
2159 const char *older_label,
2160 const char *yours_label,
2161 apr_file_t *merged,
2162 const char *diff3_cmd,
2163 const apr_array_header_t *user_args,
2164 apr_pool_t *pool);
2165
2166/** Similar to svn_io_run_diff3_2(), but with @a user_args set to @c NULL.
2167 *
2168 * @deprecated Provided for backwards compatibility with the 1.3 API.
2169 */
2172svn_io_run_diff3(const char *dir,
2173 const char *mine,
2174 const char *older,
2175 const char *yours,
2176 const char *mine_label,
2177 const char *older_label,
2178 const char *yours_label,
2179 apr_file_t *merged,
2180 int *exitcode,
2181 const char *diff3_cmd,
2182 apr_pool_t *pool);
2183
2184
2185/** Parse utf8-encoded @a mimetypes_file as a MIME types file (such as
2186 * is provided with Apache HTTP Server), and set @a *type_map to a
2187 * hash mapping <tt>const char *</tt> filename extensions to
2188 * <tt>const char *</tt> MIME types.
2189 *
2190 * @since New in 1.5.
2191 */
2193svn_io_parse_mimetypes_file(apr_hash_t **type_map,
2194 const char *mimetypes_file,
2195 apr_pool_t *pool);
2196
2197
2198/** Examine utf8-encoded @a file to determine if it can be described by a
2199 * known (as in, known by this function) Multipurpose Internet Mail
2200 * Extension (MIME) type. If so, set @a *mimetype to a character string
2201 * describing the MIME type, else set it to @c NULL.
2202 *
2203 * If not @c NULL, @a mimetype_map is a hash mapping <tt>const char *</tt>
2204 * filename extensions to <tt>const char *</tt> MIME types, and is the
2205 * first source consulted regarding @a file's MIME type.
2206 *
2207 * Use @a pool for any necessary allocations.
2208 *
2209 * @since New in 1.5.
2210 */
2212svn_io_detect_mimetype2(const char **mimetype,
2213 const char *file,
2214 apr_hash_t *mimetype_map,
2215 apr_pool_t *pool);
2216
2217
2218/** Like svn_io_detect_mimetype2, but with @a mimetypes_map set to
2219 * @c NULL.
2220 *
2221 * @deprecated Provided for backward compatibility with the 1.4 API
2222 */
2225svn_io_detect_mimetype(const char **mimetype,
2226 const char *file,
2227 apr_pool_t *pool);
2228
2229
2230/** Examine up to @a len bytes of data in @a buf to determine if the
2231 * can be considered binary data, in which case return TRUE.
2232 * If the data can be considered plain-text data, return FALSE.
2233 *
2234 * @since New in 1.7.
2235 */
2237svn_io_is_binary_data(const void *buf, apr_size_t len);
2238
2239
2240/** Wrapper for apr_file_open(). @a fname is utf8-encoded.
2241 Always passed flag | APR_BINARY to apr. */
2243svn_io_file_open(apr_file_t **new_file,
2244 const char *fname,
2245 apr_int32_t flag,
2246 apr_fileperms_t perm,
2247 apr_pool_t *pool);
2248
2249
2250/** Wrapper for apr_file_close(). */
2252svn_io_file_close(apr_file_t *file,
2253 apr_pool_t *pool);
2254
2255
2256/** Wrapper for apr_file_getc(). */
2259 apr_file_t *file,
2260 apr_pool_t *pool);
2261
2262
2263/** Wrapper for apr_file_putc().
2264 * @since New in 1.7
2265 */
2268 apr_file_t *file,
2269 apr_pool_t *pool);
2270
2271
2272/** Wrapper for apr_file_info_get(). */
2274svn_io_file_info_get(apr_finfo_t *finfo,
2275 apr_int32_t wanted,
2276 apr_file_t *file,
2277 apr_pool_t *pool);
2278
2279
2280/** Set @a *filesize_p to the size of @a file. Use @a pool for temporary
2281 * allocations.
2282 *
2283 * @note Use svn_io_file_info_get() to get more information about
2284 * apr_file_t.
2285 *
2286 * @since New in 1.10
2287 */
2289svn_io_file_size_get(svn_filesize_t *filesize_p, apr_file_t *file,
2290 apr_pool_t *pool);
2291
2292/** Fetch the current offset of @a file into @a *offset_p. Use @a pool for
2293 * temporary allocations.
2294 *
2295 * @since New in 1.10
2296 */
2298svn_io_file_get_offset(apr_off_t *offset_p,
2299 apr_file_t *file,
2300 apr_pool_t *pool);
2301
2302/** Wrapper for apr_file_read(). */
2304svn_io_file_read(apr_file_t *file,
2305 void *buf,
2306 apr_size_t *nbytes,
2307 apr_pool_t *pool);
2308
2309
2310/** Wrapper for apr_file_read_full().
2311 *
2312 * If @a hit_eof is not NULL, EOF will be indicated there and no
2313 * svn_error_t error object will be created upon EOF.
2314 *
2315 * @since New in 1.7
2316 */
2318svn_io_file_read_full2(apr_file_t *file,
2319 void *buf,
2320 apr_size_t nbytes,
2321 apr_size_t *bytes_read,
2322 svn_boolean_t *hit_eof,
2323 apr_pool_t *pool);
2324
2325
2326/** Similar to svn_io_file_read_full2 with hit_eof being set
2327 * to @c NULL.
2328 *
2329 * @deprecated Provided for backward compatibility with the 1.6 API
2330 */
2333svn_io_file_read_full(apr_file_t *file,
2334 void *buf,
2335 apr_size_t nbytes,
2336 apr_size_t *bytes_read,
2337 apr_pool_t *pool);
2338
2339
2340/** Wrapper for apr_file_seek(). */
2342svn_io_file_seek(apr_file_t *file,
2343 apr_seek_where_t where,
2344 apr_off_t *offset,
2345 apr_pool_t *pool);
2346
2347/** Set the file pointer of the #APR_BUFFERED @a file to @a offset. In
2348 * contrast to #svn_io_file_seek, this function will attempt to resize the
2349 * internal data buffer to @a block_size bytes and to read data aligned to
2350 * multiples of that value. The beginning of the block will be returned
2351 * in @a buffer_start, if that is not NULL.
2352 * Uses @a scratch_pool for temporary allocations.
2353 *
2354 * @note Due to limitations of the APR API, the alignment may not be
2355 * successful. If you never use any other seek function on @a file,
2356 * however, you are virtually guaranteed to get at least 4kByte alignment
2357 * for all reads.
2358 *
2359 * @note Calling this for non-buffered files is legal but inefficient.
2360 *
2361 * @since New in 1.9
2362 */
2365 apr_off_t block_size,
2366 apr_off_t *buffer_start,
2367 apr_off_t offset,
2368 apr_pool_t *scratch_pool);
2369
2370/** Wrapper for apr_file_write(). */
2372svn_io_file_write(apr_file_t *file,
2373 const void *buf,
2374 apr_size_t *nbytes,
2375 apr_pool_t *pool);
2376
2377/** Wrapper for apr_file_flush().
2378 * @since New in 1.9
2379 */
2381svn_io_file_flush(apr_file_t *file,
2382 apr_pool_t *scratch_pool);
2383
2384
2385
2386/** Wrapper for apr_file_write_full(). */
2388svn_io_file_write_full(apr_file_t *file,
2389 const void *buf,
2390 apr_size_t nbytes,
2391 apr_size_t *bytes_written,
2392 apr_pool_t *pool);
2393
2394/**
2395 * Writes @a nbytes bytes from @a *buf to a temporary file inside the same
2396 * directory as @a *final_path. Then syncs the temporary file to disk and
2397 * closes the file. After this rename the temporary file to @a final_path,
2398 * possibly replacing an existing file.
2399 *
2400 * If @a copy_perms_path is not NULL, copy the permissions applied on @a
2401 * @a copy_perms_path on the temporary file before renaming.
2402 *
2403 * If @a flush_to_disk is non-zero, do not return until the node has
2404 * actually been written on the disk.
2405 *
2406 * @note The flush to disk operation can be very expensive on systems
2407 * that implement flushing on all IO layers, like Windows. Please use
2408 * @a flush_to_disk flag only for critical data.
2409 *
2410 * @since New in 1.10.
2411 */
2413svn_io_write_atomic2(const char *final_path,
2414 const void *buf,
2415 apr_size_t nbytes,
2416 const char *copy_perms_path,
2417 svn_boolean_t flush_to_disk,
2418 apr_pool_t *scratch_pool);
2419
2420/** Similar to svn_io_write_atomic2(), but with @a flush_to_disk set
2421 * to @c TRUE.
2422 *
2423 * @since New in 1.9.
2424 *
2425 * @deprecated Provided for backward compatibility with the 1.9 API
2426 */
2429svn_io_write_atomic(const char *final_path,
2430 const void *buf,
2431 apr_size_t nbytes,
2432 const char* copy_perms_path,
2433 apr_pool_t *scratch_pool);
2434
2435/**
2436 * Open a unique file in @a dirpath, and write @a nbytes from @a buf to
2437 * the file before flushing it to disk and closing it. Return the name
2438 * of the newly created file in @a *tmp_path, allocated in @a pool.
2439 *
2440 * If @a dirpath is @c NULL, use the path returned from svn_io_temp_dir().
2441 * (Note that when using the system-provided temp directory, it may not
2442 * be possible to atomically rename the resulting file due to cross-device
2443 * issues.)
2444 *
2445 * The file will be deleted according to @a delete_when.
2446 *
2447 * @since New in 1.6.
2448 */
2450svn_io_write_unique(const char **tmp_path,
2451 const char *dirpath,
2452 const void *buf,
2453 apr_size_t nbytes,
2454 svn_io_file_del_t delete_when,
2455 apr_pool_t *pool);
2456
2457/** Wrapper for apr_file_trunc().
2458 * @since New in 1.6. */
2460svn_io_file_trunc(apr_file_t *file,
2461 apr_off_t offset,
2462 apr_pool_t *pool);
2463
2464
2465/** Wrapper for apr_stat(). @a fname is utf8-encoded. */
2467svn_io_stat(apr_finfo_t *finfo,
2468 const char *fname,
2469 apr_int32_t wanted,
2470 apr_pool_t *pool);
2471
2472
2473/** Rename and/or move the node (not necessarily a regular file) at
2474 * @a from_path to a new path @a to_path within the same filesystem.
2475 * In some cases, an existing node at @a to_path will be overwritten.
2476 *
2477 * @a from_path and @a to_path are utf8-encoded. If @a flush_to_disk
2478 * is non-zero, do not return until the node has actually been moved on
2479 * the disk.
2480 *
2481 * @note The flush to disk operation can be very expensive on systems
2482 * that implement flushing on all IO layers, like Windows. Please use
2483 * @a flush_to_disk flag only for critical data.
2484 *
2485 * @since New in 1.10.
2486 */
2488svn_io_file_rename2(const char *from_path, const char *to_path,
2489 svn_boolean_t flush_to_disk, apr_pool_t *pool);
2490
2491/** Similar to svn_io_file_rename2(), but with @a flush_to_disk set
2492 * to @c FALSE.
2493 *
2494 * @deprecated Provided for backward compatibility with the 1.9 API
2495 */
2498svn_io_file_rename(const char *from_path,
2499 const char *to_path,
2500 apr_pool_t *pool);
2501
2502
2503/** Move the file from @a from_path to @a to_path, even across device
2504 * boundaries. Overwrite @a to_path if it exists.
2505 *
2506 * @note This function is different from svn_io_file_rename in that the
2507 * latter fails in the 'across device boundaries' case.
2508 *
2509 * @since New in 1.3.
2510 */
2512svn_io_file_move(const char *from_path,
2513 const char *to_path,
2514 apr_pool_t *pool);
2515
2516
2517/** Wrapper for apr_dir_make(). @a path is utf8-encoded. */
2520 apr_fileperms_t perm,
2521 apr_pool_t *pool);
2522
2523/** Same as svn_io_dir_make(), but sets the hidden attribute on the
2524 directory on systems that support it. */
2527 apr_fileperms_t perm,
2528 apr_pool_t *pool);
2529
2530/**
2531 * Same as svn_io_dir_make(), but attempts to set the sgid on the
2532 * directory on systems that support it. Does not return an error if
2533 * the attempt to set the sgid bit fails. On Unix filesystems,
2534 * setting the sgid bit on a directory ensures that files and
2535 * subdirectories created within inherit group ownership from the
2536 * parent instead of from the primary gid.
2537 *
2538 * @since New in 1.1.
2539 */
2542 apr_fileperms_t perm,
2543 apr_pool_t *pool);
2544
2545/** Wrapper for apr_dir_open(). @a dirname is utf8-encoded. */
2547svn_io_dir_open(apr_dir_t **new_dir,
2548 const char *dirname,
2549 apr_pool_t *pool);
2550
2551/** Wrapper for apr_dir_close().
2552 *
2553 * @since New in 1.7.
2554 */
2556svn_io_dir_close(apr_dir_t *thedir);
2557
2558/** Wrapper for apr_dir_remove(). @a dirname is utf8-encoded.
2559 * @note This function has this name to avoid confusion with
2560 * svn_io_remove_dir2(), which is recursive.
2561 */
2564 apr_pool_t *pool);
2565
2566
2567/** Wrapper for apr_dir_read(). Ensures that @a finfo->name is
2568 * utf8-encoded, which means allocating @a finfo->name in @a pool,
2569 * which may or may not be the same as @a finfo's pool. Use @a pool
2570 * for error allocation as well.
2571 */
2573svn_io_dir_read(apr_finfo_t *finfo,
2574 apr_int32_t wanted,
2575 apr_dir_t *thedir,
2576 apr_pool_t *pool);
2577
2578/** Wrapper for apr_file_name_get(). @a *filename is utf8-encoded.
2579 *
2580 * @note The file name may be NULL.
2581 *
2582 * @since New in 1.7. */
2584svn_io_file_name_get(const char **filename,
2585 apr_file_t *file,
2586 apr_pool_t *pool);
2587
2588
2589␌
2590/** Version/format files.
2591 *
2592 * @defgroup svn_io_format_files Version/format files
2593 * @{
2594 */
2595
2596/** Set @a *version to the integer that starts the file at @a path. If the
2597 * file does not begin with a series of digits followed by a newline,
2598 * return the error #SVN_ERR_BAD_VERSION_FILE_FORMAT. Use @a pool for
2599 * all allocations.
2600 */
2603 const char *path,
2604 apr_pool_t *pool);
2605
2606/** Create (or overwrite) the file at @a path with new contents,
2607 * formatted as a non-negative integer @a version followed by a single
2608 * newline. On successful completion the file will be read-only. Use
2609 * @a pool for all allocations.
2610 */
2613 int version,
2614 apr_pool_t *pool);
2615
2616/** Read a line of text from a file, up to a specified length.
2617 *
2618 * Allocate @a *stringbuf in @a result_pool, and read into it one line
2619 * from @a file. Reading stops either after a line-terminator was found
2620 * or after @a max_len bytes have been read.
2621 *
2622 * If end-of-file is reached or @a max_len bytes have been read, and @a eof
2623 * is not NULL, then set @a *eof to @c TRUE.
2624 *
2625 * The line-terminator is not stored in @a *stringbuf.
2626 * The line-terminator is detected automatically and stored in @a *eol
2627 * if @a eol is not NULL. If EOF is reached and @a file does not end
2628 * with a newline character, and @a eol is not NULL, @ *eol is set to NULL.
2629 *
2630 * @a scratch_pool is used for temporary allocations.
2631 *
2632 * Hint: To read all data until a line-terminator is hit, pass APR_SIZE_MAX
2633 * for @a max_len.
2634 *
2635 * @since New in 1.8.
2636 */
2638svn_io_file_readline(apr_file_t *file,
2639 svn_stringbuf_t **stringbuf,
2640 const char **eol,
2641 svn_boolean_t *eof,
2642 apr_size_t max_len,
2643 apr_pool_t *result_pool,
2644 apr_pool_t *scratch_pool);
2645
2646/** @} */
2647
2648#ifdef __cplusplus
2649}
2650#endif /* __cplusplus */
2651
2652#endif /* SVN_IO_H */
svn_error_t * svn_stream_copy3(svn_stream_t *from, svn_stream_t *to, svn_cancel_func_t cancel_func, void *cancel_baton, apr_pool_t *pool)
Read the contents of the readable stream from and write them to the writable stream to calling cancel...
svn_error_t *(* svn_stream_mark_fn_t)(void *baton, svn_stream_mark_t **mark, apr_pool_t *pool)
Mark handler function for a generic stream.
Definition svn_io.h:901
svn_error_t * svn_stream_readline(svn_stream_t *stream, svn_stringbuf_t **stringbuf, const char *eol, svn_boolean_t *eof, apr_pool_t *pool)
Allocate *stringbuf in pool, and read into it one line (terminated by eol) from stream.
svn_error_t * svn_stream_for_stdout(svn_stream_t **out, apr_pool_t *pool)
Set *out to a generic stream connected to stdout, allocated in pool.
struct svn_stream_t svn_stream_t
An abstract stream of bytes–either incoming or outgoing or both.
Definition svn_io.h:863
void svn_stream_set_close(svn_stream_t *stream, svn_close_fn_t close_fn)
Set stream's close function to close_fn.
svn_stream_t * svn_stream_checksummed2(svn_stream_t *stream, svn_checksum_t **read_checksum, svn_checksum_t **write_checksum, svn_checksum_kind_t checksum_kind, svn_boolean_t read_all, apr_pool_t *pool)
Return a stream that calculates checksums for all data read and written.
svn_error_t * svn_stream_open_unique(svn_stream_t **stream, const char **temp_path, const char *dirpath, svn_io_file_del_t delete_when, apr_pool_t *result_pool, apr_pool_t *scratch_pool)
Create a writable stream to a file in the directory dirpath.
void svn_stream_set_baton(svn_stream_t *stream, void *baton)
Set stream's baton to baton.
svn_stream_t * svn_stream_disown(svn_stream_t *stream, apr_pool_t *pool)
Return a stream allocated in pool which forwards all requests to stream.
svn_error_t * svn_stream_copy2(svn_stream_t *from, svn_stream_t *to, svn_cancel_func_t cancel_func, void *cancel_baton, apr_pool_t *pool)
Same as svn_stream_copy3() but the streams are not closed.
svn_error_t * svn_stream_read2(svn_stream_t *stream, char *buffer, apr_size_t *len)
Read all currently available upto *len into buffer.
svn_error_t * svn_stream_read_full(svn_stream_t *stream, char *buffer, apr_size_t *len)
Read from a generic stream until buffer is filled upto *len or until EOF is reached.
svn_boolean_t svn_stream_supports_partial_read(svn_stream_t *stream)
Returns TRUE if the generic stream supports svn_stream_read2().
void svn_stream_set_read2(svn_stream_t *stream, svn_read_fn_t read_fn, svn_read_fn_t read_full_fn)
Set stream's read functions to read_fn and read_full_fn.
svn_stream_t * svn_stream_lazyopen_create(svn_stream_lazyopen_func_t open_func, void *open_baton, svn_boolean_t open_on_close, apr_pool_t *result_pool)
Return a generic stream which wraps another primary stream, delaying the "opening" of that stream unt...
svn_error_t * svn_stream_contents_same(svn_boolean_t *same, svn_stream_t *stream1, svn_stream_t *stream2, apr_pool_t *pool)
Same as svn_stream_contents_same2(), but the streams will not be closed.
svn_error_t * svn_stream_printf_from_utf8(svn_stream_t *stream, const char *encoding, apr_pool_t *pool, const char *fmt,...)
Write to stream using a printf-style fmt specifier, passed through apr_psprintf() using memory from p...
svn_error_t * svn_stream_open_readonly(svn_stream_t **stream, const char *path, apr_pool_t *result_pool, apr_pool_t *scratch_pool)
Create a stream to read the file at path.
svn_stream_t * svn_stream_empty(apr_pool_t *pool)
Create a stream that is empty for reading and infinite for writing.
svn_error_t *(* svn_read_fn_t)(void *baton, char *buffer, apr_size_t *len)
Read handler function for a generic stream.
Definition svn_io.h:868
svn_error_t * svn_stream_seek(svn_stream_t *stream, const svn_stream_mark_t *mark)
Seek to a mark in a generic stream.
svn_error_t * svn_stream_contents_same2(svn_boolean_t *same, svn_stream_t *stream1, svn_stream_t *stream2, apr_pool_t *pool)
Set *same to TRUE if stream1 and stream2 have the same contents, else set it to FALSE.
svn_error_t * svn_stream_close(svn_stream_t *stream)
Close a generic stream.
svn_error_t * svn_stream_open_writable(svn_stream_t **stream, const char *path, apr_pool_t *result_pool, apr_pool_t *scratch_pool)
Create a stream to write a file at path.
svn_stream_t * svn_stream_buffered(apr_pool_t *result_pool)
Return a generic stream which implements buffered reads and writes.
svn_error_t * svn_stream_data_available(svn_stream_t *stream, svn_boolean_t *data_available)
When a stream supports polling for available data, obtain a boolean indicating whether data is waitin...
svn_error_t * svn_stream_for_stdin(svn_stream_t **in, apr_pool_t *pool)
Similar to svn_stream_for_stdin2(), but with buffering being disabled.
svn_stream_t * svn_stream_from_stringbuf(svn_stringbuf_t *str, apr_pool_t *pool)
Return a generic stream connected to stringbuf str.
svn_error_t *(* svn_stream_skip_fn_t)(void *baton, apr_size_t len)
Skip data handler function for a generic stream.
Definition svn_io.h:876
svn_error_t *(* svn_close_fn_t)(void *baton)
Close handler function for a generic stream.
Definition svn_io.h:885
svn_boolean_t svn_stream_supports_seek(svn_stream_t *stream)
Returns TRUE if the generic stream supports svn_stream_seek().
void svn_stream_set_data_available(svn_stream_t *stream, svn_stream_data_available_fn_t data_available)
Set stream's data available function to data_available_fn.
svn_error_t * svn_stream_printf(svn_stream_t *stream, apr_pool_t *pool, const char *fmt,...)
Write to stream using a printf-style fmt specifier, passed through apr_psprintf() using memory from p...
svn_error_t * svn_stream_read(svn_stream_t *stream, char *buffer, apr_size_t *len)
Read from a generic stream until the buffer is completely filled or EOF.
void svn_stream_set_readline(svn_stream_t *stream, svn_stream_readline_fn_t readline_fn)
Set stream's readline function to readline_fn.
svn_error_t * svn_stream_for_stderr(svn_stream_t **err, apr_pool_t *pool)
Set *err to a generic stream connected to stderr, allocated in pool.
svn_error_t * svn_stream_reset(svn_stream_t *stream)
Reset a generic stream back to its origin.
void svn_stream_set_seek(svn_stream_t *stream, svn_stream_seek_fn_t seek_fn)
Set stream's seek function to seek_fn.
svn_stream_t * svn_stream_tee(svn_stream_t *out1, svn_stream_t *out2, apr_pool_t *pool)
Return a writable stream which, when written to, writes to both of the underlying streams.
svn_error_t * svn_stream_write(svn_stream_t *stream, const char *data, apr_size_t *len)
Write to a generic stream.
svn_error_t *(* svn_write_fn_t)(void *baton, const char *data, apr_size_t *len)
Write handler function for a generic stream.
Definition svn_io.h:880
svn_boolean_t svn_stream_supports_mark(svn_stream_t *stream)
Returns TRUE if the generic stream supports svn_stream_mark().
svn_boolean_t svn_stream_supports_reset(svn_stream_t *stream)
Returns TRUE if the generic stream supports svn_stream_reset().
svn_stream_t * svn_stream_from_aprfile2(apr_file_t *file, svn_boolean_t disown, apr_pool_t *pool)
Create a stream from an APR file.
svn_stream_t * svn_stream_checksummed(svn_stream_t *stream, const unsigned char **read_digest, const unsigned char **write_digest, svn_boolean_t read_all, apr_pool_t *pool)
Similar to svn_stream_checksummed2(), but always returning the MD5 checksum in read_digest and write_...
struct svn_stream_mark_t svn_stream_mark_t
An opaque type which represents a mark on a stream.
Definition svn_io.h:894
svn_stream_t * svn_stream_from_string(const svn_string_t *str, apr_pool_t *pool)
Return a generic read-only stream connected to string str.
svn_stream_t * svn_stream_from_aprfile(apr_file_t *file, apr_pool_t *pool)
Similar to svn_stream_from_aprfile2(), except that the file will always be disowned.
void svn_stream_set_mark(svn_stream_t *stream, svn_stream_mark_fn_t mark_fn)
Set stream's mark function to mark_fn.
svn_error_t *(* svn_stream_seek_fn_t)(void *baton, const svn_stream_mark_t *mark)
Seek handler function for a generic stream.
Definition svn_io.h:910
svn_error_t * svn_stream_for_stdin2(svn_stream_t **in, svn_boolean_t buffered, apr_pool_t *pool)
Set *in to a generic stream connected to stdin, allocated in pool.
svn_error_t * svn_stream_mark(svn_stream_t *stream, svn_stream_mark_t **mark, apr_pool_t *pool)
Set a mark at the current position of a generic stream, which can later be sought back to using svn_s...
svn_error_t * svn_stringbuf_from_stream(svn_stringbuf_t **result, svn_stream_t *stream, apr_size_t len_hint, apr_pool_t *result_pool)
Read the contents of stream into memory, from its current position to its end, returning the data in ...
svn_error_t *(* svn_stream_readline_fn_t)(void *baton, svn_stringbuf_t **stringbuf, const char *eol, svn_boolean_t *eof, apr_pool_t *pool)
Readline handler function for a generic stream.
Definition svn_io.h:926
svn_error_t *(* svn_stream_lazyopen_func_t)(svn_stream_t **stream, void *baton, apr_pool_t *result_pool, apr_pool_t *scratch_pool)
A function type provided for use as a callback from svn_stream_lazyopen_create().
Definition svn_io.h:1641
svn_stream_t * svn_stream_compressed(svn_stream_t *stream, apr_pool_t *pool)
Return a stream that decompresses all data read and compresses all data written.
svn_stream_t * svn_stream_create(void *baton, apr_pool_t *pool)
Create a generic stream.
svn_error_t *(* svn_stream_data_available_fn_t)(void *baton, svn_boolean_t *data_available)
Poll handler for generic streams that support incomplete reads,.
Definition svn_io.h:918
svn_error_t * svn_string_from_stream2(svn_string_t **result, svn_stream_t *stream, apr_size_t len_hint, apr_pool_t *result_pool)
Read the contents of stream into memory, from its current position to its end, returning the data in ...
svn_error_t * svn_stream_skip(svn_stream_t *stream, apr_size_t len)
Skip len bytes from a generic stream.
void svn_stream_set_read(svn_stream_t *stream, svn_read_fn_t read_fn)
Set stream's read function to read_fn.
void svn_stream_set_write(svn_stream_t *stream, svn_write_fn_t write_fn)
Set stream's write function to write_fn.
svn_error_t * svn_string_from_stream(svn_string_t **result, svn_stream_t *stream, apr_pool_t *result_pool, apr_pool_t *scratch_pool)
Similar to svn_string_from_stream2(), but always passes 0 for len_hint.
svn_error_t * svn_stream_copy(svn_stream_t *from, svn_stream_t *to, apr_pool_t *pool)
Same as svn_stream_copy3(), but without the cancellation function or stream closing.
svn_error_t * svn_stream_puts(svn_stream_t *stream, const char *str)
Write NULL-terminated string str to stream.
void svn_stream_set_skip(svn_stream_t *stream, svn_stream_skip_fn_t skip_fn)
Set stream's skip function to skip_fn.
svn_error_t * svn_stream_contents_checksum(svn_checksum_t **checksum, svn_stream_t *stream, svn_checksum_kind_t kind, apr_pool_t *result_pool, apr_pool_t *scratch_pool)
Read the contents of the readable stream stream and return its checksum of type kind in *checksum.
svn_error_t * svn_io_write_version_file(const char *path, int version, apr_pool_t *pool)
Create (or overwrite) the file at path with new contents, formatted as a non-negative integer version...
svn_error_t * svn_io_file_readline(apr_file_t *file, svn_stringbuf_t **stringbuf, const char **eol, svn_boolean_t *eof, apr_size_t max_len, apr_pool_t *result_pool, apr_pool_t *scratch_pool)
Read a line of text from a file, up to a specified length.
svn_error_t * svn_io_read_version_file(int *version, const char *path, apr_pool_t *pool)
Set *version to the integer that starts the file at path.
const char * path
Structure used in the svn_wc_notify_func2_t function.
Definition svn_wc.h:1416
svn_error_t * err
Points to an error describing the reason for the failure when action is one of the following: svn_wc_...
Definition svn_wc.h:1437
svn_node_kind_t kind
Node kind of path.
Definition svn_wc.h:1422
A generic checksum representation.
Subversion error object.
Definition svn_types.h:177
A set of directory entry data elements as returned by svn_io_get_dirents.
Definition svn_io.h:78
apr_time_t mtime
The time the file was last modified.
Definition svn_io.h:95
svn_boolean_t special
If kind is svn_node_file, whether this entry is a special file; else FALSE.
Definition svn_io.h:89
svn_filesize_t filesize
The filesize of this entry or undefined for a directory.
Definition svn_io.h:92
svn_node_kind_t kind
The kind of this entry.
Definition svn_io.h:82
Represents the kind and special status of a directory entry.
Definition svn_io.h:123
svn_node_kind_t kind
The kind of this entry.
Definition svn_io.h:125
svn_boolean_t special
If kind is svn_node_file, whether this entry is a special file; else FALSE.
Definition svn_io.h:131
A simple counted string.
Definition svn_string.h:97
A buffered string, capable of appending without an allocation and copy for each append.
Definition svn_string.h:105
Subversion checksum routines.
svn_checksum_kind_t
Various types of checksums.
svn_error_t * svn_io_file_seek(apr_file_t *file, apr_seek_where_t where, apr_off_t *offset, apr_pool_t *pool)
Wrapper for apr_file_seek().
svn_error_t * svn_io_set_file_read_only(const char *path, svn_boolean_t ignore_enoent, apr_pool_t *pool)
Make a file as read-only as the operating system allows.
svn_error_t * svn_io_check_path(const char *path, svn_node_kind_t *kind, apr_pool_t *pool)
Determine the kind of path.
void svn_io_sleep_for_timestamps(const char *path, apr_pool_t *pool)
Sleep to ensure that any files modified after we exit have a different timestamp than the one we reco...
svn_error_t * svn_io_file_lock2(const char *lock_file, svn_boolean_t exclusive, svn_boolean_t nonblocking, apr_pool_t *pool)
Lock file at lock_file.
svn_error_t * svn_io_files_contents_same_p(svn_boolean_t *same, const char *file1, const char *file2, apr_pool_t *pool)
Set *same to TRUE if file1 and file2 have the same contents, else set it to FALSE.
svn_error_t * svn_io_file_info_get(apr_finfo_t *finfo, apr_int32_t wanted, apr_file_t *file, apr_pool_t *pool)
Wrapper for apr_file_info_get().
svn_io_dirent2_t * svn_io_dirent2_create(apr_pool_t *result_pool)
Creates a new svn_io_dirent2_t structure.
svn_error_t * svn_io_remove_file(const char *path, apr_pool_t *pool)
Similar to svn_io_remove_file2(), except with ignore_enoent set to FALSE.
svn_error_t * svn_io_stat_dirent2(const svn_io_dirent2_t **dirent_p, const char *path, svn_boolean_t verify_truename, svn_boolean_t ignore_enoent, apr_pool_t *result_pool, apr_pool_t *scratch_pool)
Create a svn_io_dirent2_t instance for path.
svn_error_t * svn_io_dir_make_hidden(const char *path, apr_fileperms_t perm, apr_pool_t *pool)
Same as svn_io_dir_make(), but sets the hidden attribute on the directory on systems that support it.
svn_error_t * svn_io_open_unique_file2(apr_file_t **f, const char **unique_name_p, const char *path, const char *suffix, svn_io_file_del_t delete_when, apr_pool_t *pool)
Like svn_io_open_uniquely_named(), but takes a joined dirpath and filename, and a single pool.
svn_error_t * svn_io_files_contents_three_same_p(svn_boolean_t *same12, svn_boolean_t *same23, svn_boolean_t *same13, const char *file1, const char *file2, const char *file3, apr_pool_t *scratch_pool)
Set *same12 to TRUE if file1 and file2 have the same contents, else set it to FALSE.
svn_error_t * svn_io_file_create_bytes(const char *file, const void *contents, apr_size_t length, apr_pool_t *scratch_pool)
Create a file at utf8-encoded path file with the contents given by contents of length bytes.
svn_error_t * svn_io_lock_open_file(apr_file_t *lockfile_handle, svn_boolean_t exclusive, svn_boolean_t nonblocking, apr_pool_t *pool)
Lock the file lockfile_handle.
svn_error_t * svn_io_set_file_affected_time(apr_time_t apr_time, const char *path, apr_pool_t *pool)
Set the timestamp of file path to apr_time.
svn_error_t * svn_io_run_cmd(const char *path, const char *cmd, const char *const *args, int *exitcode, apr_exit_why_e *exitwhy, svn_boolean_t inherit, apr_file_t *infile, apr_file_t *outfile, apr_file_t *errfile, apr_pool_t *pool)
Run a command to completion, by first calling svn_io_start_cmd() and then calling svn_io_wait_for_cmd...
svn_error_t * svn_io_open_unique_file(apr_file_t **f, const char **unique_name_p, const char *path, const char *suffix, svn_boolean_t delete_on_close, apr_pool_t *pool)
Like svn_io_open_unique_file2, but can't delete on pool cleanup.
svn_error_t * svn_io_dir_empty(svn_boolean_t *is_empty_p, const char *path, apr_pool_t *pool)
Set *is_empty_p to TRUE if directory path is empty, else to FALSE if it is not empty.
svn_error_t * svn_io_copy_file(const char *src, const char *dst, svn_boolean_t copy_perms, apr_pool_t *pool)
Copy src to dst atomically, in a "byte-for-byte" manner.
svn_error_t * svn_io_file_affected_time(apr_time_t *apr_time, const char *path, apr_pool_t *pool)
Set *apr_time to the time of last modification of the contents of the file path.
svn_error_t * svn_io_file_read(apr_file_t *file, void *buf, apr_size_t *nbytes, apr_pool_t *pool)
Wrapper for apr_file_read().
svn_error_t * svn_io_file_get_offset(apr_off_t *offset_p, apr_file_t *file, apr_pool_t *pool)
Fetch the current offset of file into *offset_p.
svn_error_t * svn_io_stat(apr_finfo_t *finfo, const char *fname, apr_int32_t wanted, apr_pool_t *pool)
Wrapper for apr_stat().
svn_error_t * svn_io_dir_make_sgid(const char *path, apr_fileperms_t perm, apr_pool_t *pool)
Same as svn_io_dir_make(), but attempts to set the sgid on the directory on systems that support it.
svn_error_t * svn_io_file_read_full2(apr_file_t *file, void *buf, apr_size_t nbytes, apr_size_t *bytes_read, svn_boolean_t *hit_eof, apr_pool_t *pool)
Wrapper for apr_file_read_full().
svn_error_t * svn_io_run_diff3_2(int *exitcode, const char *dir, const char *mine, const char *older, const char *yours, const char *mine_label, const char *older_label, const char *yours_label, apr_file_t *merged, const char *diff3_cmd, const apr_array_header_t *user_args, apr_pool_t *pool)
Invoke the configured diff3 program, in utf8-encoded dir like this:
svn_error_t * svn_io_write_atomic2(const char *final_path, const void *buf, apr_size_t nbytes, const char *copy_perms_path, svn_boolean_t flush_to_disk, apr_pool_t *scratch_pool)
Writes nbytes bytes from *buf to a temporary file inside the same directory as *final_path.
svn_error_t * svn_io_file_rename2(const char *from_path, const char *to_path, svn_boolean_t flush_to_disk, apr_pool_t *pool)
Rename and/or move the node (not necessarily a regular file) at from_path to a new path to_path withi...
svn_error_t * svn_io_file_write_full(apr_file_t *file, const void *buf, apr_size_t nbytes, apr_size_t *bytes_written, apr_pool_t *pool)
Wrapper for apr_file_write_full().
svn_error_t * svn_io_run_diff3(const char *dir, const char *mine, const char *older, const char *yours, const char *mine_label, const char *older_label, const char *yours_label, apr_file_t *merged, int *exitcode, const char *diff3_cmd, apr_pool_t *pool)
Similar to svn_io_run_diff3_2(), but with user_args set to NULL.
svn_error_t * svn_io_read_length_line(apr_file_t *file, char *buf, apr_size_t *limit, apr_pool_t *pool)
Read a line from file into buf, but not exceeding *limit bytes.
svn_error_t * svn_io_dir_open(apr_dir_t **new_dir, const char *dirname, apr_pool_t *pool)
Wrapper for apr_dir_open().
svn_error_t * svn_stringbuf_from_file(svn_stringbuf_t **result, const char *filename, apr_pool_t *pool)
Similar to svn_stringbuf_from_file2(), except that if filename is "-", return the error SVN_ERR_UNSUP...
svn_error_t * svn_io_run_diff(const char *dir, const char *const *user_args, int num_user_args, const char *label1, const char *label2, const char *from, const char *to, int *exitcode, apr_file_t *outfile, apr_file_t *errfile, const char *diff_cmd, apr_pool_t *pool)
Similar to svn_io_run_diff2() but with diff_cmd encoded in internal encoding used by APR.
svn_error_t * svn_io_start_cmd(apr_proc_t *cmd_proc, const char *path, const char *cmd, const char *const *args, svn_boolean_t inherit, apr_file_t *infile, apr_file_t *outfile, apr_file_t *errfile, apr_pool_t *pool)
Similar to svn_io_start_cmd2() but with infile_pipe, outfile_pipe, and errfile_pipe always FALSE.
svn_error_t * svn_io_get_dirents3(apr_hash_t **dirents, const char *path, svn_boolean_t only_check_type, apr_pool_t *result_pool, apr_pool_t *scratch_pool)
Read all of the disk entries in directory path, a utf8-encoded path.
svn_error_t * svn_io_start_cmd3(apr_proc_t *cmd_proc, const char *path, const char *cmd, const char *const *args, const char *const *env, svn_boolean_t inherit, svn_boolean_t infile_pipe, apr_file_t *infile, svn_boolean_t outfile_pipe, apr_file_t *outfile, svn_boolean_t errfile_pipe, apr_file_t *errfile, apr_pool_t *pool)
Start cmd with args, using utf8-encoded path as working directory.
svn_error_t * svn_io_file_rename(const char *from_path, const char *to_path, apr_pool_t *pool)
Similar to svn_io_file_rename2(), but with flush_to_disk set to FALSE.
svn_error_t * svn_io_file_close(apr_file_t *file, apr_pool_t *pool)
Wrapper for apr_file_close().
svn_error_t * svn_io_file_write(apr_file_t *file, const void *buf, apr_size_t *nbytes, apr_pool_t *pool)
Wrapper for apr_file_write().
svn_error_t * svn_io_temp_dir(const char **dir, apr_pool_t *pool)
Set *dir to a directory path (allocated in pool) deemed usable for the creation of temporary files an...
svn_error_t * svn_io_file_move(const char *from_path, const char *to_path, apr_pool_t *pool)
Move the file from from_path to to_path, even across device boundaries.
svn_error_t * svn_io_check_resolved_path(const char *path, svn_node_kind_t *kind, apr_pool_t *pool)
Like svn_io_check_path(), but resolve symlinks.
svn_error_t * svn_io_set_file_executable(const char *path, svn_boolean_t executable, svn_boolean_t ignore_enoent, apr_pool_t *pool)
Set path's "executability" (but do nothing if it is a symlink).
svn_error_t * svn_io_remove_dir2(const char *path, svn_boolean_t ignore_enoent, svn_cancel_func_t cancel_func, void *cancel_baton, apr_pool_t *pool)
Recursively remove directory path.
svn_error_t * svn_io_wait_for_cmd(apr_proc_t *cmd_proc, const char *cmd, int *exitcode, apr_exit_why_e *exitwhy, apr_pool_t *pool)
Wait for the process *cmd_proc to complete and optionally retrieve its exit code.
svn_error_t * svn_io_append_file(const char *src, const char *dst, apr_pool_t *pool)
Append src to dst.
svn_error_t * svn_io_dir_close(apr_dir_t *thedir)
Wrapper for apr_dir_close().
svn_error_t * svn_io_remove_dir(const char *path, apr_pool_t *pool)
Similar to svn_io_remove_dir2(), but with ignore_enoent set to FALSE and cancel_func and cancel_baton...
svn_error_t * svn_io_dir_remove_nonrecursive(const char *dirname, apr_pool_t *pool)
Wrapper for apr_dir_remove().
svn_error_t * svn_io_open_uniquely_named(apr_file_t **file, const char **unique_name, const char *dirpath, const char *filename, const char *suffix, svn_io_file_del_t delete_when, apr_pool_t *result_pool, apr_pool_t *scratch_pool)
Open a new file (for reading and writing) with a unique name based on utf-8 encoded filename,...
svn_error_t * svn_io_make_dir_recursively(const char *path, apr_pool_t *pool)
Create directory path on the file system, creating intermediate directories as required,...
svn_error_t * svn_io_file_flush(apr_file_t *file, apr_pool_t *scratch_pool)
Wrapper for apr_file_flush().
svn_error_t * svn_io_get_dirents(apr_hash_t **dirents, const char *path, apr_pool_t *pool)
Similar to svn_io_get_dirents2(), but *dirents is a hash table with svn_node_kind_t values.
svn_error_t * svn_stringbuf_from_file2(svn_stringbuf_t **result, const char *filename, apr_pool_t *pool)
Set *result to a string containing the contents of filename, which is either "-" (indicating that std...
svn_boolean_t svn_io_is_binary_data(const void *buf, apr_size_t len)
Examine up to len bytes of data in buf to determine if the can be considered binary data,...
svn_error_t * svn_stringbuf_from_aprfile(svn_stringbuf_t **result, apr_file_t *file, apr_pool_t *pool)
Sets *result to a string containing the contents of the already opened file.
svn_error_t * svn_io_file_checksum(unsigned char digest[], const char *file, apr_pool_t *pool)
Put the md5 checksum of file into digest.
svn_io_file_del_t
Used as an argument when creating temporary files to indicate when a file should be removed.
Definition svn_io.h:59
@ svn_io_file_del_on_pool_cleanup
Remove when the associated pool is cleared.
Definition svn_io.h:65
@ svn_io_file_del_on_close
Remove when the file is closed.
Definition svn_io.h:63
@ svn_io_file_del_none
No deletion ever.
Definition svn_io.h:61
svn_error_t * svn_io_file_lock(const char *lock_file, svn_boolean_t exclusive, apr_pool_t *pool)
Lock file at lock_file.
svn_error_t * svn_io_start_cmd2(apr_proc_t *cmd_proc, const char *path, const char *cmd, const char *const *args, svn_boolean_t inherit, svn_boolean_t infile_pipe, apr_file_t *infile, svn_boolean_t outfile_pipe, apr_file_t *outfile, svn_boolean_t errfile_pipe, apr_file_t *errfile, apr_pool_t *pool)
Similar to svn_io_start_cmd3() but with env always set to NULL.
svn_error_t * svn_io_stat_dirent(const svn_io_dirent2_t **dirent_p, const char *path, svn_boolean_t ignore_enoent, apr_pool_t *result_pool, apr_pool_t *scratch_pool)
Similar to svn_io_stat_dirent2(), but always passes FALSE for verify_truename.
svn_error_t * svn_io_file_checksum2(svn_checksum_t **checksum, const char *file, svn_checksum_kind_t kind, apr_pool_t *pool)
Return in *checksum the checksum of type kind of file Use pool for temporary allocations and to alloc...
svn_error_t * svn_io_file_putc(char ch, apr_file_t *file, apr_pool_t *pool)
Wrapper for apr_file_putc().
svn_error_t * svn_io_set_file_read_write(const char *path, svn_boolean_t ignore_enoent, apr_pool_t *pool)
Make a file as writable as the operating system allows.
svn_error_t * svn_io_file_flush_to_disk(apr_file_t *file, apr_pool_t *pool)
Flush any unwritten data from file to disk.
svn_error_t * svn_io_is_file_executable(svn_boolean_t *executable, const char *path, apr_pool_t *pool)
Determine whether a file is executable by the current user.
svn_error_t * svn_io_write_unique(const char **tmp_path, const char *dirpath, const void *buf, apr_size_t nbytes, svn_io_file_del_t delete_when, apr_pool_t *pool)
Open a unique file in dirpath, and write nbytes from buf to the file before flushing it to disk and c...
svn_error_t * svn_io_copy_link(const char *src, const char *dst, apr_pool_t *pool)
Copy symbolic link src to dst atomically.
svn_error_t * svn_io_dir_walk(const char *dirname, apr_int32_t wanted, svn_io_walk_func_t walk_func, void *walk_baton, apr_pool_t *pool)
Similar to svn_io_dir_walk(), but only calls walk_func for files of type APR_DIR (directory) and APR_...
svn_io_dirent2_t * svn_io_dirent2_dup(const svn_io_dirent2_t *item, apr_pool_t *result_pool)
Duplicates a svn_io_dirent2_t structure into result_pool.
svn_error_t * svn_io_filesizes_three_different_p(svn_boolean_t *different_p12, svn_boolean_t *different_p23, svn_boolean_t *different_p13, const char *file1, const char *file2, const char *file3, apr_pool_t *scratch_pool)
Set *different_p12 to non-zero if file1 and file2 have different sizes, else set to zero.
svn_error_t * svn_io_file_name_get(const char **filename, apr_file_t *file, apr_pool_t *pool)
Wrapper for apr_file_name_get().
svn_error_t * svn_io_check_special_path(const char *path, svn_node_kind_t *kind, svn_boolean_t *is_special, apr_pool_t *pool)
Like svn_io_check_path(), but also set *is_special to TRUE if the path is not a normal file.
svn_error_t * svn_io_write_atomic(const char *final_path, const void *buf, apr_size_t nbytes, const char *copy_perms_path, apr_pool_t *scratch_pool)
Similar to svn_io_write_atomic2(), but with flush_to_disk set to TRUE.
svn_error_t * svn_io_file_open(apr_file_t **new_file, const char *fname, apr_int32_t flag, apr_fileperms_t perm, apr_pool_t *pool)
Wrapper for apr_file_open().
svn_error_t * svn_io_parse_mimetypes_file(apr_hash_t **type_map, const char *mimetypes_file, apr_pool_t *pool)
Parse utf8-encoded mimetypes_file as a MIME types file (such as is provided with Apache HTTP Server),...
svn_error_t * svn_io_create_unique_link(const char **unique_name_p, const char *path, const char *dest, const char *suffix, apr_pool_t *pool)
Like svn_io_open_unique_file(), except that instead of creating a file, a symlink is generated that r...
svn_error_t * svn_io_file_size_get(svn_filesize_t *filesize_p, apr_file_t *file, apr_pool_t *pool)
Set *filesize_p to the size of file.
svn_error_t * svn_io_run_diff2(const char *dir, const char *const *user_args, int num_user_args, const char *label1, const char *label2, const char *from, const char *to, int *exitcode, apr_file_t *outfile, apr_file_t *errfile, const char *diff_cmd, apr_pool_t *pool)
Invoke the configured diff program, with user_args (an array of utf8-encoded num_user_args arguments)...
svn_error_t * svn_io_get_dir_filenames(apr_hash_t **dirents, const char *path, apr_pool_t *pool)
Read all of the disk entries in directory path, a utf8-encoded path.
svn_error_t * svn_io_file_create(const char *file, const char *contents, apr_pool_t *pool)
Create a file at utf8-encoded path file with the contents given by the null-terminated string content...
svn_error_t * svn_io_get_dirents2(apr_hash_t **dirents, const char *path, apr_pool_t *pool)
Similar to svn_io_get_dirents3, but returns a mapping to svn_io_dirent_t structures instead of svn_io...
svn_error_t * svn_io_open_unique_file3(apr_file_t **file, const char **temp_path, const char *dirpath, svn_io_file_del_t delete_when, apr_pool_t *result_pool, apr_pool_t *scratch_pool)
Create a writable file, with an arbitrary and unique name, in the directory dirpath.
svn_error_t *(* svn_io_walk_func_t)(void *baton, const char *path, const apr_finfo_t *finfo, apr_pool_t *pool)
Callback function type for svn_io_dir_walk().
Definition svn_io.h:1868
svn_error_t * svn_io_set_file_read_write_carefully(const char *path, svn_boolean_t enable_write, svn_boolean_t ignore_enoent, apr_pool_t *pool)
Similar to svn_io_set_file_read_* functions.
svn_error_t * svn_io_unlock_open_file(apr_file_t *lockfile_handle, apr_pool_t *pool)
Unlock the file lockfile_handle.
svn_error_t * svn_io_filesizes_different_p(svn_boolean_t *different_p, const char *file1, const char *file2, apr_pool_t *pool)
Set *different_p to TRUE if file1 and file2 have different sizes, else set to FALSE.
svn_error_t * svn_io_copy_dir_recursively(const char *src, const char *dst_parent, const char *dst_basename, svn_boolean_t copy_perms, svn_cancel_func_t cancel_func, void *cancel_baton, apr_pool_t *pool)
Recursively copy directory src into dst_parent, as a new entry named dst_basename.
svn_error_t * svn_io_file_trunc(apr_file_t *file, apr_off_t offset, apr_pool_t *pool)
Wrapper for apr_file_trunc().
svn_error_t * svn_io_remove_file2(const char *path, svn_boolean_t ignore_enoent, apr_pool_t *scratch_pool)
Remove file path, a utf8-encoded path.
svn_error_t * svn_io_dir_file_copy(const char *src_path, const char *dest_path, const char *file, apr_pool_t *pool)
Copy the file whose basename (or relative path) is file within directory src_path to the same basenam...
svn_error_t * svn_io_file_create_empty(const char *file, apr_pool_t *scratch_pool)
Create an empty file at utf8-encoded path file.
svn_error_t * svn_io_detect_mimetype(const char **mimetype, const char *file, apr_pool_t *pool)
Like svn_io_detect_mimetype2, but with mimetypes_map set to NULL.
svn_error_t * svn_io_dir_make(const char *path, apr_fileperms_t perm, apr_pool_t *pool)
Wrapper for apr_dir_make().
svn_error_t * svn_io_read_link(svn_string_t **dest, const char *path, apr_pool_t *pool)
Set *dest to the path that the symlink at path references.
svn_error_t * svn_io_file_aligned_seek(apr_file_t *file, apr_off_t block_size, apr_off_t *buffer_start, apr_off_t offset, apr_pool_t *scratch_pool)
Set the file pointer of the APR_BUFFERED file to offset.
svn_error_t * svn_io_file_getc(char *ch, apr_file_t *file, apr_pool_t *pool)
Wrapper for apr_file_getc().
svn_error_t * svn_io_file_read_full(apr_file_t *file, void *buf, apr_size_t nbytes, apr_size_t *bytes_read, apr_pool_t *pool)
Similar to svn_io_file_read_full2 with hit_eof being set to NULL.
svn_error_t * svn_io_dir_read(apr_finfo_t *finfo, apr_int32_t wanted, apr_dir_t *thedir, apr_pool_t *pool)
Wrapper for apr_dir_read().
svn_error_t * svn_io_copy_perms(const char *src, const char *dst, apr_pool_t *pool)
Copy permission flags from src onto the file at dst.
svn_error_t * svn_io_dir_walk2(const char *dirname, apr_int32_t wanted, svn_io_walk_func_t walk_func, void *walk_baton, apr_pool_t *pool)
Recursively walk the directory rooted at dirname, a utf8-encoded path, invoking walk_func (with walk_...
svn_error_t * svn_io_detect_mimetype2(const char **mimetype, const char *file, apr_hash_t *mimetype_map, apr_pool_t *pool)
Examine utf8-encoded file to determine if it can be described by a known (as in, known by this functi...
Counted-length strings for Subversion, plus some C string goodies.
Subversion's data types.
int svn_boolean_t
YABT: Yet Another Boolean Type.
Definition svn_types.h:137
apr_int64_t svn_filesize_t
The size of a file in the Subversion FS.
Definition svn_types.h:430
svn_error_t *(* svn_cancel_func_t)(void *cancel_baton)
A user defined callback that subversion will call with a user defined baton to see if the current ope...
Definition svn_types.h:1081
#define SVN_DEPRECATED
Macro used to mark deprecated functions.
Definition svn_types.h:62
svn_node_kind_t
The various types of nodes in the Subversion filesystem.