3 * ====================================================================
\r
4 * Copyright (c) 2000-2008 CollabNet. All rights reserved.
\r
6 * This software is licensed as described in the file COPYING, which
\r
7 * you should have received as part of this distribution. The terms
\r
8 * are also available at http://subversion.tigris.org/license-1.html.
\r
9 * If newer versions of this license are posted there, you may use a
\r
10 * newer version instead, at your option.
\r
12 * This software consists of voluntary contributions made by many
\r
13 * individuals. For exact contribution history, see the revision
\r
14 * history and logs, available at http://subversion.tigris.org/.
\r
15 * ====================================================================
\r
19 * @brief General file I/O for Subversion
\r
22 /* ==================================================================== */
\r
29 #include <apr_pools.h>
\r
30 #include <apr_time.h>
\r
31 #include <apr_hash.h>
\r
32 #include <apr_tables.h>
\r
33 #include <apr_file_io.h>
\r
34 #include <apr_file_info.h>
\r
35 #include <apr_thread_proc.h> /* for apr_proc_t, apr_exit_why_e */
\r
37 #include "svn_types.h"
\r
38 #include "svn_string.h"
\r
39 #include "svn_checksum.h"
\r
43 #endif /* __cplusplus */
\r
47 /** Used as an argument when creating temporary files to indicate
\r
48 * when a file should be removed.
\r
50 * @since New in 1.4.
\r
52 * Not specifying any of these means no removal at all. */
\r
53 typedef enum svn_io_file_del_t
\r
55 /** No deletion ever */
\r
56 svn_io_file_del_none = 0,
\r
57 /** Remove when the file is closed */
\r
58 svn_io_file_del_on_close,
\r
59 /** Remove when the associated pool is cleared */
\r
60 svn_io_file_del_on_pool_cleanup
\r
61 } svn_io_file_del_t;
\r
65 /** Represents the kind and special status of a directory entry.
\r
67 * @since New in 1.3.
\r
69 typedef struct svn_io_dirent_t {
\r
70 /** The kind of this entry. */
\r
71 svn_node_kind_t kind;
\r
72 /** If @c kind is @c svn_node_file, whether this entry is a special file;
\r
75 * @see svn_io_check_special_path().
\r
77 svn_boolean_t special;
\r
80 /** Determine the @a kind of @a path. @a path should be UTF-8 encoded.
\r
82 * If @a path is a file, set @a *kind to @c svn_node_file.
\r
84 * If @a path is a directory, set @a *kind to @c svn_node_dir.
\r
86 * If @a path does not exist, set @a *kind to @c svn_node_none.
\r
88 * If @a path exists but is none of the above, set @a *kind to @c
\r
91 * If unable to determine @a path's kind, return an error, with @a *kind's
\r
94 * Use @a pool for temporary allocations.
\r
96 * @see svn_node_kind_t
\r
99 svn_io_check_path(const char *path,
\r
100 svn_node_kind_t *kind,
\r
104 * Like svn_io_check_path(), but also set *is_special to @c TRUE if
\r
105 * the path is not a normal file.
\r
107 * @since New in 1.1.
\r
110 svn_io_check_special_path(const char *path,
\r
111 svn_node_kind_t *kind,
\r
112 svn_boolean_t *is_special,
\r
115 /** Like svn_io_check_path(), but resolve symlinks. This returns the
\r
116 same varieties of @a kind as svn_io_check_path(). */
\r
118 svn_io_check_resolved_path(const char *path,
\r
119 svn_node_kind_t *kind,
\r
123 /** Open a new file (for reading and writing) with a unique name based on
\r
124 * utf-8 encoded @a filename, in the directory @a dirpath. The file handle is
\r
125 * returned in @a *file, and the name, which ends with @a suffix, is returned
\r
126 * in @a *unique_name, also utf8-encoded. Either @a file or @a unique_name
\r
129 * If @a delete_when is @c svn_io_file_del_on_close, then the @c APR_DELONCLOSE
\r
130 * flag will be used when opening the file. The @c APR_BUFFERED flag will
\r
133 * The first attempt will just append @a suffix. If the result is not
\r
134 * a unique name, then subsequent attempts will append a dot,
\r
135 * followed by an iteration number ("2", then "3", and so on),
\r
136 * followed by the suffix. For example, successive calls to
\r
138 * svn_io_open_uniquely_named(&f, &u, "tests/t1/A/D/G", "pi", ".tmp", ...)
\r
142 * tests/t1/A/D/G/pi.tmp
\r
143 * tests/t1/A/D/G/pi.2.tmp
\r
144 * tests/t1/A/D/G/pi.3.tmp
\r
145 * tests/t1/A/D/G/pi.4.tmp
\r
146 * tests/t1/A/D/G/pi.5.tmp
\r
149 * Assuming @a suffix is non-empty, @a *unique_name will never be exactly
\r
150 * the same as @a filename, even if @a filename does not exist.
\r
152 * If @a dirpath is NULL, then the directory returned by svn_io_temp_dir()
\r
155 * If @a filename is NULL, then "tempfile" will be used.
\r
157 * If @a suffix is NULL, then ".tmp" will be used.
\r
159 * Allocates @a *file and @a *unique_name in @a result_pool. All
\r
160 * intermediate allocations will be performed in @a scratch_pool.
\r
162 * If no unique name can be found, @c SVN_ERR_IO_UNIQUE_NAMES_EXHAUSTED is
\r
163 * the error returned.
\r
165 * Claim of Historical Inevitability: this function was written
\r
168 * - tmpnam() is not thread-safe.
\r
169 * - tempname() tries standard system tmp areas first.
\r
171 * @since New in 1.6
\r
174 svn_io_open_uniquely_named(apr_file_t **file,
\r
175 const char **unique_name,
\r
176 const char *dirpath,
\r
177 const char *filename,
\r
178 const char *suffix,
\r
179 svn_io_file_del_t delete_when,
\r
180 apr_pool_t *result_pool,
\r
181 apr_pool_t *scratch_pool);
\r
184 /** Create a writable file in the directory @a dirpath. The file will have
\r
185 * an arbitrary and unique name, and the full path will be returned in
\r
186 * @a temp_path. The file will be returned in @a file. Both will be
\r
187 * allocated from @a result_pool.
\r
189 * If @a dirpath is @c NULL, use the path returned from svn_io_temp_dir().
\r
190 * (Note that when using the system-provided temp directory, it may not
\r
191 * be possibly to atomically rename the resulting file due to cross-device
\r
194 * The file will be deleted according to @a delete_when.
\r
196 * Temporary allocations will be performed in @a scratch_pool.
\r
198 * @since New in 1.6
\r
199 * @see svn_stream_open_unique()
\r
202 svn_io_open_unique_file3(apr_file_t **file,
\r
203 const char **temp_path,
\r
204 const char *dirpath,
\r
205 svn_io_file_del_t delete_when,
\r
206 apr_pool_t *result_pool,
\r
207 apr_pool_t *scratch_pool);
\r
210 /** Like svn_io_open_uniquely_named(), but takes a joined dirpath and
\r
211 * filename, and a single pool.
\r
213 * @since New in 1.4
\r
215 * @deprecated Provided for backward compatibility with the 1.5 API
\r
219 svn_io_open_unique_file2(apr_file_t **f,
\r
220 const char **unique_name_p,
\r
222 const char *suffix,
\r
223 svn_io_file_del_t delete_when,
\r
226 /** Like svn_io_open_unique_file2, but can't delete on pool cleanup.
\r
228 * @deprecated Provided for backward compatibility with the 1.0 API
\r
230 * @note In 1.4 the API was extended to require either @a f or
\r
231 * @a unique_name_p (the other can be NULL). Before that, both were
\r
236 svn_io_open_unique_file(apr_file_t **f,
\r
237 const char **unique_name_p,
\r
239 const char *suffix,
\r
240 svn_boolean_t delete_on_close,
\r
245 * Like svn_io_open_unique_file(), except that instead of creating a
\r
246 * file, a symlink is generated that references the path @a dest.
\r
248 * @since New in 1.1.
\r
251 svn_io_create_unique_link(const char **unique_name_p,
\r
254 const char *suffix,
\r
259 * Set @a *dest to the path that the symlink at @a path references.
\r
260 * Allocate the string from @a pool.
\r
262 * @since New in 1.1.
\r
265 svn_io_read_link(svn_string_t **dest,
\r
270 /** Set @a *dir to a directory path (allocated in @a pool) deemed
\r
271 * usable for the creation of temporary files and subdirectories.
\r
274 svn_io_temp_dir(const char **dir,
\r
278 /** Copy @a src to @a dst atomically, in a "byte-for-byte" manner.
\r
279 * Overwrite @a dst if it exists, else create it. Both @a src and @a dst
\r
280 * are utf8-encoded filenames. If @a copy_perms is TRUE, set @a dst's
\r
281 * permissions to match those of @a src.
\r
284 svn_io_copy_file(const char *src,
\r
286 svn_boolean_t copy_perms,
\r
290 /** Copy permission flags from @a src onto the file at @a dst. Both
\r
291 * filenames are utf8-encoded filenames.
\r
294 svn_io_copy_perms(const char *src,
\r
300 * Copy symbolic link @a src to @a dst atomically. Overwrite @a dst
\r
301 * if it exists, else create it. Both @a src and @a dst are
\r
302 * utf8-encoded filenames. After copying, the @a dst link will point
\r
303 * to the same thing @a src does.
\r
305 * @since New in 1.1.
\r
308 svn_io_copy_link(const char *src,
\r
313 /** Recursively copy directory @a src into @a dst_parent, as a new entry named
\r
314 * @a dst_basename. If @a dst_basename already exists in @a dst_parent,
\r
315 * return error. @a copy_perms will be passed through to svn_io_copy_file()
\r
316 * when any files are copied. @a src, @a dst_parent, and @a dst_basename are
\r
317 * all utf8-encoded.
\r
319 * If @a cancel_func is non-NULL, invoke it with @a cancel_baton at
\r
320 * various points during the operation. If it returns any error
\r
321 * (typically @c SVN_ERR_CANCELLED), return that error immediately.
\r
324 svn_io_copy_dir_recursively(const char *src,
\r
325 const char *dst_parent,
\r
326 const char *dst_basename,
\r
327 svn_boolean_t copy_perms,
\r
328 svn_cancel_func_t cancel_func,
\r
329 void *cancel_baton,
\r
333 /** Create directory @a path on the file system, creating intermediate
\r
334 * directories as required, like <tt>mkdir -p</tt>. Report no error if @a
\r
335 * path already exists. @a path is utf8-encoded.
\r
337 * This is essentially a wrapper for apr_dir_make_recursive(), passing
\r
338 * @c APR_OS_DEFAULT as the permissions.
\r
341 svn_io_make_dir_recursively(const char *path,
\r
345 /** Set @a *is_empty_p to @c TRUE if directory @a path is empty, else to
\r
346 * @c FALSE if it is not empty. @a path must be a directory, and is
\r
347 * utf8-encoded. Use @a pool for temporary allocation.
\r
350 svn_io_dir_empty(svn_boolean_t *is_empty_p,
\r
355 /** Append @a src to @a dst. @a dst will be appended to if it exists, else it
\r
356 * will be created. Both @a src and @a dst are utf8-encoded.
\r
359 svn_io_append_file(const char *src,
\r
364 /** Make a file as read-only as the operating system allows.
\r
365 * @a path is the utf8-encoded path to the file. If @a ignore_enoent is
\r
366 * @c TRUE, don't fail if the target file doesn't exist.
\r
368 * If @a path is a symlink, do nothing.
\r
370 * @note If @a path is a directory, act on it as though it were a
\r
371 * file, as described above, but note that you probably don't want to
\r
372 * call this function on directories. We have left it effective on
\r
373 * directories for compatibility reasons, but as its name implies, it
\r
374 * should be used only for files.
\r
377 svn_io_set_file_read_only(const char *path,
\r
378 svn_boolean_t ignore_enoent,
\r
382 /** Make a file as writable as the operating system allows.
\r
383 * @a path is the utf8-encoded path to the file. If @a ignore_enoent is
\r
384 * @c TRUE, don't fail if the target file doesn't exist.
\r
385 * @warning On Unix this function will do the equivalent of chmod a+w path.
\r
386 * If this is not what you want you should not use this function, but rather
\r
387 * use apr_file_perms_set().
\r
389 * If @a path is a symlink, do nothing.
\r
391 * @note If @a path is a directory, act on it as though it were a
\r
392 * file, as described above, but note that you probably don't want to
\r
393 * call this function on directories. We have left it effective on
\r
394 * directories for compatibility reasons, but as its name implies, it
\r
395 * should be used only for files.
\r
398 svn_io_set_file_read_write(const char *path,
\r
399 svn_boolean_t ignore_enoent,
\r
403 /** Similar to svn_io_set_file_read_* functions.
\r
404 * Change the read-write permissions of a file.
\r
405 * @since New in 1.1.
\r
407 * When making @a path read-write on operating systems with unix style
\r
408 * permissions, set the permissions on @a path to the permissions that
\r
409 * are set when a new file is created (effectively honoring the user's
\r
412 * When making the file read-only on operating systems with unix style
\r
413 * permissions, remove all write permissions.
\r
415 * On other operating systems, toggle the file's "writability" as much as
\r
416 * the operating system allows.
\r
418 * @a path is the utf8-encoded path to the file. If @a enable_write
\r
419 * is @c TRUE, then make the file read-write. If @c FALSE, make it
\r
420 * read-only. If @a ignore_enoent is @c TRUE, don't fail if the target
\r
421 * file doesn't exist.
\r
423 * @deprecated Provided for backward compatibility with the 1.3 API.
\r
427 svn_io_set_file_read_write_carefully(const char *path,
\r
428 svn_boolean_t enable_write,
\r
429 svn_boolean_t ignore_enoent,
\r
432 /** Set @a path's "executability" (but do nothing if it is a symlink).
\r
434 * @a path is the utf8-encoded path to the file. If @a executable
\r
435 * is @c TRUE, then make the file executable. If @c FALSE, make it
\r
436 * non-executable. If @a ignore_enoent is @c TRUE, don't fail if the target
\r
437 * file doesn't exist.
\r
439 * When making the file executable on operating systems with unix style
\r
440 * permissions, never add an execute permission where there is not
\r
441 * already a read permission: that is, only make the file executable
\r
442 * for the user, group or world if the corresponding read permission
\r
443 * is already set for user, group or world.
\r
445 * When making the file non-executable on operating systems with unix style
\r
446 * permissions, remove all execute permissions.
\r
448 * On other operating systems, toggle the file's "executability" as much as
\r
449 * the operating system allows.
\r
451 * @note If @a path is a directory, act on it as though it were a
\r
452 * file, as described above, but note that you probably don't want to
\r
453 * call this function on directories. We have left it effective on
\r
454 * directories for compatibility reasons, but as its name implies, it
\r
455 * should be used only for files.
\r
458 svn_io_set_file_executable(const char *path,
\r
459 svn_boolean_t executable,
\r
460 svn_boolean_t ignore_enoent,
\r
463 /** Determine whether a file is executable by the current user.
\r
464 * Set @a *executable to @c TRUE if the file @a path is executable by the
\r
465 * current user, otherwise set it to @c FALSE.
\r
467 * On Windows and on platforms without userids, always returns @c FALSE.
\r
470 svn_io_is_file_executable(svn_boolean_t *executable,
\r
475 /** Read a line from @a file into @a buf, but not exceeding @a *limit bytes.
\r
476 * Does not include newline, instead '\\0' is put there.
\r
477 * Length (as in strlen) is returned in @a *limit.
\r
478 * @a buf should be pre-allocated.
\r
479 * @a file should be already opened.
\r
481 * When the file is out of lines, @c APR_EOF will be returned.
\r
484 svn_io_read_length_line(apr_file_t *file,
\r
490 /** Set @a *apr_time to the time of last modification of the contents of the
\r
491 * file @a path. @a path is utf8-encoded.
\r
493 * @note This is the APR mtime which corresponds to the traditional mtime
\r
494 * on Unix, and the last write time on Windows.
\r
497 svn_io_file_affected_time(apr_time_t *apr_time,
\r
501 /** Set the timestamp of file @a path to @a apr_time. @a path is
\r
504 * @note This is the APR mtime which corresponds to the traditional mtime
\r
505 * on Unix, and the last write time on Windows.
\r
508 svn_io_set_file_affected_time(apr_time_t apr_time,
\r
512 /** Sleep to ensure that any files modified after we exit have a different
\r
513 * timestamp than the one we recorded. If @a path is not NULL, check if we
\r
514 * can determine how long we should wait for a new timestamp on the filesystem
\r
515 * containing @a path, an existing file or directory. If @a path is NULL or we
\r
516 * can't determine the timestamp resolution, sleep until the next second.
\r
518 * Use @a pool for any necessary allocations. @a pool can be null if @a path
\r
521 * Errors while retrieving the timestamp resolution will result in sleeping
\r
522 * to the next second, to keep the working copy stable in error conditions.
\r
524 * @since New in 1.6.
\r
527 svn_io_sleep_for_timestamps(const char *path, apr_pool_t *pool);
\r
529 /** Set @a *different_p to non-zero if @a file1 and @a file2 have different
\r
530 * sizes, else set to zero. Both @a file1 and @a file2 are utf8-encoded.
\r
532 * Setting @a *different_p to zero does not mean the files definitely
\r
533 * have the same size, it merely means that the sizes are not
\r
534 * definitely different. That is, if the size of one or both files
\r
535 * cannot be determined, then the sizes are not known to be different,
\r
536 * so @a *different_p is set to 0.
\r
539 svn_io_filesizes_different_p(svn_boolean_t *different_p,
\r
545 /** Return in @a *checksum the checksum of type @a kind of @a file
\r
546 * Use @a pool for temporary allocations and to allocate @a *checksum.
\r
548 * @since New in 1.6.
\r
551 svn_io_file_checksum2(svn_checksum_t **checksum,
\r
553 svn_checksum_kind_t kind,
\r
557 /** Put the md5 checksum of @a file into @a digest.
\r
558 * @a digest points to @c APR_MD5_DIGESTSIZE bytes of storage.
\r
559 * Use @a pool only for temporary allocations.
\r
561 * @deprecated Provided for backward compatibility with the 1.5 API.
\r
565 svn_io_file_checksum(unsigned char digest[],
\r
570 /** Set @a *same to TRUE if @a file1 and @a file2 have the same
\r
571 * contents, else set it to FALSE. Use @a pool for temporary allocations.
\r
574 svn_io_files_contents_same_p(svn_boolean_t *same,
\r
579 /** Create file at utf8-encoded @a file with contents @a contents.
\r
580 * @a file must not already exist.
\r
581 * Use @a pool for memory allocations.
\r
584 svn_io_file_create(const char *file,
\r
585 const char *contents,
\r
589 * Lock file at @a lock_file. If @a exclusive is TRUE,
\r
590 * obtain exclusive lock, otherwise obtain shared lock.
\r
591 * Lock will be automatically released when @a pool is cleared or destroyed.
\r
592 * Use @a pool for memory allocations.
\r
594 * @deprecated Provided for backward compatibility with the 1.0 API.
\r
598 svn_io_file_lock(const char *lock_file,
\r
599 svn_boolean_t exclusive,
\r
603 * Lock file at @a lock_file. If @a exclusive is TRUE,
\r
604 * obtain exclusive lock, otherwise obtain shared lock.
\r
606 * If @a nonblocking is TRUE, do not wait for the lock if it
\r
607 * is not available: throw an error instead.
\r
609 * Lock will be automatically released when @a pool is cleared or destroyed.
\r
610 * Use @a pool for memory allocations.
\r
612 * @since New in 1.1.
\r
615 svn_io_file_lock2(const char *lock_file,
\r
616 svn_boolean_t exclusive,
\r
617 svn_boolean_t nonblocking,
\r
620 * Flush any unwritten data from @a file to disk. Use @a pool for
\r
621 * memory allocations.
\r
623 * @since New in 1.1.
\r
626 svn_io_file_flush_to_disk(apr_file_t *file,
\r
629 /** Copy file @a file from location @a src_path to location @a dest_path.
\r
630 * Use @a pool for memory allocations.
\r
633 svn_io_dir_file_copy(const char *src_path,
\r
634 const char *dest_path,
\r
639 /** Generic byte-streams
\r
641 * @defgroup svn_io_byte_streams Generic byte streams
\r
645 /** An abstract stream of bytes--either incoming or outgoing or both.
\r
647 * The creator of a stream sets functions to handle read and write.
\r
648 * Both of these handlers accept a baton whose value is determined at
\r
649 * stream creation time; this baton can point to a structure
\r
650 * containing data associated with the stream. If a caller attempts
\r
651 * to invoke a handler which has not been set, it will generate a
\r
652 * runtime assertion failure. The creator can also set a handler for
\r
653 * close requests so that it can flush buffered data or whatever;
\r
654 * if a close handler is not specified, a close request on the stream
\r
655 * will simply be ignored. Note that svn_stream_close() does not
\r
656 * deallocate the memory used to allocate the stream structure; free
\r
657 * the pool you created the stream in to free that memory.
\r
659 * The read and write handlers accept length arguments via pointer.
\r
660 * On entry to the handler, the pointed-to value should be the amount
\r
661 * of data which can be read or the amount of data to write. When the
\r
662 * handler returns, the value is reset to the amount of data actually
\r
663 * read or written. Handlers are obliged to complete a read or write
\r
664 * to the maximum extent possible; thus, a short read with no
\r
665 * associated error implies the end of the input stream, and a short
\r
666 * write should never occur without an associated error.
\r
668 typedef struct svn_stream_t svn_stream_t;
\r
672 /** Read handler function for a generic stream. @see svn_stream_t. */
\r
673 typedef svn_error_t *(*svn_read_fn_t)(void *baton,
\r
677 /** Write handler function for a generic stream. @see svn_stream_t. */
\r
678 typedef svn_error_t *(*svn_write_fn_t)(void *baton,
\r
682 /** Close handler function for a generic stream. @see svn_stream_t. */
\r
683 typedef svn_error_t *(*svn_close_fn_t)(void *baton);
\r
686 /** Create a generic stream. @see svn_stream_t. */
\r
688 svn_stream_create(void *baton,
\r
691 /** Set @a stream's baton to @a baton */
\r
693 svn_stream_set_baton(svn_stream_t *stream,
\r
696 /** Set @a stream's read function to @a read_fn */
\r
698 svn_stream_set_read(svn_stream_t *stream,
\r
699 svn_read_fn_t read_fn);
\r
701 /** Set @a stream's write function to @a write_fn */
\r
703 svn_stream_set_write(svn_stream_t *stream,
\r
704 svn_write_fn_t write_fn);
\r
706 /** Set @a stream's close function to @a close_fn */
\r
708 svn_stream_set_close(svn_stream_t *stream,
\r
709 svn_close_fn_t close_fn);
\r
712 /** Create a stream that is empty for reading and infinite for writing. */
\r
714 svn_stream_empty(apr_pool_t *pool);
\r
716 /** Return a stream allocated in @a pool which forwards all requests
\r
717 * to @a stream. Destruction is explicitly excluded from forwarding.
\r
719 * @see notes/destruction-of-stacked-resources
\r
721 * @since New in 1.4.
\r
724 svn_stream_disown(svn_stream_t *stream,
\r
728 /** Create a stream to read the file at @a path. It will be opened using
\r
729 * the APR_BUFFERED and APR_BINARY flag, and APR_OS_DEFAULT for the perms.
\r
730 * If you'd like to use different values, then open the file yourself, and
\r
731 * use the svn_stream_from_aprfile2() interface.
\r
733 * The stream will be returned in @a stream, and allocated from @a result_pool.
\r
734 * Temporary allocations will be performed in @a scratch_pool.
\r
736 * @since New in 1.6
\r
739 svn_stream_open_readonly(svn_stream_t **stream,
\r
741 apr_pool_t *result_pool,
\r
742 apr_pool_t *scratch_pool);
\r
745 /** Create a stream to write a file at @a path. The file will be *created*
\r
746 * using the APR_BUFFERED and APR_BINARY flag, and APR_OS_DEFAULT for the
\r
747 * perms. The file will be created "exclusively", so if it already exists,
\r
748 * then an error will be thrown. If you'd like to use different values, or
\r
749 * open an existing file, then open the file yourself, and use the
\r
750 * svn_stream_from_aprfile2() interface.
\r
752 * The stream will be returned in @a stream, and allocated from @a result_pool.
\r
753 * Temporary allocations will be performed in @a scratch_pool.
\r
755 * @since New in 1.6
\r
758 svn_stream_open_writable(svn_stream_t **stream,
\r
760 apr_pool_t *result_pool,
\r
761 apr_pool_t *scratch_pool);
\r
764 /** Create a writable stream to a file in the directory @a dirpath.
\r
765 * The file will have an arbitrary and unique name, and the full path
\r
766 * will be returned in @a temp_path. The stream will be returned in
\r
767 * @a stream. Both will be allocated from @a result_pool.
\r
769 * If @a dirpath is @c NULL, use the path returned from svn_io_temp_dir().
\r
770 * (Note that when using the system-provided temp directory, it may not
\r
771 * be possibly to atomically rename the resulting file due to cross-device
\r
774 * The file will be deleted according to @a delete_when.
\r
776 * Temporary allocations will be performed in @a scratch_pool.
\r
778 * @since New in 1.6
\r
779 * @see svn_io_open_unique_file3()
\r
782 svn_stream_open_unique(svn_stream_t **stream,
\r
783 const char **temp_path,
\r
784 const char *dirpath,
\r
785 svn_io_file_del_t delete_when,
\r
786 apr_pool_t *result_pool,
\r
787 apr_pool_t *scratch_pool);
\r
790 /** Create a stream from an APR file. For convenience, if @a file is
\r
791 * @c NULL, an empty stream created by svn_stream_empty() is returned.
\r
793 * This function should normally be called with @a disown set to FALSE,
\r
794 * in which case closing the stream will also close the underlying file.
\r
796 * If @a disown is TRUE, the stream will disown the underlying file,
\r
797 * meaning that svn_stream_close() will not close the file.
\r
799 * @since New in 1.4.
\r
802 svn_stream_from_aprfile2(apr_file_t *file,
\r
803 svn_boolean_t disown,
\r
806 /** Similar to svn_stream_from_aprfile2(), except that the file will
\r
807 * always be disowned.
\r
809 * @note The stream returned is not considered to "own" the underlying
\r
810 * file, meaning that svn_stream_close() on the stream will not
\r
813 * @deprecated Provided for backward compatibility with the 1.3 API.
\r
817 svn_stream_from_aprfile(apr_file_t *file,
\r
820 /** Set @a *out to a generic stream connected to stdout, allocated in
\r
821 * @a pool. The stream and its underlying APR handle will be closed
\r
822 * when @a pool is cleared or destroyed.
\r
825 svn_stream_for_stdout(svn_stream_t **out,
\r
828 /** Return a generic stream connected to stringbuf @a str. Allocate the
\r
829 * stream in @a pool.
\r
832 svn_stream_from_stringbuf(svn_stringbuf_t *str,
\r
835 /** Return a generic read-only stream connected to string @a str.
\r
836 * Allocate the stream in @a pool.
\r
839 svn_stream_from_string(const svn_string_t *str,
\r
842 /** Return a stream that decompresses all data read and compresses all
\r
843 * data written. The stream @a stream is used to read and write all
\r
844 * compressed data. All compression data structures are allocated on
\r
845 * @a pool. If compression support is not compiled in then
\r
846 * svn_stream_compressed() returns @a stream unmodified. Make sure you
\r
847 * call svn_stream_close() on the stream returned by this function,
\r
848 * so that all data are flushed and cleaned up.
\r
850 * @note From 1.4, compression support is always compiled in.
\r
853 svn_stream_compressed(svn_stream_t *stream,
\r
856 /** Return a stream that calculates checksums for all data read
\r
857 * and written. The stream @a stream is used to read and write all data.
\r
858 * The stream and the resulting digests are allocated in @a pool.
\r
860 * When the stream is closed, @a *read_checksum and @a *write_checksum
\r
861 * are set to point to the resulting checksums, of type @a read_checksum_kind
\r
862 * and @a write_checksum_kind, respectively.
\r
864 * Both @a read_checksum and @a write_checksum can be @c NULL, in which case
\r
865 * the respective checksum isn't calculated.
\r
867 * If @a read_all is TRUE, make sure that all data available on @a
\r
868 * stream is read (and checksummed) when the stream is closed.
\r
870 * Read and write operations can be mixed without interfering.
\r
872 * The @a stream passed into this function is closed when the created
\r
873 * stream is closed.
\r
875 * @since New in 1.6.
\r
878 svn_stream_checksummed2(svn_stream_t *stream,
\r
879 svn_checksum_t **read_checksum,
\r
880 svn_checksum_t **write_checksum,
\r
881 svn_checksum_kind_t checksum_kind,
\r
882 svn_boolean_t read_all,
\r
886 * Similar to svn_stream_checksummed2(), but always returning the MD5
\r
887 * checksum in @a read_digest and @a write_digest.
\r
889 * @since New in 1.4.
\r
890 * @deprecated Provided for backward compatibility with the 1.5 API.
\r
894 svn_stream_checksummed(svn_stream_t *stream,
\r
895 const unsigned char **read_digest,
\r
896 const unsigned char **write_digest,
\r
897 svn_boolean_t read_all,
\r
900 /** Read from a generic stream. @see svn_stream_t. */
\r
902 svn_stream_read(svn_stream_t *stream,
\r
906 /** Write to a generic stream. @see svn_stream_t. */
\r
908 svn_stream_write(svn_stream_t *stream,
\r
912 /** Close a generic stream. @see svn_stream_t. */
\r
914 svn_stream_close(svn_stream_t *stream);
\r
917 /** Write to @a stream using a printf-style @a fmt specifier, passed through
\r
918 * apr_psprintf() using memory from @a pool.
\r
921 svn_stream_printf(svn_stream_t *stream,
\r
925 __attribute__((format(printf, 3, 4)));
\r
927 /** Write to @a stream using a printf-style @a fmt specifier, passed through
\r
928 * apr_psprintf() using memory from @a pool. The resulting string
\r
929 * will be translated to @a encoding before it is sent to @a stream.
\r
931 * @note Use @c APR_LOCALE_CHARSET to translate to the encoding of the
\r
934 * @since New in 1.3.
\r
937 svn_stream_printf_from_utf8(svn_stream_t *stream,
\r
938 const char *encoding,
\r
942 __attribute__((format(printf, 4, 5)));
\r
944 /** Allocate @a *stringbuf in @a pool, and read into it one line (terminated
\r
945 * by @a eol) from @a stream. The line-terminator is read from the stream,
\r
946 * but is not added to the end of the stringbuf. Instead, the stringbuf
\r
947 * ends with a usual '\\0'.
\r
949 * If @a stream runs out of bytes before encountering a line-terminator,
\r
950 * then set @a *eof to @c TRUE, otherwise set @a *eof to FALSE.
\r
953 svn_stream_readline(svn_stream_t *stream,
\r
954 svn_stringbuf_t **stringbuf,
\r
956 svn_boolean_t *eof,
\r
961 * Read the contents of the readable stream @a from and write them to the
\r
962 * writable stream @a to calling @a cancel_func before copying each chunk.
\r
964 * @a cancel_func may be @c NULL.
\r
966 * @note both @a from and @a to will be closed upon successful completion of
\r
967 * the copy (but an error may still be returned, based on trying to close
\r
968 * the two streams). If the closure is not desired, then you can use
\r
969 * svn_stream_disown() to protect either or both of the streams from
\r
971 * ### TODO: should close the streams ALWAYS, even on error exit
\r
973 * @since New in 1.6.
\r
976 svn_stream_copy3(svn_stream_t *from,
\r
978 svn_cancel_func_t cancel_func,
\r
979 void *cancel_baton,
\r
983 * Same as svn_stream_copy3() but the streams are not closed.
\r
985 * @since New in 1.5.
\r
986 * @deprecated Provided for backward compatibility with the 1.5 API.
\r
990 svn_stream_copy2(svn_stream_t *from,
\r
992 svn_cancel_func_t cancel_func,
\r
993 void *cancel_baton,
\r
997 * Same as svn_stream_copy3(), but without the cancellation function
\r
998 * or stream closing.
\r
1000 * @since New in 1.1.
\r
1001 * @deprecated Provided for backward compatibility with the 1.4 API.
\r
1005 svn_stream_copy(svn_stream_t *from,
\r
1007 apr_pool_t *pool);
\r
1010 /** Set @a *same to TRUE if @a stream1 and @a stream2 have the same
\r
1011 * contents, else set it to FALSE. Use @a pool for temporary allocations.
\r
1013 * @since New in 1.4.
\r
1016 svn_stream_contents_same(svn_boolean_t *same,
\r
1017 svn_stream_t *stream1,
\r
1018 svn_stream_t *stream2,
\r
1019 apr_pool_t *pool);
\r
1022 /** Read the contents of @a stream into memory, returning the data in
\r
1023 * @a result. The stream will be closed when it has been successfully and
\r
1024 * completely read.
\r
1026 * The returned memory is allocated in @a result_pool, and any temporary
\r
1027 * allocations are performed in @a scratch_pool.
\r
1029 * @note due to memory pseudo-reallocation behavior (due to pools), this
\r
1030 * can be a memory-intensive operation for large files.
\r
1032 * @since New in 1.6
\r
1035 svn_string_from_stream(svn_string_t **result,
\r
1036 svn_stream_t *stream,
\r
1037 apr_pool_t *result_pool,
\r
1038 apr_pool_t *scratch_pool);
\r
1043 /** Set @a *result to a string containing the contents of @a
\r
1044 * filename, which is either "-" (indicating that stdin should be
\r
1045 * read) or the utf8-encoded path of a real file.
\r
1047 * @warning Callers should be aware of possible unexpected results
\r
1048 * when using this function to read from stdin where additional
\r
1049 * stdin-reading processes abound. For example, if a program tries
\r
1050 * both to invoke an external editor and to read from stdin, stdin
\r
1051 * could be trashed and the editor might act funky or die outright.
\r
1053 * @note due to memory pseudo-reallocation behavior (due to pools), this
\r
1054 * can be a memory-intensive operation for large files.
\r
1056 * @since New in 1.5.
\r
1059 svn_stringbuf_from_file2(svn_stringbuf_t **result,
\r
1060 const char *filename,
\r
1061 apr_pool_t *pool);
\r
1063 /** Similar to svn_stringbuf_from_file2(), except that if @a filename
\r
1064 * is "-", return the error @c SVN_ERR_UNSUPPORTED_FEATURE and don't
\r
1065 * touch @a *result.
\r
1067 * @deprecated Provided for backwards compatibility with the 1.4 API.
\r
1071 svn_stringbuf_from_file(svn_stringbuf_t **result,
\r
1072 const char *filename,
\r
1073 apr_pool_t *pool);
\r
1075 /** Sets @a *result to a string containing the contents of the already opened
\r
1076 * @a file. Reads from the current position in file to the end. Does not
\r
1077 * close the file or reset the cursor position.
\r
1079 * @note due to memory pseudo-reallocation behavior (due to pools), this
\r
1080 * can be a memory-intensive operation for large files.
\r
1083 svn_stringbuf_from_aprfile(svn_stringbuf_t **result,
\r
1085 apr_pool_t *pool);
\r
1087 /** Remove file @a path, a utf8-encoded path. This wraps apr_file_remove(),
\r
1088 * converting any error to a Subversion error.
\r
1091 svn_io_remove_file(const char *path,
\r
1092 apr_pool_t *pool);
\r
1094 /** Recursively remove directory @a path. @a path is utf8-encoded.
\r
1095 * If @a ignore_enoent is @c TRUE, don't fail if the target directory
\r
1096 * doesn't exist. Use @a pool for temporary allocations.
\r
1098 * Because recursive delete of a directory tree can be a lengthy operation,
\r
1099 * provide @a cancel_func and @a cancel_baton for interruptability.
\r
1101 * @since New in 1.5.
\r
1104 svn_io_remove_dir2(const char *path,
\r
1105 svn_boolean_t ignore_enoent,
\r
1106 svn_cancel_func_t cancel_func,
\r
1107 void *cancel_baton,
\r
1108 apr_pool_t *pool);
\r
1110 /** Similar to svn_io_remove_dir2(), but with @a ignore_enoent set to
\r
1111 * @c FALSE and @a cancel_func and @a cancel_baton set to @c NULL.
\r
1113 * @deprecated Provided for backward compatibility with the 1.4 API
\r
1117 svn_io_remove_dir(const char *path,
\r
1118 apr_pool_t *pool);
\r
1120 /** Read all of the disk entries in directory @a path, a utf8-encoded
\r
1121 * path. Set @a *dirents to a hash mapping dirent names (<tt>char *</tt>) to
\r
1122 * undefined non-NULL values, allocated in @a pool.
\r
1124 * @note The `.' and `..' directories normally returned by
\r
1125 * apr_dir_read() are NOT returned in the hash.
\r
1127 * @since New in 1.4.
\r
1130 svn_io_get_dir_filenames(apr_hash_t **dirents,
\r
1132 apr_pool_t *pool);
\r
1134 /** Read all of the disk entries in directory @a path, a utf8-encoded
\r
1135 * path. Set @a *dirents to a hash mapping dirent names (<tt>char *</tt>) to
\r
1136 * @c svn_io_dirent_t structures, allocated in @a pool.
\r
1138 * @note The `.' and `..' directories normally returned by
\r
1139 * apr_dir_read() are NOT returned in the hash.
\r
1141 * @note The kind field in the @a dirents is set according to the mapping
\r
1142 * as documented for svn_io_check_path()
\r
1144 * @since New in 1.3.
\r
1147 svn_io_get_dirents2(apr_hash_t **dirents,
\r
1149 apr_pool_t *pool);
\r
1151 /** Similar to svn_io_get_dirents2(), but @a *dirents is a hash table
\r
1152 * with @c svn_node_kind_t values.
\r
1154 * @deprecated Provided for backwards compatibility with the 1.2 API.
\r
1158 svn_io_get_dirents(apr_hash_t **dirents,
\r
1160 apr_pool_t *pool);
\r
1163 /** Callback function type for svn_io_dir_walk() */
\r
1164 typedef svn_error_t * (*svn_io_walk_func_t)(void *baton,
\r
1166 const apr_finfo_t *finfo,
\r
1167 apr_pool_t *pool);
\r
1169 /** This function will recursively walk over the files and directories
\r
1170 * rooted at @a dirname, a utf8-encoded path. For each file or directory,
\r
1171 * @a walk_func is invoked, passing in the @a walk_baton, the utf8-encoded
\r
1172 * full path to the entry, an @c apr_finfo_t structure, and a temporary
\r
1173 * pool for allocations. For any directory, @a walk_func will be invoked
\r
1174 * on the directory itself before being invoked on any subdirectories or
\r
1175 * files within the directory.
\r
1177 * The set of information passed to @a walk_func is specified by @a wanted,
\r
1178 * and the items specified by @c APR_FINFO_TYPE and @c APR_FINFO_NAME.
\r
1180 * All allocations will be performed in @a pool.
\r
1183 svn_io_dir_walk(const char *dirname,
\r
1184 apr_int32_t wanted,
\r
1185 svn_io_walk_func_t walk_func,
\r
1187 apr_pool_t *pool);
\r
1190 * Start @a cmd with @a args, using utf8-encoded @a path as working
\r
1191 * directory. Connect @a cmd's stdin, stdout, and stderr to @a infile,
\r
1192 * @a outfile, and @a errfile, except where they are NULL. Return the
\r
1193 * process handle for the invoked program in @a *cmd_proc.
\r
1195 * @a args is a list of utf8-encoded <tt>const char *</tt> arguments,
\r
1196 * terminated by @c NULL. @a args[0] is the name of the program, though it
\r
1197 * need not be the same as @a cmd.
\r
1199 * If @a inherit is TRUE, the invoked program inherits its environment from
\r
1200 * the caller and @a cmd, if not absolute, is searched for in PATH.
\r
1201 * Otherwise, the invoked program runs with an empty environment and @a cmd
\r
1202 * must be an absolute path.
\r
1204 * @note On some platforms, failure to execute @a cmd in the child process
\r
1205 * will result in error output being written to @a errfile, if non-NULL, and
\r
1206 * a non-zero exit status being returned to the parent process.
\r
1208 * @since New in 1.3.
\r
1211 svn_io_start_cmd(apr_proc_t *cmd_proc,
\r
1214 const char *const *args,
\r
1215 svn_boolean_t inherit,
\r
1216 apr_file_t *infile,
\r
1217 apr_file_t *outfile,
\r
1218 apr_file_t *errfile,
\r
1219 apr_pool_t *pool);
\r
1222 * Wait for the process @a *cmd_proc to complete and optionally retrieve
\r
1223 * its exit code. @a cmd is used only in error messages.
\r
1225 * If @a exitcode is not NULL, @a *exitcode will contain the exit code
\r
1226 * of the process upon return, and if @a exitwhy is not NULL, @a
\r
1227 * *exitwhy will indicate why the process terminated. If @a exitwhy is
\r
1228 * NULL, and the exit reason is not @c APR_PROC_CHECK_EXIT(), or if
\r
1229 * @a exitcode is NULL and the exit code is non-zero, then an
\r
1230 * @c SVN_ERR_EXTERNAL_PROGRAM error will be returned.
\r
1232 * @since New in 1.3.
\r
1235 svn_io_wait_for_cmd(apr_proc_t *cmd_proc,
\r
1238 apr_exit_why_e *exitwhy,
\r
1239 apr_pool_t *pool);
\r
1241 /** Run a command to completion, by first calling svn_io_start_cmd() and
\r
1242 * then calling svn_io_wait_for_cmd(). The parameters correspond to
\r
1243 * the same-named parameters of those two functions.
\r
1246 svn_io_run_cmd(const char *path,
\r
1248 const char *const *args,
\r
1250 apr_exit_why_e *exitwhy,
\r
1251 svn_boolean_t inherit,
\r
1252 apr_file_t *infile,
\r
1253 apr_file_t *outfile,
\r
1254 apr_file_t *errfile,
\r
1255 apr_pool_t *pool);
\r
1257 /** Invoke the configured @c diff program, with @a user_args (an array
\r
1258 * of utf8-encoded @a num_user_args arguments) if they are specified
\r
1259 * (that is, if @a user_args is non-NULL), or "-u" if they are not.
\r
1260 * If @a user_args is NULL, the value of @a num_user_args is ignored.
\r
1262 * Diff runs in utf8-encoded @a dir, and its exit status is stored in
\r
1263 * @a exitcode, if it is not @c NULL.
\r
1265 * If @a label1 and/or @a label2 are not NULL they will be passed to the diff
\r
1266 * process as the arguments of "-L" options. @a label1 and @a label2 are also
\r
1267 * in utf8, and will be converted to native charset along with the other args.
\r
1269 * @a from is the first file passed to diff, and @a to is the second. The
\r
1270 * stdout of diff will be sent to @a outfile, and the stderr to @a errfile.
\r
1272 * @a diff_cmd must be non-NULL.
\r
1274 * Do all allocation in @a pool.
\r
1275 * @since New in 1.6.0.
\r
1278 svn_io_run_diff2(const char *dir,
\r
1279 const char *const *user_args,
\r
1280 int num_user_args,
\r
1281 const char *label1,
\r
1282 const char *label2,
\r
1286 apr_file_t *outfile,
\r
1287 apr_file_t *errfile,
\r
1288 const char *diff_cmd,
\r
1289 apr_pool_t *pool);
\r
1291 /** Similar to svn_io_run_diff2() but with @diff_cmd encoded in internal
\r
1292 * encoding used by APR.
\r
1294 * @deprecated Provided for backwards compatibility with the 1.5 API. */
\r
1297 svn_io_run_diff(const char *dir,
\r
1298 const char *const *user_args,
\r
1299 int num_user_args,
\r
1300 const char *label1,
\r
1301 const char *label2,
\r
1305 apr_file_t *outfile,
\r
1306 apr_file_t *errfile,
\r
1307 const char *diff_cmd,
\r
1308 apr_pool_t *pool);
\r
1312 /** Invoke the configured @c diff3 program, in utf8-encoded @a dir
\r
1315 * diff3 -E -m @a mine @a older @a yours > @a merged
\r
1317 * (See the diff3 documentation for details.)
\r
1319 * If @a user_args is non-NULL, replace "-E" with the <tt>const char*</tt>
\r
1320 * elements that @a user_args contains.
\r
1322 * @a mine, @a older and @a yours are utf8-encoded paths (relative to
\r
1323 * @a dir or absolute) to three files that already exist.
\r
1325 * @a merged is an open file handle, and is left open after the merge
\r
1326 * result is written to it. (@a merged should *not* be the same file
\r
1327 * as @a mine, or nondeterministic things may happen!)
\r
1329 * @a mine_label, @a older_label, @a yours_label are utf8-encoded label
\r
1330 * parameters for diff3's -L option. Any of them may be @c NULL, in
\r
1331 * which case the corresponding @a mine, @a older, or @a yours parameter is
\r
1334 * Set @a *exitcode to diff3's exit status. If @a *exitcode is anything
\r
1335 * other than 0 or 1, then return @c SVN_ERR_EXTERNAL_PROGRAM. (Note the
\r
1336 * following from the diff3 info pages: "An exit status of 0 means
\r
1337 * `diff3' was successful, 1 means some conflicts were found, and 2
\r
1338 * means trouble.")
\r
1340 * @a diff3_cmd must be non-NULL.
\r
1342 * Do all allocation in @a pool.
\r
1344 * @since New in 1.4.
\r
1347 svn_io_run_diff3_3(int *exitcode,
\r
1350 const char *older,
\r
1351 const char *yours,
\r
1352 const char *mine_label,
\r
1353 const char *older_label,
\r
1354 const char *yours_label,
\r
1355 apr_file_t *merged,
\r
1356 const char *diff3_cmd,
\r
1357 const apr_array_header_t *user_args,
\r
1358 apr_pool_t *pool);
\r
1360 /** Similar to svn_io_run_diff3_3(), but with @a diff3_cmd encoded in
\r
1361 * internal encoding used by APR.
\r
1363 * @deprecated Provided for backwards compatibility with the 1.5 API.
\r
1364 * @since New in 1.4.
\r
1368 svn_io_run_diff3_2(int *exitcode,
\r
1371 const char *older,
\r
1372 const char *yours,
\r
1373 const char *mine_label,
\r
1374 const char *older_label,
\r
1375 const char *yours_label,
\r
1376 apr_file_t *merged,
\r
1377 const char *diff3_cmd,
\r
1378 const apr_array_header_t *user_args,
\r
1379 apr_pool_t *pool);
\r
1381 /** Similar to svn_io_run_diff3_2(), but with @a user_args set to @c NULL.
\r
1383 * @deprecated Provided for backwards compatibility with the 1.3 API.
\r
1387 svn_io_run_diff3(const char *dir,
\r
1389 const char *older,
\r
1390 const char *yours,
\r
1391 const char *mine_label,
\r
1392 const char *older_label,
\r
1393 const char *yours_label,
\r
1394 apr_file_t *merged,
\r
1396 const char *diff3_cmd,
\r
1397 apr_pool_t *pool);
\r
1400 /** Parse utf8-encoded @a mimetypes_file as a MIME types file (such as
\r
1401 * is provided with Apache HTTP Server), and set @a *type_map to a
\r
1402 * hash mapping <tt>const char *</tt> filename extensions to
\r
1403 * <tt>const char *</tt> MIME types.
\r
1405 * @since New in 1.5.
\r
1408 svn_io_parse_mimetypes_file(apr_hash_t **type_map,
\r
1409 const char *mimetypes_file,
\r
1410 apr_pool_t *pool);
\r
1413 /** Examine utf8-encoded @a file to determine if it can be described by a
\r
1414 * known (as in, known by this function) Multipurpose Internet Mail
\r
1415 * Extension (MIME) type. If so, set @a *mimetype to a character string
\r
1416 * describing the MIME type, else set it to @c NULL.
\r
1418 * If not @c NULL, @a mimetype_map is a hash mapping <tt>const char *</tt>
\r
1419 * filename extensions to <tt>const char *</tt> MIME types, and is the
\r
1420 * first source consulted regarding @a file's MIME type.
\r
1422 * Use @a pool for any necessary allocations.
\r
1424 * @since New in 1.5.
\r
1427 svn_io_detect_mimetype2(const char **mimetype,
\r
1429 apr_hash_t *mimetype_map,
\r
1430 apr_pool_t *pool);
\r
1433 /** Like svn_io_detect_mimetype2, but with @a mimetypes_map set to
\r
1436 * @deprecated Provided for backward compatibility with the 1.4 API
\r
1440 svn_io_detect_mimetype(const char **mimetype,
\r
1442 apr_pool_t *pool);
\r
1445 /** Wrapper for apr_file_open(). @a fname is utf8-encoded. */
\r
1447 svn_io_file_open(apr_file_t **new_file,
\r
1448 const char *fname,
\r
1450 apr_fileperms_t perm,
\r
1451 apr_pool_t *pool);
\r
1454 /** Wrapper for apr_file_close(). */
\r
1456 svn_io_file_close(apr_file_t *file,
\r
1457 apr_pool_t *pool);
\r
1460 /** Wrapper for apr_file_getc(). */
\r
1462 svn_io_file_getc(char *ch,
\r
1464 apr_pool_t *pool);
\r
1467 /** Wrapper for apr_file_info_get(). */
\r
1469 svn_io_file_info_get(apr_finfo_t *finfo,
\r
1470 apr_int32_t wanted,
\r
1472 apr_pool_t *pool);
\r
1475 /** Wrapper for apr_file_read(). */
\r
1477 svn_io_file_read(apr_file_t *file,
\r
1479 apr_size_t *nbytes,
\r
1480 apr_pool_t *pool);
\r
1483 /** Wrapper for apr_file_read_full(). */
\r
1485 svn_io_file_read_full(apr_file_t *file,
\r
1487 apr_size_t nbytes,
\r
1488 apr_size_t *bytes_read,
\r
1489 apr_pool_t *pool);
\r
1492 /** Wrapper for apr_file_seek(). */
\r
1494 svn_io_file_seek(apr_file_t *file,
\r
1495 apr_seek_where_t where,
\r
1496 apr_off_t *offset,
\r
1497 apr_pool_t *pool);
\r
1500 /** Wrapper for apr_file_write(). */
\r
1502 svn_io_file_write(apr_file_t *file,
\r
1504 apr_size_t *nbytes,
\r
1505 apr_pool_t *pool);
\r
1508 /** Wrapper for apr_file_write_full(). */
\r
1510 svn_io_file_write_full(apr_file_t *file,
\r
1512 apr_size_t nbytes,
\r
1513 apr_size_t *bytes_written,
\r
1514 apr_pool_t *pool);
\r
1517 * Open a unique file in @a dirpath, and write @a nbytes from @a buf to
\r
1518 * the file before closing it. Return the name of the newly created file
\r
1519 * in @a *tmp_path, allocated in @a pool.
\r
1521 * If @a dirpath is @c NULL, use the path returned from svn_io_temp_dir().
\r
1522 * (Note that when using the system-provided temp directory, it may not
\r
1523 * be possibly to atomically rename the resulting file due to cross-device
\r
1526 * The file will be deleted according to @a delete_when.
\r
1528 * @since New in 1.6.
\r
1531 svn_io_write_unique(const char **tmp_path,
\r
1532 const char *dirpath,
\r
1534 apr_size_t nbytes,
\r
1535 svn_io_file_del_t delete_when,
\r
1536 apr_pool_t *pool);
\r
1538 /** Wrapper for apr_file_trunc().
\r
1539 * @since New in 1.6. */
\r
1541 svn_io_file_trunc(apr_file_t *file,
\r
1543 apr_pool_t *pool);
\r
1546 /** Wrapper for apr_stat(). @a fname is utf8-encoded. */
\r
1548 svn_io_stat(apr_finfo_t *finfo,
\r
1549 const char *fname,
\r
1550 apr_int32_t wanted,
\r
1551 apr_pool_t *pool);
\r
1554 /** Wrapper for apr_file_rename(). @a from_path and @a to_path are
\r
1558 svn_io_file_rename(const char *from_path,
\r
1559 const char *to_path,
\r
1560 apr_pool_t *pool);
\r
1563 /** Move the file from @a from_path to @a to_path, even across device
\r
1564 * boundaries. Overwrite @a to_path if it exists.
\r
1566 * @note This function is different from svn_io_file_rename in that the
\r
1567 * latter fails in the 'across device boundaries' case.
\r
1569 * @since New in 1.3.
\r
1572 svn_io_file_move(const char *from_path,
\r
1573 const char *to_path,
\r
1574 apr_pool_t *pool);
\r
1577 /** Wrapper for apr_dir_make(). @a path is utf8-encoded. */
\r
1579 svn_io_dir_make(const char *path,
\r
1580 apr_fileperms_t perm,
\r
1581 apr_pool_t *pool);
\r
1583 /** Same as svn_io_dir_make(), but sets the hidden attribute on the
\r
1584 directory on systems that support it. */
\r
1586 svn_io_dir_make_hidden(const char *path,
\r
1587 apr_fileperms_t perm,
\r
1588 apr_pool_t *pool);
\r
1591 * Same as svn_io_dir_make(), but attempts to set the sgid on the
\r
1592 * directory on systems that support it. Does not return an error if
\r
1593 * the attempt to set the sgid bit fails. On Unix filesystems,
\r
1594 * setting the sgid bit on a directory ensures that files and
\r
1595 * subdirectories created within inherit group ownership from the
\r
1596 * parent instead of from the primary gid.
\r
1598 * @since New in 1.1.
\r
1601 svn_io_dir_make_sgid(const char *path,
\r
1602 apr_fileperms_t perm,
\r
1603 apr_pool_t *pool);
\r
1605 /** Wrapper for apr_dir_open(). @a dirname is utf8-encoded. */
\r
1607 svn_io_dir_open(apr_dir_t **new_dir,
\r
1608 const char *dirname,
\r
1609 apr_pool_t *pool);
\r
1612 /** Wrapper for apr_dir_remove(). @a dirname is utf8-encoded.
\r
1613 * @note This function has this name to avoid confusion with
\r
1614 * svn_io_remove_dir2(), which is recursive.
\r
1617 svn_io_dir_remove_nonrecursive(const char *dirname,
\r
1618 apr_pool_t *pool);
\r
1621 /** Wrapper for apr_dir_read(). Ensures that @a finfo->name is
\r
1622 * utf8-encoded, which means allocating @a finfo->name in @a pool,
\r
1623 * which may or may not be the same as @a finfo's pool. Use @a pool
\r
1624 * for error allocation as well.
\r
1627 svn_io_dir_read(apr_finfo_t *finfo,
\r
1628 apr_int32_t wanted,
\r
1629 apr_dir_t *thedir,
\r
1630 apr_pool_t *pool);
\r
1634 /** Version/format files.
\r
1636 * @defgroup svn_io_format_files Version/format files
\r
1640 /** Set @a *version to the integer that starts the file at @a path. If the
\r
1641 * file does not begin with a series of digits followed by a newline,
\r
1642 * return the error @c SVN_ERR_BAD_VERSION_FILE_FORMAT. Use @a pool for
\r
1643 * all allocations.
\r
1646 svn_io_read_version_file(int *version,
\r
1648 apr_pool_t *pool);
\r
1650 /** Create (or overwrite) the file at @a path with new contents,
\r
1651 * formatted as a non-negative integer @a version followed by a single
\r
1652 * newline. On successful completion the file will be read-only. Use
\r
1653 * @a pool for all allocations.
\r
1656 svn_io_write_version_file(const char *path,
\r
1658 apr_pool_t *pool);
\r
1662 #ifdef __cplusplus
\r
1664 #endif /* __cplusplus */
\r
1666 #endif /* SVN_IO_H */
\r