svn_io.h

Go to the documentation of this file.
00001 /**
00002  * @copyright
00003  * ====================================================================
00004  * Copyright (c) 2000-2007 CollabNet.  All rights reserved.
00005  *
00006  * This software is licensed as described in the file COPYING, which
00007  * you should have received as part of this distribution.  The terms
00008  * are also available at http://subversion.tigris.org/license-1.html.
00009  * If newer versions of this license are posted there, you may use a
00010  * newer version instead, at your option.
00011  *
00012  * This software consists of voluntary contributions made by many
00013  * individuals.  For exact contribution history, see the revision
00014  * history and logs, available at http://subversion.tigris.org/.
00015  * ====================================================================
00016  * @endcopyright
00017  *
00018  * @file svn_io.h
00019  * @brief General file I/O for Subversion
00020  */
00021 
00022 /* ==================================================================== */
00023 
00024 
00025 #ifndef SVN_IO_H
00026 #define SVN_IO_H
00027 
00028 #include <apr.h>
00029 #include <apr_pools.h>
00030 #include <apr_file_io.h>
00031 #include <apr_thread_proc.h>
00032 
00033 #include "svn_types.h"
00034 #include "svn_error.h"
00035 #include "svn_string.h"
00036 
00037 #ifdef __cplusplus
00038 extern "C" {
00039 #endif /* __cplusplus */
00040 
00041 
00042 
00043 /** Used as an argument when creating temporary files to indicate
00044  * when a file should be removed.
00045  *
00046  * @since New in 1.4.
00047  *
00048  * Not specifying any of these means no removal at all. */
00049 typedef enum svn_io_file_del_t
00050 {
00051   /** No deletion ever */
00052   svn_io_file_del_none = 0,
00053   /** Remove when the file is closed */
00054   svn_io_file_del_on_close,
00055   /** Remove when the associated pool is cleared */
00056   svn_io_file_del_on_pool_cleanup
00057 } svn_io_file_del_t;
00058 
00059 
00060 
00061 /** Represents the kind and special status of a directory entry.
00062  *
00063  * @since New in 1.3.
00064  */
00065 typedef struct svn_io_dirent_t {
00066   /** The kind of this entry. */
00067   svn_node_kind_t kind;
00068   /** If @c kind is @c svn_node_file, whether this entry is a special file;
00069    * else FALSE.
00070    *
00071    * @see svn_io_check_special_path().
00072    */
00073   svn_boolean_t special;
00074 } svn_io_dirent_t;
00075 
00076 /** Determine the @a kind of @a path.  @a path should be UTF-8 encoded.
00077  *
00078  * If @a path is a file, set @a *kind to @c svn_node_file.
00079  *
00080  * If @a path is a directory, set @a *kind to @c svn_node_dir.
00081  *
00082  * If @a path does not exist, set @a *kind to @c svn_node_none.
00083  *
00084  * If @a path exists but is none of the above, set @a *kind to @c
00085  * svn_node_unknown.
00086  *
00087  * If unable to determine @a path's kind, return an error, with @a *kind's
00088  * value undefined.
00089  *
00090  * Use @a pool for temporary allocations.
00091  *
00092  * @see svn_node_kind_t
00093  */
00094 svn_error_t *svn_io_check_path(const char *path,
00095                                svn_node_kind_t *kind,
00096                                apr_pool_t *pool);
00097 
00098 /**
00099  * Like svn_io_check_path(), but also set *is_special to @c TRUE if
00100  * the path is not a normal file.
00101  *
00102  * @since New in 1.1.
00103  */
00104 svn_error_t *svn_io_check_special_path(const char *path,
00105                                        svn_node_kind_t *kind,
00106                                        svn_boolean_t *is_special,
00107                                        apr_pool_t *pool);
00108 
00109 /** Like svn_io_check_path(), but resolve symlinks.  This returns the
00110     same varieties of @a kind as svn_io_check_path(). */
00111 svn_error_t *svn_io_check_resolved_path(const char *path,
00112                                         svn_node_kind_t *kind,
00113                                         apr_pool_t *pool);
00114 
00115 
00116 /** Open a new file (for reading and writing) with a unique name based on
00117  * utf-8 encoded @a path, in the same directory as @a path.  The file handle is
00118  * returned in @a *f, and the name, which ends with @a suffix, is returned
00119  * in @a *unique_name_p, also utf8-encoded.  Either @a f or @a unique_name_p
00120  * may be @c NULL.
00121  *
00122  * If @a delete_when is @c svn_io_file_del_on_close, then the @c APR_DELONCLOSE
00123  * flag will be used when opening the file.  The @c APR_BUFFERED flag will
00124  * always be used.
00125  *
00126  * The first attempt will just append @a suffix.  If the result is not
00127  * a unique name, then subsequent attempts will append a dot,
00128  * followed by an iteration number ("2", then "3", and so on),
00129  * followed by the suffix.  For example, if @a path is
00130  *
00131  *    tests/t1/A/D/G/pi
00132  *
00133  * then successive calls to
00134  *
00135  *    svn_io_open_unique_file2(&f, &unique_name, @a path, ".tmp", ..., pool)
00136  *
00137  * will open
00138  *
00139  *    tests/t1/A/D/G/pi.tmp
00140  *    tests/t1/A/D/G/pi.2.tmp
00141  *    tests/t1/A/D/G/pi.3.tmp
00142  *    tests/t1/A/D/G/pi.4.tmp
00143  *    tests/t1/A/D/G/pi.5.tmp
00144  *    ...
00145  *
00146  * Assuming @a suffix is non-empty, @a *unique_name_p will never be exactly
00147  * the same as @a path, even if @a path does not exist.
00148  *
00149  * It doesn't matter if @a path is a file or directory, the unique name will
00150  * be in @a path's parent either way.
00151  *
00152  * Allocate @a *f and @a *unique_name_p in @a pool.
00153  *
00154  * If no unique name can be found, @c SVN_ERR_IO_UNIQUE_NAMES_EXHAUSTED is
00155  * the error returned.
00156  *
00157  * Claim of Historical Inevitability: this function was written
00158  * because
00159  *
00160  *    - tmpnam() is not thread-safe.
00161  *    - tempname() tries standard system tmp areas first.
00162  *
00163  *
00164  * @since New in 1.4
00165  *
00166  */
00167 svn_error_t *svn_io_open_unique_file2(apr_file_t **f,
00168                                       const char **unique_name_p,
00169                                       const char *path,
00170                                       const char *suffix,
00171                                       svn_io_file_del_t delete_when,
00172                                       apr_pool_t *pool);
00173 
00174 /** Like svn_io_open_unique_file2, but can't delete on pool cleanup.
00175  *
00176  * @deprecated Provided for backward compatibility with the 1.0 API
00177  *
00178  * @note In 1.4 the API was extended to require either @a f or
00179  *       @a unique_name_p (the other can be NULL).  Before that, both were
00180  *       required.
00181  *
00182  */
00183 svn_error_t *svn_io_open_unique_file(apr_file_t **f,
00184                                      const char **unique_name_p,
00185                                      const char *path,
00186                                      const char *suffix,
00187                                      svn_boolean_t delete_on_close,
00188                                      apr_pool_t *pool);
00189 
00190 /**
00191  * Like svn_io_open_unique_file(), except that instead of creating a
00192  * file, a symlink is generated that references the path @a dest.
00193  *
00194  * @since New in 1.1.
00195  */
00196 svn_error_t *svn_io_create_unique_link(const char **unique_name_p,
00197                                        const char *path,
00198                                        const char *dest,
00199                                        const char *suffix,
00200                                        apr_pool_t *pool);
00201 
00202 
00203 /**
00204  * Set @a *dest to the path that the symlink at @a path references.
00205  * Allocate the string from @a pool.
00206  *
00207  * @since New in 1.1.
00208  */
00209 svn_error_t *svn_io_read_link(svn_string_t **dest,
00210                               const char *path,
00211                               apr_pool_t *pool);
00212 
00213 
00214 /** Set @a *dir to a directory path (allocated in @a pool) deemed
00215  * usable for the creation of temporary files and subdirectories.
00216  */
00217 svn_error_t *svn_io_temp_dir(const char **dir,
00218                              apr_pool_t *pool);
00219 
00220 
00221 /** Copy @a src to @a dst atomically, in a "byte-for-byte" manner.
00222  * Overwrite @a dst if it exists, else create it.  Both @a src and @a dst
00223  * are utf8-encoded filenames.  If @a copy_perms is TRUE, set @a dst's
00224  * permissions to match those of @a src.
00225  */
00226 svn_error_t *svn_io_copy_file(const char *src,
00227                               const char *dst,
00228                               svn_boolean_t copy_perms,
00229                               apr_pool_t *pool);
00230 
00231 /**
00232  * Copy symbolic link @a src to @a dst atomically.  Overwrite @a dst
00233  * if it exists, else create it.  Both @a src and @a dst are
00234  * utf8-encoded filenames.  After copying, the @a dst link will point
00235  * to the same thing @a src does.
00236  *
00237  * @since New in 1.1.
00238  */
00239 svn_error_t *svn_io_copy_link(const char *src,
00240                               const char *dst,
00241                               apr_pool_t *pool);
00242 
00243 
00244 /** Recursively copy directory @a src into @a dst_parent, as a new entry named
00245  * @a dst_basename.  If @a dst_basename already exists in @a dst_parent,
00246  * return error.  @a copy_perms will be passed through to svn_io_copy_file()
00247  * when any files are copied.  @a src, @a dst_parent, and @a dst_basename are
00248  * all utf8-encoded.
00249  *
00250  * If @a cancel_func is non-NULL, invoke it with @a cancel_baton at
00251  * various points during the operation.  If it returns any error
00252  * (typically @c SVN_ERR_CANCELLED), return that error immediately.
00253  */
00254 svn_error_t *svn_io_copy_dir_recursively(const char *src,
00255                                          const char *dst_parent,
00256                                          const char *dst_basename,
00257                                          svn_boolean_t copy_perms,
00258                                          svn_cancel_func_t cancel_func,
00259                                          void *cancel_baton,
00260                                          apr_pool_t *pool);
00261 
00262 
00263 
00264 /** Create directory @a path on the file system, creating intermediate
00265  * directories as required, like <tt>mkdir -p</tt>.  Report no error if @a
00266  * path already exists.  @a path is utf8-encoded.
00267  *
00268  * This is essentially a wrapper for apr_dir_make_recursive(), passing
00269  * @c APR_OS_DEFAULT as the permissions.
00270  */
00271 svn_error_t *svn_io_make_dir_recursively(const char *path, apr_pool_t *pool);
00272 
00273 
00274 /** Set @a *is_empty_p to @c TRUE if directory @a path is empty, else to
00275  * @c FALSE if it is not empty.  @a path must be a directory, and is
00276  * utf8-encoded.  Use @a pool for temporary allocation.
00277  */
00278 svn_error_t *
00279 svn_io_dir_empty(svn_boolean_t *is_empty_p,
00280                  const char *path,
00281                  apr_pool_t *pool);
00282 
00283 
00284 /** Append @a src to @a dst.  @a dst will be appended to if it exists, else it
00285  * will be created.  Both @a src and @a dst are utf8-encoded.
00286  */
00287 svn_error_t *svn_io_append_file(const char *src,
00288                                 const char *dst,
00289                                 apr_pool_t *pool);
00290 
00291 
00292 /** Make a file as read-only as the operating system allows.
00293  * @a path is the utf8-encoded path to the file. If @a ignore_enoent is
00294  * @c TRUE, don't fail if the target file doesn't exist.
00295  *
00296  * If @a path is a symlink, do nothing.
00297  *
00298  * @note If @a path is a directory, act on it as though it were a
00299  * file, as described above, but note that you probably don't want to
00300  * call this function on directories.  We have left it effective on
00301  * directories for compatibility reasons, but as its name implies, it
00302  * should be used only for files.
00303  */
00304 svn_error_t *svn_io_set_file_read_only(const char *path,
00305                                        svn_boolean_t ignore_enoent,
00306                                        apr_pool_t *pool);
00307 
00308 
00309 /** Make a file as writable as the operating system allows.
00310  * @a path is the utf8-encoded path to the file.  If @a ignore_enoent is
00311  * @c TRUE, don't fail if the target file doesn't exist.
00312  * @warning On Unix this function will do the equivalent of chmod a+w path.
00313  * If this is not what you want you should not use this function, but rather
00314  * use apr_file_perms_set().
00315  *
00316  * If @a path is a symlink, do nothing.
00317  *
00318  * @note If @a path is a directory, act on it as though it were a
00319  * file, as described above, but note that you probably don't want to
00320  * call this function on directories.  We have left it effective on
00321  * directories for compatibility reasons, but as its name implies, it
00322  * should be used only for files.
00323  */
00324 svn_error_t *svn_io_set_file_read_write(const char *path,
00325                                         svn_boolean_t ignore_enoent,
00326                                         apr_pool_t *pool);
00327 
00328 
00329 /** Similar to svn_io_set_file_read_* functions.
00330  * Change the read-write permissions of a file.
00331  * @since New in 1.1.
00332  *
00333  * When making @a path read-write on operating systems with unix style
00334  * permissions, set the permissions on @a path to the permissions that
00335  * are set when a new file is created (effectively honoring the user's
00336  * umask).
00337  *
00338  * When making the file read-only on operating systems with unix style
00339  * permissions, remove all write permissions.
00340  *
00341  * On other operating systems, toggle the file's "writability" as much as
00342  * the operating system allows.
00343  *
00344  * @a path is the utf8-encoded path to the file.  If @a enable_write
00345  * is @c TRUE, then make the file read-write.  If @c FALSE, make it
00346  * read-only.  If @a ignore_enoent is @c TRUE, don't fail if the target
00347  * file doesn't exist.
00348  *
00349  * @deprecated Provided for backward compatibility with the 1.3 API.
00350  */
00351 svn_error_t *svn_io_set_file_read_write_carefully(const char *path,
00352                                                   svn_boolean_t enable_write,
00353                                                   svn_boolean_t ignore_enoent,
00354                                                   apr_pool_t *pool);
00355 
00356 /** Set @a path's "executability" (but do nothing if it is a symlink).
00357  *
00358  * @a path is the utf8-encoded path to the file.  If @a executable
00359  * is @c TRUE, then make the file executable.  If @c FALSE, make it
00360  * non-executable.  If @a ignore_enoent is @c TRUE, don't fail if the target
00361  * file doesn't exist.
00362  *
00363  * When making the file executable on operating systems with unix style
00364  * permissions, never add an execute permission where there is not
00365  * already a read permission: that is, only make the file executable
00366  * for the user, group or world if the corresponding read permission
00367  * is already set for user, group or world.
00368  *
00369  * When making the file non-executable on operating systems with unix style
00370  * permissions, remove all execute permissions.
00371  *
00372  * On other operating systems, toggle the file's "executability" as much as
00373  * the operating system allows.
00374  *
00375  * @note If @a path is a directory, act on it as though it were a
00376  * file, as described above, but note that you probably don't want to
00377  * call this function on directories.  We have left it effective on
00378  * directories for compatibility reasons, but as its name implies, it
00379  * should be used only for files.
00380  */
00381 svn_error_t *svn_io_set_file_executable(const char *path,
00382                                         svn_boolean_t executable,
00383                                         svn_boolean_t ignore_enoent,
00384                                         apr_pool_t *pool);
00385 
00386 /** Determine whether a file is executable by the current user.
00387  * Set @a *executable to @c TRUE if the file @a path is executable by the
00388  * current user, otherwise set it to @c FALSE.
00389  *
00390  * On Windows and on platforms without userids, always returns @c FALSE.
00391  */
00392 svn_error_t *svn_io_is_file_executable(svn_boolean_t *executable,
00393                                        const char *path,
00394                                        apr_pool_t *pool);
00395 
00396 
00397 /** Read a line from @a file into @a buf, but not exceeding @a *limit bytes.
00398  * Does not include newline, instead '\\0' is put there.
00399  * Length (as in strlen) is returned in @a *limit.
00400  * @a buf should be pre-allocated.
00401  * @a file should be already opened.
00402  *
00403  * When the file is out of lines, @c APR_EOF will be returned.
00404  */
00405 svn_error_t *
00406 svn_io_read_length_line(apr_file_t *file, char *buf, apr_size_t *limit,
00407                         apr_pool_t *pool);
00408 
00409 
00410 /** Set @a *apr_time to the time of last modification of the contents of the
00411  * file @a path.  @a path is utf8-encoded.
00412  *
00413  * @note This is the APR mtime which corresponds to the traditional mtime
00414  * on Unix, and the last write time on Windows.
00415  */
00416 svn_error_t *svn_io_file_affected_time(apr_time_t *apr_time,
00417                                        const char *path,
00418                                        apr_pool_t *pool);
00419 
00420 /** Set the timestamp of file @a path to @a apr_time.  @a path is
00421  *  utf8-encoded.
00422  *
00423  * @note This is the APR mtime which corresponds to the traditional mtime
00424  * on Unix, and the last write time on Windows.
00425  */
00426 svn_error_t *svn_io_set_file_affected_time(apr_time_t apr_time,
00427                                            const char *path,
00428                                            apr_pool_t *pool);
00429 
00430 
00431 
00432 /** Set @a *different_p to non-zero if @a file1 and @a file2 have different
00433  * sizes, else set to zero.  Both @a file1 and @a file2 are utf8-encoded.
00434  *
00435  * Setting @a *different_p to zero does not mean the files definitely
00436  * have the same size, it merely means that the sizes are not
00437  * definitely different.  That is, if the size of one or both files
00438  * cannot be determined, then the sizes are not known to be different,
00439  * so @a *different_p is set to 0.
00440  */
00441 svn_error_t *svn_io_filesizes_different_p(svn_boolean_t *different_p,
00442                                           const char *file1,
00443                                           const char *file2,
00444                                           apr_pool_t *pool);
00445 
00446 
00447 /** Put the md5 checksum of @a file into @a digest.
00448  * @a digest points to @c APR_MD5_DIGESTSIZE bytes of storage.
00449  * Use @a pool only for temporary allocations.
00450  */
00451 svn_error_t *svn_io_file_checksum(unsigned char digest[],
00452                                   const char *file,
00453                                   apr_pool_t *pool);
00454 
00455 
00456 /** Set @a *same to TRUE if @a file1 and @a file2 have the same
00457  * contents, else set it to FALSE.  Use @a pool for temporary allocations.
00458  */
00459 svn_error_t *svn_io_files_contents_same_p(svn_boolean_t *same,
00460                                           const char *file1,
00461                                           const char *file2,
00462                                           apr_pool_t *pool);
00463 
00464 /** Create file at utf8-encoded @a file with contents @a contents.
00465  * @a file must not already exist.
00466  * Use @a pool for memory allocations.
00467  */
00468 svn_error_t *svn_io_file_create(const char *file,
00469                                 const char *contents,
00470                                 apr_pool_t *pool);
00471 
00472 /**
00473  * Lock file at @a lock_file. If @a exclusive is TRUE,
00474  * obtain exclusive lock, otherwise obtain shared lock.
00475  * Lock will be automatically released when @a pool is cleared or destroyed.
00476  * Use @a pool for memory allocations.
00477  *
00478  * @deprecated Provided for backward compatibility with the 1.0 API.
00479  */
00480 svn_error_t *svn_io_file_lock(const char *lock_file,
00481                               svn_boolean_t exclusive,
00482                               apr_pool_t *pool);
00483 
00484 /**
00485  * Lock file at @a lock_file. If @a exclusive is TRUE,
00486  * obtain exclusive lock, otherwise obtain shared lock.
00487  *
00488  * If @a nonblocking is TRUE, do not wait for the lock if it
00489  * is not available: throw an error instead.
00490  *
00491  * Lock will be automatically released when @a pool is cleared or destroyed.
00492  * Use @a pool for memory allocations.
00493  *
00494  * @since New in 1.1.
00495  */
00496 svn_error_t *svn_io_file_lock2(const char *lock_file,
00497                                svn_boolean_t exclusive,
00498                                svn_boolean_t nonblocking,
00499                                apr_pool_t *pool);
00500 /**
00501  * Flush any unwritten data from @a file to disk.  Use @a pool for
00502  *  memory allocations.
00503  *
00504  * @since New in 1.1.
00505  */
00506 svn_error_t *svn_io_file_flush_to_disk(apr_file_t *file,
00507                                        apr_pool_t *pool);
00508 
00509 /** Copy file @a file from location @a src_path to location @a dest_path.
00510  * Use @a pool for memory allocations.
00511  */
00512 svn_error_t *svn_io_dir_file_copy(const char *src_path,
00513                                   const char *dest_path,
00514                                   const char *file,
00515                                   apr_pool_t *pool);
00516 
00517 
00518 /** Generic byte-streams
00519  *
00520  * @defgroup svn_io_byte_streams Generic byte streams
00521  * @{
00522  */
00523 
00524 /** An abstract stream of bytes--either incoming or outgoing or both.
00525  *
00526  * The creator of a stream sets functions to handle read and write.
00527  * Both of these handlers accept a baton whose value is determined at
00528  * stream creation time; this baton can point to a structure
00529  * containing data associated with the stream.  If a caller attempts
00530  * to invoke a handler which has not been set, it will generate a
00531  * runtime assertion failure.  The creator can also set a handler for
00532  * close requests so that it can flush buffered data or whatever;
00533  * if a close handler is not specified, a close request on the stream
00534  * will simply be ignored.  Note that svn_stream_close() does not
00535  * deallocate the memory used to allocate the stream structure; free
00536  * the pool you created the stream in to free that memory.
00537  *
00538  * The read and write handlers accept length arguments via pointer.
00539  * On entry to the handler, the pointed-to value should be the amount
00540  * of data which can be read or the amount of data to write.  When the
00541  * handler returns, the value is reset to the amount of data actually
00542  * read or written.  Handlers are obliged to complete a read or write
00543  * to the maximum extent possible; thus, a short read with no
00544  * associated error implies the end of the input stream, and a short
00545  * write should never occur without an associated error.
00546  */
00547 typedef struct svn_stream_t svn_stream_t;
00548 
00549 
00550 
00551 /** Read handler function for a generic stream.  @see svn_stream_t. */
00552 typedef svn_error_t *(*svn_read_fn_t)(void *baton,
00553                                       char *buffer,
00554                                       apr_size_t *len);
00555 
00556 /** Write handler function for a generic stream.  @see svn_stream_t. */
00557 typedef svn_error_t *(*svn_write_fn_t)(void *baton,
00558                                        const char *data,
00559                                        apr_size_t *len);
00560 
00561 /** Close handler function for a generic stream.  @see svn_stream_t. */
00562 typedef svn_error_t *(*svn_close_fn_t)(void *baton);
00563 
00564 
00565 /** Create a generic stream.  @see svn_stream_t. */
00566 svn_stream_t *svn_stream_create(void *baton, apr_pool_t *pool);
00567 
00568 /** Set @a stream's baton to @a baton */
00569 void svn_stream_set_baton(svn_stream_t *stream, void *baton);
00570 
00571 /** Set @a stream's read function to @a read_fn */
00572 void svn_stream_set_read(svn_stream_t *stream, svn_read_fn_t read_fn);
00573 
00574 /** Set @a stream's write function to @a write_fn */
00575 void svn_stream_set_write(svn_stream_t *stream, svn_write_fn_t write_fn);
00576 
00577 /** Set @a stream's close function to @a close_fn */
00578 void svn_stream_set_close(svn_stream_t *stream, svn_close_fn_t close_fn);
00579 
00580 
00581 /** Create a stream that is empty for reading and infinite for writing. */
00582 svn_stream_t *svn_stream_empty(apr_pool_t *pool);
00583 
00584 /** Return a stream allocated in @a pool which forwards all requests
00585  * to @a stream.  Destruction is explicitly excluded from forwarding.
00586  *
00587  * @see notes/destruction-of-stacked-resources
00588  *
00589  * @since New in 1.4.
00590  */
00591 svn_stream_t *svn_stream_disown(svn_stream_t *stream, apr_pool_t *pool);
00592 
00593 /** Create a stream from an APR file.  For convenience, if @a file is
00594  * @c NULL, an empty stream created by svn_stream_empty() is returned.
00595  *
00596  * This function should normally be called with @a disown set to FALSE,
00597  * in which case closing the stream will also close the underlying file.
00598  *
00599  * If @a disown is TRUE, the stream will disown the underlying file,
00600  * meaning that svn_stream_close() will not close the file.
00601  *
00602  * @since New in 1.4.
00603  */
00604 svn_stream_t * svn_stream_from_aprfile2(apr_file_t *file,
00605                                         svn_boolean_t disown,
00606                                         apr_pool_t *pool);
00607 
00608 /** Similar to svn_stream_from_aprfile2(), except that the file will
00609  * always be disowned.
00610  *
00611  * @note The stream returned is not considered to "own" the underlying
00612  *       file, meaning that svn_stream_close() on the stream will not
00613  *       close the file.
00614  *
00615  * @deprecated Provided for backward compatibility with the 1.3 API.
00616  */
00617 svn_stream_t *svn_stream_from_aprfile(apr_file_t *file, apr_pool_t *pool);
00618 
00619 /** Set @a *out to a generic stream connected to stdout, allocated in
00620  * @a pool.  The stream and its underlying APR handle will be closed
00621  * when @a pool is cleared or destroyed.
00622  */
00623 svn_error_t *svn_stream_for_stdout(svn_stream_t **out, apr_pool_t *pool);
00624 
00625 /** Return a generic stream connected to stringbuf @a str.  Allocate the
00626  * stream in @a pool.
00627  */
00628 svn_stream_t *svn_stream_from_stringbuf(svn_stringbuf_t *str,
00629                                         apr_pool_t *pool);
00630 
00631 /** Return a stream that decompresses all data read and compresses all
00632  * data written. The stream @a stream is used to read and write all
00633  * compressed data. All compression data structures are allocated on
00634  * @a pool. If compression support is not compiled in then
00635  * svn_stream_compressed() returns @a stream unmodified. Make sure you
00636  * call svn_stream_close() on the stream returned by this function,
00637  * so that all data are flushed and cleaned up.
00638  *
00639  * @note From 1.4, compression support is always compiled in.
00640  */
00641 svn_stream_t *svn_stream_compressed(svn_stream_t *stream,
00642                                     apr_pool_t *pool);
00643 
00644 /** Return a stream that calculates checksums for all data read
00645  * and written.  The stream @a stream is used to read and write all data.
00646  * The stream and the resulting digests are allocated in @a pool.
00647  *
00648  * When the stream is closed, @a read_digest and @a write_digest
00649  * are set to point to the resulting digests.
00650  *
00651  * Both @a read_digest and @a write_digest
00652  * can be @c NULL, in which case the respective checksum isn't calculated.
00653  *
00654  * If @a read_all is TRUE, make sure that all data available on @a
00655  * stream is read (and checksummed) when the stream is closed.
00656  *
00657  * Read and write operations can be mixed without interfering.
00658  *
00659  * The @a stream passed into this function is closed when the created
00660  * stream is closed.
00661  *
00662  * @since New in 1.4.
00663  */
00664 svn_stream_t *svn_stream_checksummed(svn_stream_t *stream,
00665                                      const unsigned char **read_digest,
00666                                      const unsigned char **write_digest,
00667                                      svn_boolean_t read_all,
00668                                      apr_pool_t *pool);
00669 
00670 /** Read from a generic stream. @see svn_stream_t. */
00671 svn_error_t *svn_stream_read(svn_stream_t *stream, char *buffer,
00672                              apr_size_t *len);
00673 
00674 /** Write to a generic stream. @see svn_stream_t. */
00675 svn_error_t *svn_stream_write(svn_stream_t *stream, const char *data,
00676                               apr_size_t *len);
00677 
00678 /** Close a generic stream. @see svn_stream_t. */
00679 svn_error_t *svn_stream_close(svn_stream_t *stream);
00680 
00681 
00682 /** Write to @a stream using a printf-style @a fmt specifier, passed through
00683  * apr_psprintf() using memory from @a pool.
00684  */
00685 svn_error_t *svn_stream_printf(svn_stream_t *stream,
00686                                apr_pool_t *pool,
00687                                const char *fmt,
00688                                ...)
00689        __attribute__((format(printf, 3, 4)));
00690 
00691 /** Write to @a stream using a printf-style @a fmt specifier, passed through
00692  * apr_psprintf() using memory from @a pool.  The resulting string
00693  * will be translated to @a encoding before it is sent to @a stream.
00694  *
00695  * @note Use @c APR_LOCALE_CHARSET to translate to the encoding of the
00696  * current locale.
00697  *
00698  * @since New in 1.3.
00699  */
00700 svn_error_t *svn_stream_printf_from_utf8(svn_stream_t *stream,
00701                                          const char *encoding,
00702                                          apr_pool_t *pool,
00703                                          const char *fmt,
00704                                          ...)
00705        __attribute__((format(printf, 4, 5)));
00706 
00707 /** Allocate @a *stringbuf in @a pool, and read into it one line (terminated
00708  * by @a eol) from @a stream. The line-terminator is read from the stream,
00709  * but is not added to the end of the stringbuf.  Instead, the stringbuf
00710  * ends with a usual '\\0'.
00711  *
00712  * If @a stream runs out of bytes before encountering a line-terminator,
00713  * then set @a *eof to @c TRUE, otherwise set @a *eof to FALSE.
00714  */
00715 svn_error_t *
00716 svn_stream_readline(svn_stream_t *stream,
00717                     svn_stringbuf_t **stringbuf,
00718                     const char *eol,
00719                     svn_boolean_t *eof,
00720                     apr_pool_t *pool);
00721 
00722 /**
00723  * Read the contents of the readable stream @a from and write them to the
00724  * writable stream @a to calling @a cancel_func before copying each chunk.
00725  *
00726  * @a cancel_func may be @c NULL.
00727  *
00728  * @since New in 1.5.
00729  */
00730 svn_error_t *svn_stream_copy2(svn_stream_t *from, svn_stream_t *to,
00731                               svn_cancel_func_t cancel_func,
00732                               void *cancel_baton,
00733                               apr_pool_t *pool);
00734 
00735 
00736 /**
00737  * Same as svn_stream_copy2(), but without the cancellation function.
00738  *
00739  * @since New in 1.1.
00740  * @deprecated Provided for backward compatibility with the 1.4 API.
00741  */
00742 svn_error_t *svn_stream_copy(svn_stream_t *from, svn_stream_t *to,
00743                              apr_pool_t *pool);
00744 
00745 /** Set @a *same to TRUE if @a stream1 and @a stream2 have the same
00746  * contents, else set it to FALSE.  Use @a pool for temporary allocations.
00747  *
00748  * @since New in 1.4.
00749  */
00750 svn_error_t *
00751 svn_stream_contents_same(svn_boolean_t *same,
00752                          svn_stream_t *stream1,
00753                          svn_stream_t *stream2,
00754                          apr_pool_t *pool);
00755 
00756 /** @} */
00757 
00758 /** Set @a *result to a string containing the contents of @a
00759  * filename, which is either "-" (indicating that stdin should be
00760  * read) or the utf8-encoded path of a real file.
00761  *
00762  * @warning Callers should be aware of possible unexpected results
00763  * when using this function to read from stdin where additional
00764  * stdin-reading processes abound.  For example, if a program tries
00765  * both to invoke an external editor and to read from stdin, stdin
00766  * could be trashed and the editor might act funky or die outright.
00767  *
00768  * @since New in 1.5.
00769  */
00770 svn_error_t *svn_stringbuf_from_file2(svn_stringbuf_t **result,
00771                                       const char *filename,
00772                                       apr_pool_t *pool);
00773 
00774 /** Similar to svn_stringbuf_from_file2(), except that if @a filename
00775  * is "-", return the error @c SVN_ERR_UNSUPPORTED_FEATURE and don't
00776  * touch @a *result.
00777  *
00778  * @deprecated Provided for backwards compatibility with the 1.4 API.
00779  */
00780 svn_error_t *svn_stringbuf_from_file(svn_stringbuf_t **result,
00781                                      const char *filename,
00782                                      apr_pool_t *pool);
00783 
00784 /** Sets @a *result to a string containing the contents of the already opened
00785  * @a file.  Reads from the current position in file to the end.  Does not
00786  * close the file or reset the cursor position.
00787  */
00788 svn_error_t *svn_stringbuf_from_aprfile(svn_stringbuf_t **result,
00789                                         apr_file_t *file,
00790                                         apr_pool_t *pool);
00791 
00792 /** Remove file @a path, a utf8-encoded path.  This wraps apr_file_remove(),
00793  * converting any error to a Subversion error.
00794  */
00795 svn_error_t *svn_io_remove_file(const char *path, apr_pool_t *pool);
00796 
00797 /** Recursively remove directory @a path.  @a path is utf8-encoded.
00798  * If @a ignore_enoent is @c TRUE, don't fail if the target directory
00799  * doesn't exist.  Use @a pool for temporary allocations.
00800  *
00801  * Because recursive delete of a directory tree can be a lengthy operation,
00802  * provide @a cancel_func and @a cancel_baton for interuptability.
00803  *
00804  * @since New in 1.5.
00805  */
00806 svn_error_t *svn_io_remove_dir2(const char *path,
00807                                 svn_boolean_t ignore_enoent,
00808                                 svn_cancel_func_t cancel_func,
00809                                 void *cancel_baton,
00810                                 apr_pool_t *pool);
00811 
00812 /** Similar to svn_io_remove_dir2(), but with @a ignore_enoent set to
00813  * @c FALSE.
00814  *
00815  * @deprecated Provided for backward compatibility with the 1.4 API
00816  */
00817 svn_error_t *svn_io_remove_dir(const char *path, apr_pool_t *pool);
00818 
00819 /** Read all of the disk entries in directory @a path, a utf8-encoded
00820  * path.  Set @a *dirents to a hash mapping dirent names (<tt>char *</tt>) to
00821  * undefined non-NULL values, allocated in @a pool.
00822  *
00823  * @note The `.' and `..' directories normally returned by
00824  * apr_dir_read() are NOT returned in the hash.
00825  *
00826  * @since New in 1.4.
00827  */
00828 svn_error_t *svn_io_get_dir_filenames(apr_hash_t **dirents,
00829                                       const char *path,
00830                                       apr_pool_t *pool);
00831 
00832 /** Read all of the disk entries in directory @a path, a utf8-encoded
00833  * path.  Set @a *dirents to a hash mapping dirent names (<tt>char *</tt>) to
00834  * @c svn_io_dirent_t structures, allocated in @a pool.
00835  *
00836  * @note The `.' and `..' directories normally returned by
00837  * apr_dir_read() are NOT returned in the hash.
00838  *
00839  * @note The kind field in the @a dirents is set according to the mapping
00840  *       as documented for svn_io_check_path()
00841  *
00842  * @since New in 1.3.
00843  */
00844 svn_error_t *svn_io_get_dirents2(apr_hash_t **dirents,
00845                                  const char *path,
00846                                  apr_pool_t *pool);
00847 
00848 /** Similar to svn_io_get_dirents2(), but @a *dirents is a hash table
00849  * with @c svn_node_kind_t values.
00850  *
00851  * @deprecated Provided for backwards compatibility with the 1.2 API.
00852  */
00853 svn_error_t *svn_io_get_dirents(apr_hash_t **dirents,
00854                                 const char *path,
00855                                 apr_pool_t *pool);
00856 
00857 
00858 /** Callback function type for svn_io_dir_walk() */
00859 typedef svn_error_t * (*svn_io_walk_func_t)(void *baton,
00860                                             const char *path,
00861                                             const apr_finfo_t *finfo,
00862                                             apr_pool_t *pool);
00863 
00864 /** This function will recursively walk over the files and directories
00865  * rooted at @a dirname, a utf8-encoded path. For each file or directory,
00866  * @a walk_func is invoked, passing in the @a walk_baton, the utf8-encoded
00867  * full path to the entry, an @c apr_finfo_t structure, and a temporary
00868  * pool for allocations.  For any directory, @a walk_func will be invoked
00869  * on the directory itself before being invoked on any subdirectories or
00870  * files within the directory.
00871  *
00872  * The set of information passed to @a walk_func is specified by @a wanted,
00873  * and the items specified by @c APR_FINFO_TYPE and @c APR_FINFO_NAME.
00874  *
00875  * All allocations will be performed in @a pool.
00876  */
00877 svn_error_t *svn_io_dir_walk(const char *dirname,
00878                              apr_int32_t wanted,
00879                              svn_io_walk_func_t walk_func,
00880                              void *walk_baton,
00881                              apr_pool_t *pool);
00882 
00883 /**
00884  * Start @a cmd with @a args, using utf8-encoded @a path as working
00885  * directory.  Connect @a cmd's stdin, stdout, and stderr to @a infile,
00886  * @a outfile, and @a errfile, except where they are NULL.  Return the
00887  * process handle for the invoked program in @a *cmd_proc.
00888  *
00889  * @a args is a list of utf8-encoded <tt>const char *</tt> arguments,
00890  * terminated by @c NULL.  @a args[0] is the name of the program, though it
00891  * need not be the same as @a cmd.
00892  *
00893  * If @a inherit is TRUE, the invoked program inherits its environment from
00894  * the caller and @a cmd, if not absolute, is searched for in PATH.
00895  * Otherwise, the invoked program runs with an empty environment and @a cmd
00896  * must be an absolute path.
00897  *
00898  * @note On some platforms, failure to execute @a cmd in the child process
00899  * will result in error output being written to @a errfile, if non-NULL, and
00900  * a non-zero exit status being returned to the parent process.
00901  *
00902  * @since New in 1.3.
00903  */
00904 svn_error_t *svn_io_start_cmd(apr_proc_t *cmd_proc,
00905                               const char *path,
00906                               const char *cmd,
00907                               const char *const *args,
00908                               svn_boolean_t inherit,
00909                               apr_file_t *infile,
00910                               apr_file_t *outfile,
00911                               apr_file_t *errfile,
00912                               apr_pool_t *pool);
00913 
00914 /**
00915  * Wait for the process @a *cmd_proc to complete and optionally retrieve
00916  * its exit code.  @a cmd is used only in error messages.
00917  *
00918  * If @a exitcode is not NULL, @a *exitcode will contain the exit code
00919  * of the process upon return, and if @a exitwhy is not NULL, @a
00920  * *exitwhy will indicate why the process terminated.  If @a exitwhy is
00921  * NULL, and the exit reason is not @c APR_PROC_CHECK_EXIT(), or if
00922  * @a exitcode is NULL and the exit code is non-zero, then an
00923  * @c SVN_ERR_EXTERNAL_PROGRAM error will be returned.
00924  *
00925  * @since New in 1.3.
00926  */
00927 svn_error_t *svn_io_wait_for_cmd(apr_proc_t *cmd_proc,
00928                                  const char *cmd,
00929                                  int *exitcode,
00930                                  apr_exit_why_e *exitwhy,
00931                                  apr_pool_t *pool);
00932 
00933 /** Run a command to completion, by first calling svn_io_start_cmd() and
00934  * then calling svn_io_wait_for_cmd().  The parameters correspond to
00935  * the same-named parameters of those two functions.
00936  */
00937 svn_error_t *svn_io_run_cmd(const char *path,
00938                             const char *cmd,
00939                             const char *const *args,
00940                             int *exitcode,
00941                             apr_exit_why_e *exitwhy,
00942                             svn_boolean_t inherit,
00943                             apr_file_t *infile,
00944                             apr_file_t *outfile,
00945                             apr_file_t *errfile,
00946                             apr_pool_t *pool);
00947 
00948 /** Invoke @c the configured diff program, with @a user_args (an array
00949  * of utf8-encoded @a num_user_args arguments) if they are specified
00950  * (that is, if @a user_args is non-NULL), or "-u" if they are not.
00951  * If @a user_args is NULL, the value of @a num_user_args is ignored.
00952  *
00953  * Diff runs in utf8-encoded @a dir, and its exit status is stored in
00954  * @a exitcode, if it is not @c NULL.
00955  *
00956  * If @a label1 and/or @a label2 are not NULL they will be passed to the diff
00957  * process as the arguments of "-L" options.  @a label1 and @a label2 are also
00958  * in utf8, and will be converted to native charset along with the other args.
00959  *
00960  * @a from is the first file passed to diff, and @a to is the second.  The
00961  * stdout of diff will be sent to @a outfile, and the stderr to @a errfile.
00962  *
00963  * @a diff_cmd must be non-NULL.
00964  *
00965  * Do all allocation in @a pool.
00966  */
00967 svn_error_t *svn_io_run_diff(const char *dir,
00968                              const char *const *user_args,
00969                              int num_user_args,
00970                              const char *label1,
00971                              const char *label2,
00972                              const char *from,
00973                              const char *to,
00974                              int *exitcode,
00975                              apr_file_t *outfile,
00976                              apr_file_t *errfile,
00977                              const char *diff_cmd,
00978                              apr_pool_t *pool);
00979 
00980 
00981 /** Invoke the configured @c diff3 program, in utf8-encoded @a dir
00982  * like this:
00983  *
00984  *          diff3 -E -m @a mine @a older @a yours > @a merged
00985  *
00986  * (See the diff3 documentation for details.)
00987  *
00988  * If @a user_args is non-NULL, replace "-E" with the <tt>const char*</tt>
00989  * elements that @a user_args contains.
00990  *
00991  * @a mine, @a older and @a yours are utf8-encoded paths (relative to
00992  * @a dir or absolute) to three files that already exist.
00993  *
00994  * @a merged is an open file handle, and is left open after the merge
00995  * result is written to it. (@a merged should *not* be the same file
00996  * as @a mine, or nondeterministic things may happen!)
00997  *
00998  * @a mine_label, @a older_label, @a yours_label are utf8-encoded label
00999  * parameters for diff3's -L option.  Any of them may be @c NULL, in
01000  * which case the corresponding @a mine, @a older, or @a yours parameter is
01001  * used instead.
01002  *
01003  * Set @a *exitcode to diff3's exit status.  If @a *exitcode is anything
01004  * other than 0 or 1, then return @c SVN_ERR_EXTERNAL_PROGRAM.  (Note the
01005  * following from the diff3 info pages: "An exit status of 0 means
01006  * `diff3' was successful, 1 means some conflicts were found, and 2
01007  * means trouble.")
01008  *
01009  * @a diff3_cmd must be non-NULL.
01010  *
01011  * Do all allocation in @a pool.
01012  *
01013  * @since New in 1.4.
01014  */
01015 svn_error_t *svn_io_run_diff3_2(int *exitcode,
01016                                 const char *dir,
01017                                 const char *mine,
01018                                 const char *older,
01019                                 const char *yours,
01020                                 const char *mine_label,
01021                                 const char *older_label,
01022                                 const char *yours_label,
01023                                 apr_file_t *merged,
01024                                 const char *diff3_cmd,
01025                                 const apr_array_header_t *user_args,
01026                                 apr_pool_t *pool);
01027 
01028 /** Similar to svn_io_run_diff3_2(), but with @a user_args set to @c NULL.
01029  *
01030  * @deprecated Provided for backwards compatibility with the 1.3 API.
01031  */
01032 svn_error_t *svn_io_run_diff3(const char *dir,
01033                               const char *mine,
01034                               const char *older,
01035                               const char *yours,
01036                               const char *mine_label,
01037                               const char *older_label,
01038                               const char *yours_label,
01039                               apr_file_t *merged,
01040                               int *exitcode,
01041                               const char *diff3_cmd,
01042                               apr_pool_t *pool);
01043 
01044 
01045 /** Parse utf8-encoded @a mimetypes_file as a MIME types file (such as
01046  * is provided with Apache HTTP Server), and set @a *type_map to a
01047  * hash mapping <tt>const char *</tt> filename extensions to
01048  * <tt>const char *</tt> MIME types.
01049  *
01050  * @since New in 1.5.
01051  */
01052 svn_error_t *svn_io_parse_mimetypes_file(apr_hash_t **type_map,
01053                                          const char *mimetypes_file,
01054                                          apr_pool_t *pool);
01055 
01056 
01057 /** Examine utf8-encoded @a file to determine if it can be described by a
01058  * known (as in, known by this function) Multipurpose Internet Mail
01059  * Extension (MIME) type.  If so, set @a *mimetype to a character string
01060  * describing the MIME type, else set it to @c NULL.
01061  *
01062  * If not @c NULL, @a mimetype_map is a hash mapping <tt>const char *</tt>
01063  * filename extensions to <tt>const char *</tt> MIME types, and is the
01064  * first source consulted regarding @a file's MIME type.
01065  *
01066  * Use @a pool for any necessary allocations.
01067  *
01068  * @since New in 1.5.
01069  */
01070 svn_error_t *svn_io_detect_mimetype2(const char **mimetype,
01071                                      const char *file,
01072                                      apr_hash_t *mimetype_map,
01073                                      apr_pool_t *pool);
01074 
01075 
01076 /** Like svn_io_detect_mimetype2, but with @a mimetypes_map set to
01077  * @c NULL.
01078  *
01079  * @deprecated Provided for backward compatibility with the 1.4 API
01080  */
01081 svn_error_t *svn_io_detect_mimetype(const char **mimetype,
01082                                     const char *file,
01083                                     apr_pool_t *pool);
01084 
01085 
01086 /** Wrapper for apr_file_open().  @a fname is utf8-encoded. */
01087 svn_error_t *
01088 svn_io_file_open(apr_file_t **new_file, const char *fname,
01089                  apr_int32_t flag, apr_fileperms_t perm,
01090                  apr_pool_t *pool);
01091 
01092 
01093 /** Wrapper for apr_file_close(). */
01094 svn_error_t *
01095 svn_io_file_close(apr_file_t *file, apr_pool_t *pool);
01096 
01097 
01098 /** Wrapper for apr_file_getc(). */
01099 svn_error_t *
01100 svn_io_file_getc(char *ch, apr_file_t *file, apr_pool_t *pool);
01101 
01102 
01103 /** Wrapper for apr_file_info_get(). */
01104 svn_error_t *
01105 svn_io_file_info_get(apr_finfo_t *finfo, apr_int32_t wanted,
01106                      apr_file_t *file, apr_pool_t *pool);
01107 
01108 
01109 /** Wrapper for apr_file_read(). */
01110 svn_error_t *
01111 svn_io_file_read(apr_file_t *file, void *buf,
01112                  apr_size_t *nbytes, apr_pool_t *pool);
01113 
01114 
01115 /** Wrapper for apr_file_read_full(). */
01116 svn_error_t *
01117 svn_io_file_read_full(apr_file_t *file, void *buf,
01118                       apr_size_t nbytes, apr_size_t *bytes_read,
01119                       apr_pool_t *pool);
01120 
01121 
01122 /** Wrapper for apr_file_seek(). */
01123 svn_error_t *
01124 svn_io_file_seek(apr_file_t *file, apr_seek_where_t where,
01125                  apr_off_t *offset, apr_pool_t *pool);
01126 
01127 
01128 /** Wrapper for apr_file_write(). */
01129 svn_error_t *
01130 svn_io_file_write(apr_file_t *file, const void *buf,
01131                   apr_size_t *nbytes, apr_pool_t *pool);
01132 
01133 
01134 /** Wrapper for apr_file_write_full(). */
01135 svn_error_t *
01136 svn_io_file_write_full(apr_file_t *file, const void *buf,
01137                        apr_size_t nbytes, apr_size_t *bytes_written,
01138                        apr_pool_t *pool);
01139 
01140 
01141 /** Wrapper for apr_stat().  @a fname is utf8-encoded. */
01142 svn_error_t *
01143 svn_io_stat(apr_finfo_t *finfo, const char *fname,
01144             apr_int32_t wanted, apr_pool_t *pool);
01145 
01146 
01147 /** Wrapper for apr_file_rename().  @a from_path and @a to_path are
01148  * utf8-encoded.
01149  */
01150 svn_error_t *
01151 svn_io_file_rename(const char *from_path, const char *to_path,
01152                    apr_pool_t *pool);
01153 
01154 
01155 /** Move the file from @a from_path to @a to_path, even across device
01156  * boundaries. Overwrite @a to_path if it exists.
01157  *
01158  * @note This function is different from svn_io_file_rename in that the
01159  * latter fails in the 'across device boundaries' case.
01160  *
01161  * @since New in 1.3.
01162  */
01163 svn_error_t *
01164 svn_io_file_move(const char *from_path, const char *to_path,
01165                  apr_pool_t *pool);
01166 
01167 
01168 /** Wrapper for apr_dir_make().  @a path is utf8-encoded. */
01169 svn_error_t *
01170 svn_io_dir_make(const char *path, apr_fileperms_t perm, apr_pool_t *pool);
01171 
01172 /** Same as svn_io_dir_make(), but sets the hidden attribute on the
01173     directory on systems that support it. */
01174 svn_error_t *
01175 svn_io_dir_make_hidden(const char *path, apr_fileperms_t perm,
01176                        apr_pool_t *pool);
01177 
01178 /**
01179  * Same as svn_io_dir_make(), but attempts to set the sgid on the
01180  * directory on systems that support it.  Does not return an error if
01181  * the attempt to set the sgid bit fails.  On Unix filesystems,
01182  * setting the sgid bit on a directory ensures that files and
01183  * subdirectories created within inherit group ownership from the
01184  * parent instead of from the primary gid.
01185  *
01186  * @since New in 1.1.
01187  */
01188 svn_error_t *
01189 svn_io_dir_make_sgid(const char *path, apr_fileperms_t perm,
01190                      apr_pool_t *pool);
01191 
01192 /** Wrapper for apr_dir_open().  @a dirname is utf8-encoded. */
01193 svn_error_t *
01194 svn_io_dir_open(apr_dir_t **new_dir, const char *dirname, apr_pool_t *pool);
01195 
01196 
01197 /** Wrapper for apr_dir_remove().  @a dirname is utf8-encoded.
01198  * @note This function has this name to avoid confusion with
01199  * svn_io_remove_dir2(), which is recursive.
01200  */
01201 svn_error_t *
01202 svn_io_dir_remove_nonrecursive(const char *dirname, apr_pool_t *pool);
01203 
01204 
01205 /** Wrapper for apr_dir_read().  Ensures that @a finfo->name is
01206  * utf8-encoded, which means allocating @a finfo->name in @a pool,
01207  * which may or may not be the same as @a finfo's pool.  Use @a pool
01208  * for error allocation as well.
01209  */
01210 svn_error_t *
01211 svn_io_dir_read(apr_finfo_t *finfo,
01212                 apr_int32_t wanted,
01213                 apr_dir_t *thedir,
01214                 apr_pool_t *pool);
01215 
01216 
01217 
01218 /** Version/format files.
01219  *
01220  * @defgroup svn_io_format_files Version/format files
01221  * @{
01222  */
01223 
01224 /** Set @a *version to the integer that starts the file at @a path.  If the
01225  * file does not begin with a series of digits followed by a newline,
01226  * return the error @c SVN_ERR_BAD_VERSION_FILE_FORMAT.  Use @a pool for
01227  * all allocations.
01228  */
01229 svn_error_t *
01230 svn_io_read_version_file(int *version, const char *path, apr_pool_t *pool);
01231 
01232 /** Create (or overwrite) the file at @a path with new contents,
01233  * formatted as a non-negative integer @a version followed by a single
01234  * newline.  On successful completion the file will be read-only.  Use
01235  * @a pool for all allocations.
01236  */
01237 svn_error_t *
01238 svn_io_write_version_file(const char *path, int version, apr_pool_t *pool);
01239 
01240 /** @} */
01241 
01242 #ifdef __cplusplus
01243 }
01244 #endif /* __cplusplus */
01245 
01246 #endif /* SVN_IO_H */

Generated on Sun Dec 14 02:22:43 2008 for Subversion by  doxygen 1.4.7