00001 /** 00002 * @copyright 00003 * ==================================================================== 00004 * Licensed to the Apache Software Foundation (ASF) under one 00005 * or more contributor license agreements. See the NOTICE file 00006 * distributed with this work for additional information 00007 * regarding copyright ownership. The ASF licenses this file 00008 * to you under the Apache License, Version 2.0 (the 00009 * "License"); you may not use this file except in compliance 00010 * with the License. You may obtain a copy of the License at 00011 * 00012 * http://www.apache.org/licenses/LICENSE-2.0 00013 * 00014 * Unless required by applicable law or agreed to in writing, 00015 * software distributed under the License is distributed on an 00016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 00017 * KIND, either express or implied. See the License for the 00018 * specific language governing permissions and limitations 00019 * under the License. 00020 * ==================================================================== 00021 * @endcopyright 00022 * 00023 * @file svn_io.h 00024 * @brief General file I/O for Subversion 00025 */ 00026 00027 /* ==================================================================== */ 00028 00029 00030 #ifndef SVN_IO_H 00031 #define SVN_IO_H 00032 00033 #include <apr.h> 00034 #include <apr_pools.h> 00035 #include <apr_time.h> 00036 #include <apr_hash.h> 00037 #include <apr_tables.h> 00038 #include <apr_file_io.h> 00039 #include <apr_file_info.h> 00040 #include <apr_thread_proc.h> /* for apr_proc_t, apr_exit_why_e */ 00041 00042 #include "svn_types.h" 00043 #include "svn_string.h" 00044 #include "svn_checksum.h" 00045 00046 #ifdef __cplusplus 00047 extern "C" { 00048 #endif /* __cplusplus */ 00049 00050 00051 00052 /** Used as an argument when creating temporary files to indicate 00053 * when a file should be removed. 00054 * 00055 * @since New in 1.4. 00056 * 00057 * Not specifying any of these means no removal at all. */ 00058 typedef enum svn_io_file_del_t 00059 { 00060 /** No deletion ever */ 00061 svn_io_file_del_none = 0, 00062 /** Remove when the file is closed */ 00063 svn_io_file_del_on_close, 00064 /** Remove when the associated pool is cleared */ 00065 svn_io_file_del_on_pool_cleanup 00066 } svn_io_file_del_t; 00067 00068 /** A set of directory entry data elements as returned by svn_io_get_dirents 00069 * 00070 * Note that the first two fields are exactly identical to svn_io_dirent_t 00071 * to allow returning a svn_io_dirent2_t as a svn_io_dirent_t. 00072 * 00073 * Use svn_io_dirent2_create() to create new svn_dirent2_t instances or 00074 * svn_io_dirent2_dup() to duplicate an existing instance. 00075 * 00076 * @since New in 1.7. 00077 */ 00078 typedef struct svn_io_dirent2_t { 00079 /* New fields must be added at the end to preserve binary compatibility */ 00080 00081 /** The kind of this entry. */ 00082 svn_node_kind_t kind; 00083 00084 /** If @c kind is #svn_node_file, whether this entry is a special file; 00085 * else FALSE. 00086 * 00087 * @see svn_io_check_special_path(). 00088 */ 00089 svn_boolean_t special; 00090 00091 /** The filesize of this entry or undefined for a directory */ 00092 svn_filesize_t filesize; 00093 00094 /** The time the file was last modified */ 00095 apr_time_t mtime; 00096 00097 /* Don't forget to update svn_io_dirent2_dup() when adding new fields */ 00098 } svn_io_dirent2_t; 00099 00100 00101 /** Creates a new #svn_io_dirent2_t structure 00102 * 00103 * @since New in 1.7. 00104 */ 00105 svn_io_dirent2_t * 00106 svn_io_dirent2_create(apr_pool_t *result_pool); 00107 00108 /** Duplicates a @c svn_io_dirent2_t structure into @a result_pool. 00109 * 00110 * @since New in 1.7. 00111 */ 00112 svn_io_dirent2_t * 00113 svn_io_dirent2_dup(const svn_io_dirent2_t *item, 00114 apr_pool_t *result_pool); 00115 00116 /** Represents the kind and special status of a directory entry. 00117 * 00118 * Note that the first two fields are exactly identical to svn_io_dirent2_t 00119 * to allow returning a svn_io_dirent2_t as a svn_io_dirent_t. 00120 * 00121 * @since New in 1.3. 00122 */ 00123 typedef struct svn_io_dirent_t { 00124 /** The kind of this entry. */ 00125 svn_node_kind_t kind; 00126 /** If @c kind is #svn_node_file, whether this entry is a special file; 00127 * else FALSE. 00128 * 00129 * @see svn_io_check_special_path(). 00130 */ 00131 svn_boolean_t special; 00132 } svn_io_dirent_t; 00133 00134 /** Determine the @a kind of @a path. @a path should be UTF-8 encoded. 00135 * 00136 * If @a path is a file, set @a *kind to #svn_node_file. 00137 * 00138 * If @a path is a directory, set @a *kind to #svn_node_dir. 00139 * 00140 * If @a path does not exist, set @a *kind to #svn_node_none. 00141 * 00142 * If @a path exists but is none of the above, set @a *kind to 00143 * #svn_node_unknown. 00144 * 00145 * If @a path is not a valid pathname, set @a *kind to #svn_node_none. If 00146 * unable to determine @a path's kind for any other reason, return an error, 00147 * with @a *kind's value undefined. 00148 * 00149 * Use @a pool for temporary allocations. 00150 * 00151 * @see svn_node_kind_t 00152 */ 00153 svn_error_t * 00154 svn_io_check_path(const char *path, 00155 svn_node_kind_t *kind, 00156 apr_pool_t *pool); 00157 00158 /** 00159 * Like svn_io_check_path(), but also set *is_special to @c TRUE if 00160 * the path is not a normal file. 00161 * 00162 * @since New in 1.1. 00163 */ 00164 svn_error_t * 00165 svn_io_check_special_path(const char *path, 00166 svn_node_kind_t *kind, 00167 svn_boolean_t *is_special, 00168 apr_pool_t *pool); 00169 00170 /** Like svn_io_check_path(), but resolve symlinks. This returns the 00171 same varieties of @a kind as svn_io_check_path(). */ 00172 svn_error_t * 00173 svn_io_check_resolved_path(const char *path, 00174 svn_node_kind_t *kind, 00175 apr_pool_t *pool); 00176 00177 00178 /** Open a new file (for reading and writing) with a unique name based on 00179 * utf-8 encoded @a filename, in the directory @a dirpath. The file handle is 00180 * returned in @a *file, and the name, which ends with @a suffix, is returned 00181 * in @a *unique_name, also utf8-encoded. Either @a file or @a unique_name 00182 * may be @c NULL. If @a file is @c NULL, the file will be created but not 00183 * open. 00184 * 00185 * The file will be deleted according to @a delete_when. If that is 00186 * #svn_io_file_del_on_pool_cleanup, it refers to @a result_pool. 00187 * 00188 * The @c APR_BUFFERED flag will always be used when opening the file. 00189 * 00190 * The first attempt will just append @a suffix. If the result is not 00191 * a unique name, then subsequent attempts will append a dot, 00192 * followed by an iteration number ("2", then "3", and so on), 00193 * followed by the suffix. For example, successive calls to 00194 * 00195 * svn_io_open_uniquely_named(&f, &u, "tests/t1/A/D/G", "pi", ".tmp", ...) 00196 * 00197 * will open 00198 * 00199 * tests/t1/A/D/G/pi.tmp 00200 * tests/t1/A/D/G/pi.2.tmp 00201 * tests/t1/A/D/G/pi.3.tmp 00202 * tests/t1/A/D/G/pi.4.tmp 00203 * tests/t1/A/D/G/pi.5.tmp 00204 * ... 00205 * 00206 * Assuming @a suffix is non-empty, @a *unique_name will never be exactly 00207 * the same as @a filename, even if @a filename does not exist. 00208 * 00209 * If @a dirpath is NULL, then the directory returned by svn_io_temp_dir() 00210 * will be used. 00211 * 00212 * If @a filename is NULL, then "tempfile" will be used. 00213 * 00214 * If @a suffix is NULL, then ".tmp" will be used. 00215 * 00216 * Allocates @a *file and @a *unique_name in @a result_pool. All 00217 * intermediate allocations will be performed in @a scratch_pool. 00218 * 00219 * If no unique name can be found, #SVN_ERR_IO_UNIQUE_NAMES_EXHAUSTED is 00220 * the error returned. 00221 * 00222 * Claim of Historical Inevitability: this function was written 00223 * because 00224 * 00225 * - tmpnam() is not thread-safe. 00226 * - tempname() tries standard system tmp areas first. 00227 * 00228 * @since New in 1.6 00229 */ 00230 svn_error_t * 00231 svn_io_open_uniquely_named(apr_file_t **file, 00232 const char **unique_name, 00233 const char *dirpath, 00234 const char *filename, 00235 const char *suffix, 00236 svn_io_file_del_t delete_when, 00237 apr_pool_t *result_pool, 00238 apr_pool_t *scratch_pool); 00239 00240 00241 /** Create a writable file, with an arbitrary and unique name, in the 00242 * directory @a dirpath. Set @a *temp_path to its full path, and set 00243 * @a *file to the file handle, both allocated from @a result_pool. Either 00244 * @a file or @a temp_path may be @c NULL. If @a file is @c NULL, the file 00245 * will be created but not open. 00246 * 00247 * If @a dirpath is @c NULL, use the path returned from svn_io_temp_dir(). 00248 * (Note that when using the system-provided temp directory, it may not 00249 * be possible to atomically rename the resulting file due to cross-device 00250 * issues.) 00251 * 00252 * The file will be deleted according to @a delete_when. If that is 00253 * #svn_io_file_del_on_pool_cleanup, it refers to @a result_pool. If it 00254 * is #svn_io_file_del_on_close and @a file is @c NULL, the file will be 00255 * deleted before this function returns. 00256 * 00257 * When passing @c svn_io_file_del_none please don't forget to eventually 00258 * remove the temporary file to avoid filling up the system temp directory. 00259 * It is often appropriate to bind the lifetime of the temporary file to 00260 * the lifetime of a pool by using @c svn_io_file_del_on_pool_cleanup. 00261 * 00262 * Temporary allocations will be performed in @a scratch_pool. 00263 * 00264 * @since New in 1.6 00265 * @see svn_stream_open_unique() 00266 */ 00267 svn_error_t * 00268 svn_io_open_unique_file3(apr_file_t **file, 00269 const char **temp_path, 00270 const char *dirpath, 00271 svn_io_file_del_t delete_when, 00272 apr_pool_t *result_pool, 00273 apr_pool_t *scratch_pool); 00274 00275 00276 /** Like svn_io_open_uniquely_named(), but takes a joined dirpath and 00277 * filename, and a single pool. 00278 * 00279 * @since New in 1.4 00280 * 00281 * @deprecated Provided for backward compatibility with the 1.5 API 00282 */ 00283 SVN_DEPRECATED 00284 svn_error_t * 00285 svn_io_open_unique_file2(apr_file_t **f, 00286 const char **unique_name_p, 00287 const char *path, 00288 const char *suffix, 00289 svn_io_file_del_t delete_when, 00290 apr_pool_t *pool); 00291 00292 /** Like svn_io_open_unique_file2, but can't delete on pool cleanup. 00293 * 00294 * @deprecated Provided for backward compatibility with the 1.3 API 00295 * 00296 * @note In 1.4 the API was extended to require either @a f or 00297 * @a unique_name_p (the other can be NULL). Before that, both were 00298 * required. 00299 */ 00300 SVN_DEPRECATED 00301 svn_error_t * 00302 svn_io_open_unique_file(apr_file_t **f, 00303 const char **unique_name_p, 00304 const char *path, 00305 const char *suffix, 00306 svn_boolean_t delete_on_close, 00307 apr_pool_t *pool); 00308 00309 00310 /** 00311 * Like svn_io_open_unique_file(), except that instead of creating a 00312 * file, a symlink is generated that references the path @a dest. 00313 * 00314 * @since New in 1.1. 00315 */ 00316 svn_error_t * 00317 svn_io_create_unique_link(const char **unique_name_p, 00318 const char *path, 00319 const char *dest, 00320 const char *suffix, 00321 apr_pool_t *pool); 00322 00323 00324 /** 00325 * Set @a *dest to the path that the symlink at @a path references. 00326 * Allocate the string from @a pool. 00327 * 00328 * @since New in 1.1. 00329 */ 00330 svn_error_t * 00331 svn_io_read_link(svn_string_t **dest, 00332 const char *path, 00333 apr_pool_t *pool); 00334 00335 00336 /** Set @a *dir to a directory path (allocated in @a pool) deemed 00337 * usable for the creation of temporary files and subdirectories. 00338 */ 00339 svn_error_t * 00340 svn_io_temp_dir(const char **dir, 00341 apr_pool_t *pool); 00342 00343 00344 /** Copy @a src to @a dst atomically, in a "byte-for-byte" manner. 00345 * Overwrite @a dst if it exists, else create it. Both @a src and @a dst 00346 * are utf8-encoded filenames. If @a copy_perms is TRUE, set @a dst's 00347 * permissions to match those of @a src. 00348 */ 00349 svn_error_t * 00350 svn_io_copy_file(const char *src, 00351 const char *dst, 00352 svn_boolean_t copy_perms, 00353 apr_pool_t *pool); 00354 00355 00356 /** Copy permission flags from @a src onto the file at @a dst. Both 00357 * filenames are utf8-encoded filenames. 00358 * 00359 * @since New in 1.6. 00360 */ 00361 svn_error_t * 00362 svn_io_copy_perms(const char *src, 00363 const char *dst, 00364 apr_pool_t *pool); 00365 00366 00367 /** 00368 * Copy symbolic link @a src to @a dst atomically. Overwrite @a dst 00369 * if it exists, else create it. Both @a src and @a dst are 00370 * utf8-encoded filenames. After copying, the @a dst link will point 00371 * to the same thing @a src does. 00372 * 00373 * @since New in 1.1. 00374 */ 00375 svn_error_t * 00376 svn_io_copy_link(const char *src, 00377 const char *dst, 00378 apr_pool_t *pool); 00379 00380 00381 /** Recursively copy directory @a src into @a dst_parent, as a new entry named 00382 * @a dst_basename. If @a dst_basename already exists in @a dst_parent, 00383 * return error. @a copy_perms will be passed through to svn_io_copy_file() 00384 * when any files are copied. @a src, @a dst_parent, and @a dst_basename are 00385 * all utf8-encoded. 00386 * 00387 * If @a cancel_func is non-NULL, invoke it with @a cancel_baton at 00388 * various points during the operation. If it returns any error 00389 * (typically #SVN_ERR_CANCELLED), return that error immediately. 00390 */ 00391 svn_error_t * 00392 svn_io_copy_dir_recursively(const char *src, 00393 const char *dst_parent, 00394 const char *dst_basename, 00395 svn_boolean_t copy_perms, 00396 svn_cancel_func_t cancel_func, 00397 void *cancel_baton, 00398 apr_pool_t *pool); 00399 00400 00401 /** Create directory @a path on the file system, creating intermediate 00402 * directories as required, like <tt>mkdir -p</tt>. Report no error if @a 00403 * path already exists. @a path is utf8-encoded. 00404 * 00405 * This is essentially a wrapper for apr_dir_make_recursive(), passing 00406 * @c APR_OS_DEFAULT as the permissions. 00407 */ 00408 svn_error_t * 00409 svn_io_make_dir_recursively(const char *path, 00410 apr_pool_t *pool); 00411 00412 00413 /** Set @a *is_empty_p to @c TRUE if directory @a path is empty, else to 00414 * @c FALSE if it is not empty. @a path must be a directory, and is 00415 * utf8-encoded. Use @a pool for temporary allocation. 00416 */ 00417 svn_error_t * 00418 svn_io_dir_empty(svn_boolean_t *is_empty_p, 00419 const char *path, 00420 apr_pool_t *pool); 00421 00422 00423 /** Append @a src to @a dst. @a dst will be appended to if it exists, else it 00424 * will be created. Both @a src and @a dst are utf8-encoded. 00425 */ 00426 svn_error_t * 00427 svn_io_append_file(const char *src, 00428 const char *dst, 00429 apr_pool_t *pool); 00430 00431 00432 /** Make a file as read-only as the operating system allows. 00433 * @a path is the utf8-encoded path to the file. If @a ignore_enoent is 00434 * @c TRUE, don't fail if the target file doesn't exist. 00435 * 00436 * If @a path is a symlink, do nothing. 00437 * 00438 * @note If @a path is a directory, act on it as though it were a 00439 * file, as described above, but note that you probably don't want to 00440 * call this function on directories. We have left it effective on 00441 * directories for compatibility reasons, but as its name implies, it 00442 * should be used only for files. 00443 */ 00444 svn_error_t * 00445 svn_io_set_file_read_only(const char *path, 00446 svn_boolean_t ignore_enoent, 00447 apr_pool_t *pool); 00448 00449 00450 /** Make a file as writable as the operating system allows. 00451 * @a path is the utf8-encoded path to the file. If @a ignore_enoent is 00452 * @c TRUE, don't fail if the target file doesn't exist. 00453 * @warning On Unix this function will do the equivalent of chmod a+w path. 00454 * If this is not what you want you should not use this function, but rather 00455 * use apr_file_perms_set(). 00456 * 00457 * If @a path is a symlink, do nothing. 00458 * 00459 * @note If @a path is a directory, act on it as though it were a 00460 * file, as described above, but note that you probably don't want to 00461 * call this function on directories. We have left it effective on 00462 * directories for compatibility reasons, but as its name implies, it 00463 * should be used only for files. 00464 */ 00465 svn_error_t * 00466 svn_io_set_file_read_write(const char *path, 00467 svn_boolean_t ignore_enoent, 00468 apr_pool_t *pool); 00469 00470 00471 /** Similar to svn_io_set_file_read_* functions. 00472 * Change the read-write permissions of a file. 00473 * @since New in 1.1. 00474 * 00475 * When making @a path read-write on operating systems with unix style 00476 * permissions, set the permissions on @a path to the permissions that 00477 * are set when a new file is created (effectively honoring the user's 00478 * umask). 00479 * 00480 * When making the file read-only on operating systems with unix style 00481 * permissions, remove all write permissions. 00482 * 00483 * On other operating systems, toggle the file's "writability" as much as 00484 * the operating system allows. 00485 * 00486 * @a path is the utf8-encoded path to the file. If @a enable_write 00487 * is @c TRUE, then make the file read-write. If @c FALSE, make it 00488 * read-only. If @a ignore_enoent is @c TRUE, don't fail if the target 00489 * file doesn't exist. 00490 * 00491 * @deprecated Provided for backward compatibility with the 1.3 API. 00492 */ 00493 SVN_DEPRECATED 00494 svn_error_t * 00495 svn_io_set_file_read_write_carefully(const char *path, 00496 svn_boolean_t enable_write, 00497 svn_boolean_t ignore_enoent, 00498 apr_pool_t *pool); 00499 00500 /** Set @a path's "executability" (but do nothing if it is a symlink). 00501 * 00502 * @a path is the utf8-encoded path to the file. If @a executable 00503 * is @c TRUE, then make the file executable. If @c FALSE, make it 00504 * non-executable. If @a ignore_enoent is @c TRUE, don't fail if the target 00505 * file doesn't exist. 00506 * 00507 * When making the file executable on operating systems with unix style 00508 * permissions, never add an execute permission where there is not 00509 * already a read permission: that is, only make the file executable 00510 * for the user, group or world if the corresponding read permission 00511 * is already set for user, group or world. 00512 * 00513 * When making the file non-executable on operating systems with unix style 00514 * permissions, remove all execute permissions. 00515 * 00516 * On other operating systems, toggle the file's "executability" as much as 00517 * the operating system allows. 00518 * 00519 * @note If @a path is a directory, act on it as though it were a 00520 * file, as described above, but note that you probably don't want to 00521 * call this function on directories. We have left it effective on 00522 * directories for compatibility reasons, but as its name implies, it 00523 * should be used only for files. 00524 */ 00525 svn_error_t * 00526 svn_io_set_file_executable(const char *path, 00527 svn_boolean_t executable, 00528 svn_boolean_t ignore_enoent, 00529 apr_pool_t *pool); 00530 00531 /** Determine whether a file is executable by the current user. 00532 * Set @a *executable to @c TRUE if the file @a path is executable by the 00533 * current user, otherwise set it to @c FALSE. 00534 * 00535 * On Windows and on platforms without userids, always returns @c FALSE. 00536 */ 00537 svn_error_t * 00538 svn_io_is_file_executable(svn_boolean_t *executable, 00539 const char *path, 00540 apr_pool_t *pool); 00541 00542 00543 /** Read a line from @a file into @a buf, but not exceeding @a *limit bytes. 00544 * Does not include newline, instead '\\0' is put there. 00545 * Length (as in strlen) is returned in @a *limit. 00546 * @a buf should be pre-allocated. 00547 * @a file should be already opened. 00548 * 00549 * When the file is out of lines, @c APR_EOF will be returned. 00550 */ 00551 svn_error_t * 00552 svn_io_read_length_line(apr_file_t *file, 00553 char *buf, 00554 apr_size_t *limit, 00555 apr_pool_t *pool); 00556 00557 00558 /** Set @a *apr_time to the time of last modification of the contents of the 00559 * file @a path. @a path is utf8-encoded. 00560 * 00561 * @note This is the APR mtime which corresponds to the traditional mtime 00562 * on Unix, and the last write time on Windows. 00563 */ 00564 svn_error_t * 00565 svn_io_file_affected_time(apr_time_t *apr_time, 00566 const char *path, 00567 apr_pool_t *pool); 00568 00569 /** Set the timestamp of file @a path to @a apr_time. @a path is 00570 * utf8-encoded. 00571 * 00572 * @note This is the APR mtime which corresponds to the traditional mtime 00573 * on Unix, and the last write time on Windows. 00574 */ 00575 svn_error_t * 00576 svn_io_set_file_affected_time(apr_time_t apr_time, 00577 const char *path, 00578 apr_pool_t *pool); 00579 00580 /** Sleep to ensure that any files modified after we exit have a different 00581 * timestamp than the one we recorded. If @a path is not NULL, check if we 00582 * can determine how long we should wait for a new timestamp on the filesystem 00583 * containing @a path, an existing file or directory. If @a path is NULL or we 00584 * can't determine the timestamp resolution, sleep until the next second. 00585 * 00586 * Use @a pool for any necessary allocations. @a pool can be null if @a path 00587 * is NULL. 00588 * 00589 * Errors while retrieving the timestamp resolution will result in sleeping 00590 * to the next second, to keep the working copy stable in error conditions. 00591 * 00592 * @since New in 1.6. 00593 */ 00594 void 00595 svn_io_sleep_for_timestamps(const char *path, apr_pool_t *pool); 00596 00597 /** Set @a *different_p to TRUE if @a file1 and @a file2 have different 00598 * sizes, else set to FALSE. Both @a file1 and @a file2 are utf8-encoded. 00599 * 00600 * Setting @a *different_p to zero does not mean the files definitely 00601 * have the same size, it merely means that the sizes are not 00602 * definitely different. That is, if the size of one or both files 00603 * cannot be determined, then the sizes are not known to be different, 00604 * so @a *different_p is set to FALSE. 00605 */ 00606 svn_error_t * 00607 svn_io_filesizes_different_p(svn_boolean_t *different_p, 00608 const char *file1, 00609 const char *file2, 00610 apr_pool_t *pool); 00611 00612 /** Set @a *different_p12 to non-zero if @a file1 and @a file2 have different 00613 * sizes, else set to zero. Do the similar for @a *different_p23 with 00614 * @a file2 and @a file3, and @a *different_p13 for @a file1 and @a file3. 00615 * The filenames @a file1, @a file2 and @a file3 are utf8-encoded. 00616 * 00617 * Setting @a *different_p12 to zero does not mean the files definitely 00618 * have the same size, it merely means that the sizes are not 00619 * definitely different. That is, if the size of one or both files 00620 * cannot be determined (due to stat() returning an error), then the sizes 00621 * are not known to be different, so @a *different_p12 is set to 0. 00622 * 00623 * @since New in 1.8. 00624 */ 00625 svn_error_t * 00626 svn_io_filesizes_three_different_p(svn_boolean_t *different_p12, 00627 svn_boolean_t *different_p23, 00628 svn_boolean_t *different_p13, 00629 const char *file1, 00630 const char *file2, 00631 const char *file3, 00632 apr_pool_t *scratch_pool); 00633 00634 /** Return in @a *checksum the checksum of type @a kind of @a file 00635 * Use @a pool for temporary allocations and to allocate @a *checksum. 00636 * 00637 * @since New in 1.6. 00638 */ 00639 svn_error_t * 00640 svn_io_file_checksum2(svn_checksum_t **checksum, 00641 const char *file, 00642 svn_checksum_kind_t kind, 00643 apr_pool_t *pool); 00644 00645 00646 /** Put the md5 checksum of @a file into @a digest. 00647 * @a digest points to @c APR_MD5_DIGESTSIZE bytes of storage. 00648 * Use @a pool only for temporary allocations. 00649 * 00650 * @deprecated Provided for backward compatibility with the 1.5 API. 00651 */ 00652 SVN_DEPRECATED 00653 svn_error_t * 00654 svn_io_file_checksum(unsigned char digest[], 00655 const char *file, 00656 apr_pool_t *pool); 00657 00658 00659 /** Set @a *same to TRUE if @a file1 and @a file2 have the same 00660 * contents, else set it to FALSE. Use @a pool for temporary allocations. 00661 */ 00662 svn_error_t * 00663 svn_io_files_contents_same_p(svn_boolean_t *same, 00664 const char *file1, 00665 const char *file2, 00666 apr_pool_t *pool); 00667 00668 /** Set @a *same12 to TRUE if @a file1 and @a file2 have the same 00669 * contents, else set it to FALSE. Do the similar for @a *same23 00670 * with @a file2 and @a file3, and @a *same13 for @a file1 and @a 00671 * file3. The filenames @a file1, @a file2 and @a file3 are 00672 * utf8-encoded. Use @a scratch_pool for temporary allocations. 00673 * 00674 * @since New in 1.8. 00675 */ 00676 svn_error_t * 00677 svn_io_files_contents_three_same_p(svn_boolean_t *same12, 00678 svn_boolean_t *same23, 00679 svn_boolean_t *same13, 00680 const char *file1, 00681 const char *file2, 00682 const char *file3, 00683 apr_pool_t *scratch_pool); 00684 00685 /** Create a file at utf8-encoded path @a file with the contents given 00686 * by the null-terminated string @a contents. 00687 * 00688 * @a file must not already exist. If an error occurs while writing or 00689 * closing the file, attempt to delete the file before returning the error. 00690 * 00691 * Write the data in 'binary' mode (#APR_FOPEN_BINARY). If @a contents 00692 * is @c NULL, create an empty file. 00693 * 00694 * Use @a pool for memory allocations. 00695 */ 00696 svn_error_t * 00697 svn_io_file_create(const char *file, 00698 const char *contents, 00699 apr_pool_t *pool); 00700 00701 /** Create a file at utf8-encoded path @a file with the contents given 00702 * by @a contents of @a length bytes. 00703 * 00704 * @a file must not already exist. If an error occurs while writing or 00705 * closing the file, attempt to delete the file before returning the error. 00706 * 00707 * Write the data in 'binary' mode (#APR_FOPEN_BINARY). If @a length is 00708 * zero, create an empty file; in this case @a contents may be @c NULL. 00709 * 00710 * Use @a scratch_pool for temporary allocations. 00711 * 00712 * @since New in 1.9. 00713 */ 00714 svn_error_t * 00715 svn_io_file_create_bytes(const char *file, 00716 const void *contents, 00717 apr_size_t length, 00718 apr_pool_t *scratch_pool); 00719 00720 /** Create an empty file at utf8-encoded path @a file. 00721 * 00722 * @a file must not already exist. If an error occurs while 00723 * closing the file, attempt to delete the file before returning the error. 00724 * 00725 * Use @a scratch_pool for temporary allocations. 00726 * 00727 * @since New in 1.9. 00728 */ 00729 svn_error_t * 00730 svn_io_file_create_empty(const char *file, 00731 apr_pool_t *scratch_pool); 00732 00733 /** 00734 * Lock file at @a lock_file. If @a exclusive is TRUE, 00735 * obtain exclusive lock, otherwise obtain shared lock. 00736 * Lock will be automatically released when @a pool is cleared or destroyed. 00737 * Use @a pool for memory allocations. 00738 * 00739 * @deprecated Provided for backward compatibility with the 1.0 API. 00740 */ 00741 SVN_DEPRECATED 00742 svn_error_t * 00743 svn_io_file_lock(const char *lock_file, 00744 svn_boolean_t exclusive, 00745 apr_pool_t *pool); 00746 00747 /** 00748 * Lock file at @a lock_file. If @a exclusive is TRUE, 00749 * obtain exclusive lock, otherwise obtain shared lock. 00750 * 00751 * If @a nonblocking is TRUE, do not wait for the lock if it 00752 * is not available: throw an error instead. 00753 * 00754 * Lock will be automatically released when @a pool is cleared or destroyed. 00755 * Use @a pool for memory allocations. 00756 * 00757 * @since New in 1.1. 00758 */ 00759 svn_error_t * 00760 svn_io_file_lock2(const char *lock_file, 00761 svn_boolean_t exclusive, 00762 svn_boolean_t nonblocking, 00763 apr_pool_t *pool); 00764 00765 /** 00766 * Lock the file @a lockfile_handle. If @a exclusive is TRUE, 00767 * obtain exclusive lock, otherwise obtain shared lock. 00768 * 00769 * If @a nonblocking is TRUE, do not wait for the lock if it 00770 * is not available: throw an error instead. 00771 * 00772 * Lock will be automatically released when @a pool is cleared or destroyed. 00773 * You may also explicitly call svn_io_unlock_open_file(). 00774 * Use @a pool for memory allocations. @a pool must be the pool that 00775 * @a lockfile_handle has been created in or one of its sub-pools. 00776 * 00777 * @since New in 1.8. 00778 */ 00779 svn_error_t * 00780 svn_io_lock_open_file(apr_file_t *lockfile_handle, 00781 svn_boolean_t exclusive, 00782 svn_boolean_t nonblocking, 00783 apr_pool_t *pool); 00784 00785 /** 00786 * Unlock the file @a lockfile_handle. 00787 * 00788 * Use @a pool for memory allocations. @a pool must be the pool that 00789 * was passed to svn_io_lock_open_file(). 00790 * 00791 * @since New in 1.8. 00792 */ 00793 svn_error_t * 00794 svn_io_unlock_open_file(apr_file_t *lockfile_handle, 00795 apr_pool_t *pool); 00796 00797 /** 00798 * Flush any unwritten data from @a file to disk. Use @a pool for 00799 * memory allocations. 00800 * 00801 * @note This function uses advanced file control operations to flush buffers 00802 * to disk that aren't always accessible and can be very expensive on systems 00803 * that implement flushing on all IO layers, like Windows. Please avoid using 00804 * this function in cases where the file should just work on any network 00805 * filesystem. In many cases a normal svn_io_file_flush() will work just fine. 00806 * 00807 * @since New in 1.1. 00808 */ 00809 svn_error_t * 00810 svn_io_file_flush_to_disk(apr_file_t *file, 00811 apr_pool_t *pool); 00812 00813 /** Copy the file whose basename (or relative path) is @a file within 00814 * directory @a src_path to the same basename (or relative path) within 00815 * directory @a dest_path. Overwrite the destination file if it already 00816 * exists. The destination directory (including any directory 00817 * components in @a name) must already exist. Set the destination 00818 * file's permissions to match those of the source. Use @a pool for 00819 * memory allocations. 00820 */ 00821 svn_error_t * 00822 svn_io_dir_file_copy(const char *src_path, 00823 const char *dest_path, 00824 const char *file, 00825 apr_pool_t *pool); 00826 00827 00828 /** Generic byte-streams 00829 * 00830 * @defgroup svn_io_byte_streams Generic byte streams 00831 * @{ 00832 */ 00833 00834 /** An abstract stream of bytes--either incoming or outgoing or both. 00835 * 00836 * The creator of a stream sets functions to handle read and write. 00837 * Both of these handlers accept a baton whose value is determined at 00838 * stream creation time; this baton can point to a structure 00839 * containing data associated with the stream. If a caller attempts 00840 * to invoke a handler which has not been set, it will generate a 00841 * runtime assertion failure. The creator can also set a handler for 00842 * close requests so that it can flush buffered data or whatever; 00843 * if a close handler is not specified, a close request on the stream 00844 * will simply be ignored. Note that svn_stream_close() does not 00845 * deallocate the memory used to allocate the stream structure; free 00846 * the pool you created the stream in to free that memory. 00847 * 00848 * The read and write handlers accept length arguments via pointer. 00849 * On entry to the handler, the pointed-to value should be the amount 00850 * of data which can be read or the amount of data to write. When the 00851 * handler returns, the value is reset to the amount of data actually 00852 * read or written. The write and full read handler are obliged to 00853 * complete a read or write to the maximum extent possible; thus, a 00854 * short read with no associated error implies the end of the input 00855 * stream, and a short write should never occur without an associated 00856 * error. In Subversion 1.9 the stream api was extended to also support 00857 * limited reads via the new svn_stream_read2() api. 00858 * 00859 * In Subversion 1.7 mark, seek and reset support was added as an optional 00860 * feature of streams. If a stream implements resetting it allows reading 00861 * the data again after a successful call to svn_stream_reset(). 00862 */ 00863 typedef struct svn_stream_t svn_stream_t; 00864 00865 00866 00867 /** Read handler function for a generic stream. @see svn_stream_t. */ 00868 typedef svn_error_t *(*svn_read_fn_t)(void *baton, 00869 char *buffer, 00870 apr_size_t *len); 00871 00872 /** Skip data handler function for a generic stream. @see svn_stream_t 00873 * and svn_stream_skip(). 00874 * @since New in 1.7. 00875 */ 00876 typedef svn_error_t *(*svn_stream_skip_fn_t)(void *baton, 00877 apr_size_t len); 00878 00879 /** Write handler function for a generic stream. @see svn_stream_t. */ 00880 typedef svn_error_t *(*svn_write_fn_t)(void *baton, 00881 const char *data, 00882 apr_size_t *len); 00883 00884 /** Close handler function for a generic stream. @see svn_stream_t. */ 00885 typedef svn_error_t *(*svn_close_fn_t)(void *baton); 00886 00887 /** An opaque type which represents a mark on a stream. There is no 00888 * concrete definition of this type, it is a named type for stream 00889 * implementation specific baton pointers. 00890 * 00891 * @see svn_stream_mark(). 00892 * @since New in 1.7. 00893 */ 00894 typedef struct svn_stream_mark_t svn_stream_mark_t; 00895 00896 /** Mark handler function for a generic stream. @see svn_stream_t and 00897 * svn_stream_mark(). 00898 * 00899 * @since New in 1.7. 00900 */ 00901 typedef svn_error_t *(*svn_stream_mark_fn_t)(void *baton, 00902 svn_stream_mark_t **mark, 00903 apr_pool_t *pool); 00904 00905 /** Seek handler function for a generic stream. @see svn_stream_t and 00906 * svn_stream_seek(). 00907 * 00908 * @since New in 1.7. 00909 */ 00910 typedef svn_error_t *(*svn_stream_seek_fn_t)(void *baton, 00911 const svn_stream_mark_t *mark); 00912 00913 /** Poll handler for generic streams that support incomplete reads, @see 00914 * svn_stream_t and svn_stream_data_available(). 00915 * 00916 * @since New in 1.9. 00917 */ 00918 typedef svn_error_t *(*svn_stream_data_available_fn_t)(void *baton, 00919 svn_boolean_t *data_available); 00920 00921 /** Readline handler function for a generic stream. @see svn_stream_t and 00922 * svn_stream_readline(). 00923 * 00924 * @since New in 1.10. 00925 */ 00926 typedef svn_error_t *(*svn_stream_readline_fn_t)(void *baton, 00927 svn_stringbuf_t **stringbuf, 00928 const char *eol, 00929 svn_boolean_t *eof, 00930 apr_pool_t *pool); 00931 00932 /** Create a generic stream. @see svn_stream_t. */ 00933 svn_stream_t * 00934 svn_stream_create(void *baton, 00935 apr_pool_t *pool); 00936 00937 /** Set @a stream's baton to @a baton */ 00938 void 00939 svn_stream_set_baton(svn_stream_t *stream, 00940 void *baton); 00941 00942 /** Set @a stream's read functions to @a read_fn and @a read_full_fn. If 00943 * @a read_full_fn is NULL a default implementation based on multiple calls 00944 * to @a read_fn will be used. 00945 * 00946 * @since New in 1.9. 00947 */ 00948 void 00949 svn_stream_set_read2(svn_stream_t *stream, 00950 svn_read_fn_t read_fn, 00951 svn_read_fn_t read_full_fn); 00952 00953 /** Set @a stream's read function to @a read_fn. 00954 * 00955 * This function sets only the full read function to read_fn. 00956 * 00957 * @deprecated Provided for backward compatibility with the 1.8 API. 00958 */ 00959 SVN_DEPRECATED 00960 void 00961 svn_stream_set_read(svn_stream_t *stream, 00962 svn_read_fn_t read_fn); 00963 00964 /** Set @a stream's skip function to @a skip_fn 00965 * 00966 * @since New in 1.7 00967 */ 00968 void 00969 svn_stream_set_skip(svn_stream_t *stream, 00970 svn_stream_skip_fn_t skip_fn); 00971 00972 /** Set @a stream's write function to @a write_fn */ 00973 void 00974 svn_stream_set_write(svn_stream_t *stream, 00975 svn_write_fn_t write_fn); 00976 00977 /** Set @a stream's close function to @a close_fn */ 00978 void 00979 svn_stream_set_close(svn_stream_t *stream, 00980 svn_close_fn_t close_fn); 00981 00982 /** Set @a stream's mark function to @a mark_fn 00983 * 00984 * @since New in 1.7. 00985 */ 00986 void 00987 svn_stream_set_mark(svn_stream_t *stream, 00988 svn_stream_mark_fn_t mark_fn); 00989 00990 /** Set @a stream's seek function to @a seek_fn 00991 * 00992 * @since New in 1.7. 00993 */ 00994 void 00995 svn_stream_set_seek(svn_stream_t *stream, 00996 svn_stream_seek_fn_t seek_fn); 00997 00998 /** Set @a stream's data available function to @a data_available_fn 00999 * 01000 * @since New in 1.9. 01001 */ 01002 void 01003 svn_stream_set_data_available(svn_stream_t *stream, 01004 svn_stream_data_available_fn_t data_available); 01005 01006 /** Set @a stream's readline function to @a readline_fn 01007 * 01008 * @since New in 1.10. 01009 */ 01010 void 01011 svn_stream_set_readline(svn_stream_t *stream, 01012 svn_stream_readline_fn_t readline_fn); 01013 01014 /** Create a stream that is empty for reading and infinite for writing. */ 01015 svn_stream_t * 01016 svn_stream_empty(apr_pool_t *pool); 01017 01018 /** Return a stream allocated in @a pool which forwards all requests 01019 * to @a stream. Destruction is explicitly excluded from forwarding. 01020 * 01021 * @see http://subversion.apache.org/docs/community-guide/conventions.html#destruction-of-stacked-resources 01022 * 01023 * @since New in 1.4. 01024 */ 01025 svn_stream_t * 01026 svn_stream_disown(svn_stream_t *stream, 01027 apr_pool_t *pool); 01028 01029 01030 /** Create a stream to read the file at @a path. It will be opened using 01031 * the APR_BUFFERED and APR_BINARY flag, and APR_OS_DEFAULT for the perms. 01032 * If you'd like to use different values, then open the file yourself, and 01033 * use the svn_stream_from_aprfile2() interface. 01034 * 01035 * The stream will be returned in @a stream, and allocated from @a result_pool. 01036 * Temporary allocations will be performed in @a scratch_pool. 01037 * 01038 * @since New in 1.6 01039 */ 01040 svn_error_t * 01041 svn_stream_open_readonly(svn_stream_t **stream, 01042 const char *path, 01043 apr_pool_t *result_pool, 01044 apr_pool_t *scratch_pool); 01045 01046 01047 /** Create a stream to write a file at @a path. The file will be *created* 01048 * using the APR_BUFFERED and APR_BINARY flag, and APR_OS_DEFAULT for the 01049 * perms. The file will be created "exclusively", so if it already exists, 01050 * then an error will be thrown. If you'd like to use different values, or 01051 * open an existing file, then open the file yourself, and use the 01052 * svn_stream_from_aprfile2() interface. 01053 * 01054 * The stream will be returned in @a stream, and allocated from @a result_pool. 01055 * Temporary allocations will be performed in @a scratch_pool. 01056 * 01057 * @since New in 1.6 01058 */ 01059 svn_error_t * 01060 svn_stream_open_writable(svn_stream_t **stream, 01061 const char *path, 01062 apr_pool_t *result_pool, 01063 apr_pool_t *scratch_pool); 01064 01065 01066 /** Create a writable stream to a file in the directory @a dirpath. 01067 * The file will have an arbitrary and unique name, and the full path 01068 * will be returned in @a temp_path. The stream will be returned in 01069 * @a stream. Both will be allocated from @a result_pool. 01070 * 01071 * If @a dirpath is @c NULL, use the path returned from svn_io_temp_dir(). 01072 * (Note that when using the system-provided temp directory, it may not 01073 * be possible to atomically rename the resulting file due to cross-device 01074 * issues.) 01075 * 01076 * The file will be deleted according to @a delete_when. If that is 01077 * #svn_io_file_del_on_pool_cleanup, it refers to @a result_pool. 01078 * 01079 * Temporary allocations will be performed in @a scratch_pool. 01080 * 01081 * @since New in 1.6 01082 * @see svn_io_open_unique_file3() 01083 */ 01084 svn_error_t * 01085 svn_stream_open_unique(svn_stream_t **stream, 01086 const char **temp_path, 01087 const char *dirpath, 01088 svn_io_file_del_t delete_when, 01089 apr_pool_t *result_pool, 01090 apr_pool_t *scratch_pool); 01091 01092 01093 /** Create a stream from an APR file. For convenience, if @a file is 01094 * @c NULL, an empty stream created by svn_stream_empty() is returned. 01095 * 01096 * This function should normally be called with @a disown set to FALSE, 01097 * in which case closing the stream will also close the underlying file. 01098 * 01099 * If @a disown is TRUE, the stream will disown the underlying file, 01100 * meaning that svn_stream_close() will not close the file. 01101 * 01102 * @since New in 1.4. 01103 */ 01104 svn_stream_t * 01105 svn_stream_from_aprfile2(apr_file_t *file, 01106 svn_boolean_t disown, 01107 apr_pool_t *pool); 01108 01109 /** Similar to svn_stream_from_aprfile2(), except that the file will 01110 * always be disowned. 01111 * 01112 * @note The stream returned is not considered to "own" the underlying 01113 * file, meaning that svn_stream_close() on the stream will not 01114 * close the file. 01115 * 01116 * @deprecated Provided for backward compatibility with the 1.3 API. 01117 */ 01118 SVN_DEPRECATED 01119 svn_stream_t * 01120 svn_stream_from_aprfile(apr_file_t *file, 01121 apr_pool_t *pool); 01122 01123 /** Set @a *in to a generic stream connected to stdin, allocated in 01124 * @a pool. If @a buffered is set, APR buffering will be enabled. 01125 * The stream and its underlying APR handle will be closed when @a pool 01126 * is cleared or destroyed. 01127 * 01128 * @note APR buffering will try to fill the whole internal buffer before 01129 * serving read requests. This may be inappropriate for interactive 01130 * applications where stdin will not deliver any more data unless 01131 * the application processed the data already received. 01132 * 01133 * @since New in 1.10. 01134 */ 01135 svn_error_t * 01136 svn_stream_for_stdin2(svn_stream_t **in, 01137 svn_boolean_t buffered, 01138 apr_pool_t *pool); 01139 01140 /** Similar to svn_stream_for_stdin2(), but with buffering being disabled. 01141 * 01142 * @since New in 1.7. 01143 * 01144 * @deprecated Provided for backward compatibility with the 1.9 API. 01145 */ 01146 SVN_DEPRECATED 01147 svn_error_t * 01148 svn_stream_for_stdin(svn_stream_t **in, 01149 apr_pool_t *pool); 01150 01151 /** Set @a *err to a generic stream connected to stderr, allocated in 01152 * @a pool. The stream and its underlying APR handle will be closed 01153 * when @a pool is cleared or destroyed. 01154 * 01155 * @since New in 1.7. 01156 */ 01157 svn_error_t * 01158 svn_stream_for_stderr(svn_stream_t **err, 01159 apr_pool_t *pool); 01160 01161 /** Set @a *out to a generic stream connected to stdout, allocated in 01162 * @a pool. The stream and its underlying APR handle will be closed 01163 * when @a pool is cleared or destroyed. 01164 */ 01165 svn_error_t * 01166 svn_stream_for_stdout(svn_stream_t **out, 01167 apr_pool_t *pool); 01168 01169 /** Read the contents of @a stream into memory, from its current position 01170 * to its end, returning the data in @a *result. This function does not 01171 * close the @a stream upon completion. 01172 * 01173 * @a len_hint gives a hint about the expected length, in bytes, of the 01174 * actual data that will be read from the stream. It may be 0, meaning no 01175 * hint is being provided. Efficiency in time and/or in space may be 01176 * better (and in general will not be worse) when the actual data length 01177 * is equal or approximately equal to the length hint. 01178 * 01179 * The returned memory is allocated in @a result_pool. 01180 * 01181 * @note The present implementation is efficient when @a len_hint is big 01182 * enough (but not vastly bigger than necessary), and also for actual 01183 * lengths up to 64 bytes when @a len_hint is 0. Otherwise it can incur 01184 * significant time and space overheads. See source code for details. 01185 * 01186 * @since New in 1.9. 01187 */ 01188 svn_error_t * 01189 svn_stringbuf_from_stream(svn_stringbuf_t **result, 01190 svn_stream_t *stream, 01191 apr_size_t len_hint, 01192 apr_pool_t *result_pool); 01193 01194 /** Return a generic stream connected to stringbuf @a str. Allocate the 01195 * stream in @a pool. 01196 */ 01197 svn_stream_t * 01198 svn_stream_from_stringbuf(svn_stringbuf_t *str, 01199 apr_pool_t *pool); 01200 01201 /** Return a generic read-only stream connected to string @a str. 01202 * Allocate the stream in @a pool. 01203 */ 01204 svn_stream_t * 01205 svn_stream_from_string(const svn_string_t *str, 01206 apr_pool_t *pool); 01207 01208 /** Return a generic stream which implements buffered reads and writes. 01209 * The stream will preferentially store data in-memory, but may use 01210 * disk storage as backup if the amount of data is large. 01211 * Allocate the stream in @a result_pool 01212 * 01213 * @since New in 1.8. 01214 */ 01215 svn_stream_t * 01216 svn_stream_buffered(apr_pool_t *result_pool); 01217 01218 /** Return a stream that decompresses all data read and compresses all 01219 * data written. The stream @a stream is used to read and write all 01220 * compressed data. All compression data structures are allocated on 01221 * @a pool. If compression support is not compiled in then 01222 * svn_stream_compressed() returns @a stream unmodified. Make sure you 01223 * call svn_stream_close() on the stream returned by this function, 01224 * so that all data are flushed and cleaned up. 01225 * 01226 * @note From 1.4, compression support is always compiled in. 01227 */ 01228 svn_stream_t * 01229 svn_stream_compressed(svn_stream_t *stream, 01230 apr_pool_t *pool); 01231 01232 /** Return a stream that calculates checksums for all data read 01233 * and written. The stream @a stream is used to read and write all data. 01234 * The stream and the resulting digests are allocated in @a pool. 01235 * 01236 * When the stream is closed, @a *read_checksum and @a *write_checksum 01237 * are set to point to the resulting checksums, of type @a read_checksum_kind 01238 * and @a write_checksum_kind, respectively. 01239 * 01240 * Both @a read_checksum and @a write_checksum can be @c NULL, in which case 01241 * the respective checksum isn't calculated. 01242 * 01243 * If @a read_all is TRUE, make sure that all data available on @a 01244 * stream is read (and checksummed) when the stream is closed. 01245 * 01246 * Read and write operations can be mixed without interfering. 01247 * 01248 * The @a stream passed into this function is closed when the created 01249 * stream is closed. 01250 * 01251 * @since New in 1.6. Since 1.10, the resulting stream supports reset 01252 * via stream_stream_reset(). 01253 */ 01254 svn_stream_t * 01255 svn_stream_checksummed2(svn_stream_t *stream, 01256 svn_checksum_t **read_checksum, 01257 svn_checksum_t **write_checksum, 01258 svn_checksum_kind_t checksum_kind, 01259 svn_boolean_t read_all, 01260 apr_pool_t *pool); 01261 01262 /** 01263 * Similar to svn_stream_checksummed2(), but always returning the MD5 01264 * checksum in @a read_digest and @a write_digest. 01265 * 01266 * @since New in 1.4. 01267 * @deprecated Provided for backward compatibility with the 1.5 API. 01268 */ 01269 SVN_DEPRECATED 01270 svn_stream_t * 01271 svn_stream_checksummed(svn_stream_t *stream, 01272 const unsigned char **read_digest, 01273 const unsigned char **write_digest, 01274 svn_boolean_t read_all, 01275 apr_pool_t *pool); 01276 01277 /** Read the contents of the readable stream @a stream and return its 01278 * checksum of type @a kind in @a *checksum. 01279 * 01280 * The stream will be closed before this function returns (regardless 01281 * of the result, or any possible error). 01282 * 01283 * Use @a scratch_pool for temporary allocations and @a result_pool 01284 * to allocate @a *checksum. 01285 * 01286 * @since New in 1.10. 01287 */ 01288 svn_error_t * 01289 svn_stream_contents_checksum(svn_checksum_t **checksum, 01290 svn_stream_t *stream, 01291 svn_checksum_kind_t kind, 01292 apr_pool_t *result_pool, 01293 apr_pool_t *scratch_pool); 01294 01295 /** Read from a generic stream until @a buffer is filled upto @a *len or 01296 * until EOF is reached. @see svn_stream_t 01297 * 01298 * @since New in 1.9. 01299 */ 01300 svn_error_t * 01301 svn_stream_read_full(svn_stream_t *stream, 01302 char *buffer, 01303 apr_size_t *len); 01304 01305 01306 /** Returns @c TRUE if the generic @c stream supports svn_stream_read2(). 01307 * 01308 * @since New in 1.9. 01309 */ 01310 svn_boolean_t 01311 svn_stream_supports_partial_read(svn_stream_t *stream); 01312 01313 /** Read all currently available upto @a *len into @a buffer. Use 01314 * svn_stream_read_full() if you want to wait for the buffer to be filled 01315 * or EOF. If the stream doesn't support limited reads this function will 01316 * return an #SVN_ERR_STREAM_NOT_SUPPORTED error. 01317 * 01318 * A 0 byte read signals the end of the stream. 01319 * 01320 * @since New in 1.9. 01321 */ 01322 svn_error_t * 01323 svn_stream_read2(svn_stream_t *stream, 01324 char *buffer, 01325 apr_size_t *len); 01326 01327 01328 /** Read from a generic stream until the buffer is completely filled or EOF. 01329 * @see svn_stream_t. 01330 * 01331 * @note This function is a wrapper of svn_stream_read_full() now, which name 01332 * better documents the behavior of this function. 01333 * 01334 * @deprecated Provided for backward compatibility with the 1.8 API 01335 */ 01336 SVN_DEPRECATED 01337 svn_error_t * 01338 svn_stream_read(svn_stream_t *stream, 01339 char *buffer, 01340 apr_size_t *len); 01341 01342 /** 01343 * Skip @a len bytes from a generic @a stream. If the stream is exhausted 01344 * before @a len bytes have been read, return an error. 01345 * 01346 * @note No assumption can be made on the semantics of this function 01347 * other than that the stream read pointer will be advanced by *len 01348 * bytes. Depending on the capabilities of the underlying stream 01349 * implementation, this may for instance be translated into a sequence 01350 * of reads or a simple seek operation. If the stream implementation has 01351 * not provided a skip function, this will read from the stream and 01352 * discard the data. 01353 * 01354 * @since New in 1.7. 01355 */ 01356 svn_error_t * 01357 svn_stream_skip(svn_stream_t *stream, 01358 apr_size_t len); 01359 01360 /** Write to a generic stream. @see svn_stream_t. */ 01361 svn_error_t * 01362 svn_stream_write(svn_stream_t *stream, 01363 const char *data, 01364 apr_size_t *len); 01365 01366 /** Close a generic stream. @see svn_stream_t. */ 01367 svn_error_t * 01368 svn_stream_close(svn_stream_t *stream); 01369 01370 /** Reset a generic stream back to its origin. (E.g. On a file this would be 01371 * implemented as a seek to position 0). This function returns a 01372 * #SVN_ERR_STREAM_SEEK_NOT_SUPPORTED error when the stream doesn't 01373 * implement resetting. 01374 * 01375 * @since New in 1.7. 01376 */ 01377 svn_error_t * 01378 svn_stream_reset(svn_stream_t *stream); 01379 01380 /** Returns @c TRUE if the generic @a stream supports svn_stream_mark(). 01381 * 01382 * @see svn_stream_mark() 01383 * @since New in 1.7. 01384 */ 01385 svn_boolean_t 01386 svn_stream_supports_mark(svn_stream_t *stream); 01387 01388 /** Returns @c TRUE if the generic @a stream supports svn_stream_reset(). 01389 * 01390 * @see svn_stream_reset() 01391 * @since New in 1.10. 01392 */ 01393 svn_boolean_t 01394 svn_stream_supports_reset(svn_stream_t *stream); 01395 01396 /** Set a @a mark at the current position of a generic @a stream, 01397 * which can later be sought back to using svn_stream_seek(). 01398 * The @a mark is allocated in @a pool. 01399 * 01400 * This function returns the #SVN_ERR_STREAM_SEEK_NOT_SUPPORTED error 01401 * if the stream doesn't implement seeking. 01402 * 01403 * @see svn_stream_seek() 01404 * @since New in 1.7. 01405 */ 01406 svn_error_t * 01407 svn_stream_mark(svn_stream_t *stream, 01408 svn_stream_mark_t **mark, 01409 apr_pool_t *pool); 01410 01411 /** Seek to a @a mark in a generic @a stream. 01412 * This function returns the #SVN_ERR_STREAM_SEEK_NOT_SUPPORTED error 01413 * if the stream doesn't implement seeking. Passing NULL as @a mark, 01414 * seeks to the start of the stream. 01415 * 01416 * @see svn_stream_mark() 01417 * @since New in 1.7. 01418 */ 01419 svn_error_t * 01420 svn_stream_seek(svn_stream_t *stream, const svn_stream_mark_t *mark); 01421 01422 /** When a stream supports polling for available data, obtain a boolean 01423 * indicating whether data is waiting to be read. If the stream doesn't 01424 * support polling this function returns a #SVN_ERR_STREAM_NOT_SUPPORTED 01425 * error. 01426 * 01427 * If the data_available callback is implemented and the stream is at the end 01428 * the stream will set @a *data_available to FALSE. 01429 * 01430 * @since New in 1.9. 01431 */ 01432 svn_error_t * 01433 svn_stream_data_available(svn_stream_t *stream, 01434 svn_boolean_t *data_available); 01435 01436 /** Return a writable stream which, when written to, writes to both of the 01437 * underlying streams. Both of these streams will be closed upon closure of 01438 * the returned stream; use svn_stream_disown() if this is not the desired 01439 * behavior. One or both of @a out1 and @a out2 may be @c NULL. If both are 01440 * @c NULL, @c NULL is returned. 01441 * 01442 * @since New in 1.7. 01443 */ 01444 svn_stream_t * 01445 svn_stream_tee(svn_stream_t *out1, 01446 svn_stream_t *out2, 01447 apr_pool_t *pool); 01448 01449 /** Write NULL-terminated string @a str to @a stream. 01450 * 01451 * @since New in 1.8. 01452 * 01453 */ 01454 svn_error_t * 01455 svn_stream_puts(svn_stream_t *stream, 01456 const char *str); 01457 01458 /** Write to @a stream using a printf-style @a fmt specifier, passed through 01459 * apr_psprintf() using memory from @a pool. 01460 */ 01461 svn_error_t * 01462 svn_stream_printf(svn_stream_t *stream, 01463 apr_pool_t *pool, 01464 const char *fmt, 01465 ...) 01466 __attribute__((format(printf, 3, 4))); 01467 01468 /** Write to @a stream using a printf-style @a fmt specifier, passed through 01469 * apr_psprintf() using memory from @a pool. The resulting string 01470 * will be translated to @a encoding before it is sent to @a stream. 01471 * 01472 * @note Use @c APR_LOCALE_CHARSET to translate to the encoding of the 01473 * current locale. 01474 * 01475 * @since New in 1.3. 01476 */ 01477 svn_error_t * 01478 svn_stream_printf_from_utf8(svn_stream_t *stream, 01479 const char *encoding, 01480 apr_pool_t *pool, 01481 const char *fmt, 01482 ...) 01483 __attribute__((format(printf, 4, 5))); 01484 01485 /** Allocate @a *stringbuf in @a pool, and read into it one line (terminated 01486 * by @a eol) from @a stream. The line-terminator is read from the stream, 01487 * but is not added to the end of the stringbuf. Instead, the stringbuf 01488 * ends with a usual '\\0'. 01489 * 01490 * If @a stream runs out of bytes before encountering a line-terminator, 01491 * then set @a *eof to @c TRUE, otherwise set @a *eof to FALSE. 01492 */ 01493 svn_error_t * 01494 svn_stream_readline(svn_stream_t *stream, 01495 svn_stringbuf_t **stringbuf, 01496 const char *eol, 01497 svn_boolean_t *eof, 01498 apr_pool_t *pool); 01499 01500 /** 01501 * Read the contents of the readable stream @a from and write them to the 01502 * writable stream @a to calling @a cancel_func before copying each chunk. 01503 * 01504 * @a cancel_func may be @c NULL. 01505 * 01506 * @note both @a from and @a to will be closed upon successful completion of 01507 * the copy (but an error may still be returned, based on trying to close 01508 * the two streams). If the closure is not desired, then you can use 01509 * svn_stream_disown() to protect either or both of the streams from 01510 * being closed. 01511 * 01512 * @since New in 1.6. 01513 */ 01514 svn_error_t * 01515 svn_stream_copy3(svn_stream_t *from, 01516 svn_stream_t *to, 01517 svn_cancel_func_t cancel_func, 01518 void *cancel_baton, 01519 apr_pool_t *pool); 01520 01521 /** 01522 * Same as svn_stream_copy3() but the streams are not closed. 01523 * 01524 * @since New in 1.5. 01525 * @deprecated Provided for backward compatibility with the 1.5 API. 01526 */ 01527 SVN_DEPRECATED 01528 svn_error_t * 01529 svn_stream_copy2(svn_stream_t *from, 01530 svn_stream_t *to, 01531 svn_cancel_func_t cancel_func, 01532 void *cancel_baton, 01533 apr_pool_t *pool); 01534 01535 /** 01536 * Same as svn_stream_copy3(), but without the cancellation function 01537 * or stream closing. 01538 * 01539 * @since New in 1.1. 01540 * @deprecated Provided for backward compatibility with the 1.4 API. 01541 */ 01542 SVN_DEPRECATED 01543 svn_error_t * 01544 svn_stream_copy(svn_stream_t *from, 01545 svn_stream_t *to, 01546 apr_pool_t *pool); 01547 01548 01549 /** Set @a *same to TRUE if @a stream1 and @a stream2 have the same 01550 * contents, else set it to FALSE. 01551 * 01552 * Both streams will be closed before this function returns (regardless of 01553 * the result, or any possible error). 01554 * 01555 * Use @a scratch_pool for temporary allocations. 01556 * 01557 * @since New in 1.7. 01558 */ 01559 svn_error_t * 01560 svn_stream_contents_same2(svn_boolean_t *same, 01561 svn_stream_t *stream1, 01562 svn_stream_t *stream2, 01563 apr_pool_t *pool); 01564 01565 01566 /** 01567 * Same as svn_stream_contents_same2(), but the streams will not be closed. 01568 * 01569 * @since New in 1.4. 01570 * @deprecated Provided for backward compatibility with the 1.6 API. 01571 */ 01572 SVN_DEPRECATED 01573 svn_error_t * 01574 svn_stream_contents_same(svn_boolean_t *same, 01575 svn_stream_t *stream1, 01576 svn_stream_t *stream2, 01577 apr_pool_t *pool); 01578 01579 01580 /** Read the contents of @a stream into memory, from its current position 01581 * to its end, returning the data in @a *result. The stream will be closed 01582 * when it has been successfully and completely read. 01583 * 01584 * @a len_hint gives a hint about the expected length, in bytes, of the 01585 * actual data that will be read from the stream. It may be 0, meaning no 01586 * hint is being provided. Efficiency in time and/or in space may be 01587 * better (and in general will not be worse) when the actual data length 01588 * is equal or approximately equal to the length hint. 01589 * 01590 * The returned memory is allocated in @a result_pool, and any temporary 01591 * allocations may be performed in @a scratch_pool. 01592 * 01593 * @note The present implementation is efficient when @a len_hint is big 01594 * enough (but not vastly bigger than necessary), and also for actual 01595 * lengths up to 64 bytes when @a len_hint is 0. Otherwise it can incur 01596 * significant time and space overheads. See source code for details. 01597 * 01598 * @since New in 1.10 01599 */ 01600 svn_error_t * 01601 svn_string_from_stream2(svn_string_t **result, 01602 svn_stream_t *stream, 01603 apr_size_t len_hint, 01604 apr_pool_t *result_pool); 01605 01606 /** Similar to svn_string_from_stream2(), but always passes 0 for 01607 * @a len_hint. 01608 * 01609 * @deprecated Provided for backwards compatibility with the 1.9 API. 01610 */ 01611 SVN_DEPRECATED 01612 svn_error_t * 01613 svn_string_from_stream(svn_string_t **result, 01614 svn_stream_t *stream, 01615 apr_pool_t *result_pool, 01616 apr_pool_t *scratch_pool); 01617 01618 /** A function type provided for use as a callback from 01619 * @c svn_stream_lazyopen_create(). 01620 * 01621 * The callback function shall open a new stream and set @a *stream to 01622 * the stream object, allocated in @a result_pool. @a baton is the 01623 * callback baton that was passed to svn_stream_lazyopen_create(). 01624 * 01625 * @a result_pool is the result pool that was passed to 01626 * svn_stream_lazyopen_create(). The callback function may use 01627 * @a scratch_pool for temporary allocations; the caller may clear or 01628 * destroy @a scratch_pool any time after the function returns. 01629 * 01630 * @since New in 1.8. 01631 */ 01632 typedef svn_error_t * 01633 (*svn_stream_lazyopen_func_t)(svn_stream_t **stream, 01634 void *baton, 01635 apr_pool_t *result_pool, 01636 apr_pool_t *scratch_pool); 01637 01638 01639 /** Return a generic stream which wraps another primary stream, 01640 * delaying the "opening" of that stream until the first time the 01641 * returned stream is accessed. 01642 * 01643 * @a open_func and @a open_baton are a callback function/baton pair 01644 * which will be invoked upon the first access of the returned 01645 * stream (read, write, mark, seek, skip, or possibly close). The 01646 * callback shall open the primary stream. 01647 * 01648 * If the only "access" the returned stream gets is to close it 01649 * then @a open_func will only be called if @a open_on_close is TRUE. 01650 * 01651 * Allocate the returned stream in @a result_pool. Also arrange for 01652 * @a result_pool to be passed as the @c result_pool parameter to 01653 * @a open_func when it is called. 01654 * 01655 * @since New in 1.8. 01656 */ 01657 svn_stream_t * 01658 svn_stream_lazyopen_create(svn_stream_lazyopen_func_t open_func, 01659 void *open_baton, 01660 svn_boolean_t open_on_close, 01661 apr_pool_t *result_pool); 01662 01663 /** @} */ 01664 01665 /** Set @a *result to a string containing the contents of @a 01666 * filename, which is either "-" (indicating that stdin should be 01667 * read) or the utf8-encoded path of a real file. 01668 * 01669 * @warning Callers should be aware of possible unexpected results 01670 * when using this function to read from stdin where additional 01671 * stdin-reading processes abound. For example, if a program tries 01672 * both to invoke an external editor and to read from stdin, stdin 01673 * could be trashed and the editor might act funky or die outright. 01674 * 01675 * @note due to memory pseudo-reallocation behavior (due to pools), this 01676 * can be a memory-intensive operation for large files. 01677 * 01678 * @since New in 1.5. 01679 */ 01680 svn_error_t * 01681 svn_stringbuf_from_file2(svn_stringbuf_t **result, 01682 const char *filename, 01683 apr_pool_t *pool); 01684 01685 /** Similar to svn_stringbuf_from_file2(), except that if @a filename 01686 * is "-", return the error #SVN_ERR_UNSUPPORTED_FEATURE and don't 01687 * touch @a *result. 01688 * 01689 * @deprecated Provided for backwards compatibility with the 1.4 API. 01690 */ 01691 SVN_DEPRECATED 01692 svn_error_t * 01693 svn_stringbuf_from_file(svn_stringbuf_t **result, 01694 const char *filename, 01695 apr_pool_t *pool); 01696 01697 /** Sets @a *result to a string containing the contents of the already opened 01698 * @a file. Reads from the current position in file to the end. Does not 01699 * close the file or reset the cursor position. 01700 * 01701 * @note due to memory pseudo-reallocation behavior (due to pools), this 01702 * can be a memory-intensive operation for large files. 01703 */ 01704 svn_error_t * 01705 svn_stringbuf_from_aprfile(svn_stringbuf_t **result, 01706 apr_file_t *file, 01707 apr_pool_t *pool); 01708 01709 /** Remove file @a path, a utf8-encoded path. This wraps apr_file_remove(), 01710 * converting any error to a Subversion error. If @a ignore_enoent is TRUE, and 01711 * the file is not present (APR_STATUS_IS_ENOENT returns TRUE), then no 01712 * error will be returned. 01713 * 01714 * The file will be removed even if it is not writable. (On Windows and 01715 * OS/2, this function first clears the file's read-only bit.) 01716 * 01717 * @since New in 1.7. 01718 */ 01719 svn_error_t * 01720 svn_io_remove_file2(const char *path, 01721 svn_boolean_t ignore_enoent, 01722 apr_pool_t *scratch_pool); 01723 01724 /** Similar to svn_io_remove_file2(), except with @a ignore_enoent set to FALSE. 01725 * 01726 * @deprecated Provided for backwards compatibility with the 1.6 API. 01727 */ 01728 SVN_DEPRECATED 01729 svn_error_t * 01730 svn_io_remove_file(const char *path, 01731 apr_pool_t *pool); 01732 01733 /** Recursively remove directory @a path. @a path is utf8-encoded. 01734 * If @a ignore_enoent is @c TRUE, don't fail if the target directory 01735 * doesn't exist. Use @a pool for temporary allocations. 01736 * 01737 * Because recursive delete of a directory tree can be a lengthy operation, 01738 * provide @a cancel_func and @a cancel_baton for interruptibility. 01739 * 01740 * @since New in 1.5. 01741 */ 01742 svn_error_t * 01743 svn_io_remove_dir2(const char *path, 01744 svn_boolean_t ignore_enoent, 01745 svn_cancel_func_t cancel_func, 01746 void *cancel_baton, 01747 apr_pool_t *pool); 01748 01749 /** Similar to svn_io_remove_dir2(), but with @a ignore_enoent set to 01750 * @c FALSE and @a cancel_func and @a cancel_baton set to @c NULL. 01751 * 01752 * @deprecated Provided for backward compatibility with the 1.4 API 01753 */ 01754 SVN_DEPRECATED 01755 svn_error_t * 01756 svn_io_remove_dir(const char *path, 01757 apr_pool_t *pool); 01758 01759 /** Read all of the disk entries in directory @a path, a utf8-encoded 01760 * path. Set @a *dirents to a hash mapping dirent names (<tt>char *</tt>) to 01761 * undefined non-NULL values, allocated in @a pool. 01762 * 01763 * @note The `.' and `..' directories normally returned by 01764 * apr_dir_read() are NOT returned in the hash. 01765 * 01766 * @since New in 1.4. 01767 * @deprecated Provided for backward compatibility with the 1.6 API. 01768 */ 01769 SVN_DEPRECATED 01770 svn_error_t * 01771 svn_io_get_dir_filenames(apr_hash_t **dirents, 01772 const char *path, 01773 apr_pool_t *pool); 01774 01775 /** Read all of the disk entries in directory @a path, a utf8-encoded 01776 * path. Set @a *dirents to a hash mapping dirent names (<tt>char *</tt>) to 01777 * #svn_io_dirent2_t structures, allocated in @a pool. 01778 * 01779 * If @a only_check_type is set to @c TRUE, only the kind and special 01780 * fields of the svn_io_dirent2_t are filled. 01781 * 01782 * @note The `.' and `..' directories normally returned by 01783 * apr_dir_read() are NOT returned in the hash. 01784 * 01785 * @note The kind field in the @a dirents is set according to the mapping 01786 * as documented for svn_io_check_path(). 01787 * 01788 * @since New in 1.7. 01789 */ 01790 svn_error_t * 01791 svn_io_get_dirents3(apr_hash_t **dirents, 01792 const char *path, 01793 svn_boolean_t only_check_type, 01794 apr_pool_t *result_pool, 01795 apr_pool_t *scratch_pool); 01796 01797 01798 /** Similar to svn_io_get_dirents3, but returns a mapping to svn_io_dirent_t 01799 * structures instead of svn_io_dirent2_t and with only a single pool. 01800 * 01801 * @since New in 1.3. 01802 * @deprecated Provided for backward compatibility with the 1.6 API. 01803 */ 01804 SVN_DEPRECATED 01805 svn_error_t * 01806 svn_io_get_dirents2(apr_hash_t **dirents, 01807 const char *path, 01808 apr_pool_t *pool); 01809 01810 /** Similar to svn_io_get_dirents2(), but @a *dirents is a hash table 01811 * with #svn_node_kind_t values. 01812 * 01813 * @deprecated Provided for backwards compatibility with the 1.2 API. 01814 */ 01815 SVN_DEPRECATED 01816 svn_error_t * 01817 svn_io_get_dirents(apr_hash_t **dirents, 01818 const char *path, 01819 apr_pool_t *pool); 01820 01821 /** Create a svn_io_dirent2_t instance for path. Specialized variant of 01822 * svn_io_stat() that directly translates node_kind and special. 01823 * 01824 * If @a verify_truename is @c TRUE, an additional check is performed to 01825 * verify the truename of the last path component on case insensitive 01826 * filesystems. This check is expensive compared to a just a stat, 01827 * but certainly cheaper than a full truename calculation using 01828 * apr_filepath_merge() which verifies all path components. 01829 * 01830 * If @a ignore_enoent is set to @c TRUE, set *dirent_p->kind to 01831 * svn_node_none instead of returning an error. 01832 * 01833 * @since New in 1.8. 01834 */ 01835 svn_error_t * 01836 svn_io_stat_dirent2(const svn_io_dirent2_t **dirent_p, 01837 const char *path, 01838 svn_boolean_t verify_truename, 01839 svn_boolean_t ignore_enoent, 01840 apr_pool_t *result_pool, 01841 apr_pool_t *scratch_pool); 01842 01843 01844 /** Similar to svn_io_stat_dirent2(), but always passes FALSE for 01845 * @a verify_truename. 01846 * 01847 * @since New in 1.7. 01848 * @deprecated Provided for backwards compatibility with the 1.7 API. 01849 */ 01850 SVN_DEPRECATED 01851 svn_error_t * 01852 svn_io_stat_dirent(const svn_io_dirent2_t **dirent_p, 01853 const char *path, 01854 svn_boolean_t ignore_enoent, 01855 apr_pool_t *result_pool, 01856 apr_pool_t *scratch_pool); 01857 01858 01859 /** Callback function type for svn_io_dir_walk() */ 01860 typedef svn_error_t * (*svn_io_walk_func_t)(void *baton, 01861 const char *path, 01862 const apr_finfo_t *finfo, 01863 apr_pool_t *pool); 01864 01865 /** Recursively walk the directory rooted at @a dirname, a 01866 * utf8-encoded path, invoking @a walk_func (with @a walk_baton) for 01867 * each item in the tree. For a given directory, invoke @a walk_func 01868 * on the directory itself before invoking it on any children thereof. 01869 * 01870 * Deliver to @a walk_func the information specified by @a wanted, 01871 * which is a combination of @c APR_FINFO_* flags, plus the 01872 * information specified by @c APR_FINFO_TYPE and @c APR_FINFO_NAME. 01873 * 01874 * Use @a pool for all allocations. 01875 * 01876 * @note This function does not currently pass all file types to @a 01877 * walk_func -- only APR_DIR, APR_REG, and APR_LNK. We reserve the 01878 * right to pass additional file types through this interface in the 01879 * future, though, so implementations of this callback should 01880 * explicitly test FINFO->filetype. See the APR library's 01881 * apr_filetype_e enum for the various filetypes and their meanings. 01882 * 01883 * @since New in 1.7. 01884 */ 01885 svn_error_t * 01886 svn_io_dir_walk2(const char *dirname, 01887 apr_int32_t wanted, 01888 svn_io_walk_func_t walk_func, 01889 void *walk_baton, 01890 apr_pool_t *pool); 01891 01892 /** Similar to svn_io_dir_walk(), but only calls @a walk_func for 01893 * files of type APR_DIR (directory) and APR_REG (regular file). 01894 * 01895 * @deprecated Provided for backwards compatibility with the 1.6 API. 01896 */ 01897 SVN_DEPRECATED 01898 svn_error_t * 01899 svn_io_dir_walk(const char *dirname, 01900 apr_int32_t wanted, 01901 svn_io_walk_func_t walk_func, 01902 void *walk_baton, 01903 apr_pool_t *pool); 01904 01905 /** 01906 * Start @a cmd with @a args, using utf8-encoded @a path as working 01907 * directory. Return the process handle for the invoked program in @a 01908 * *cmd_proc. 01909 * 01910 * If @a infile_pipe is TRUE, connect @a cmd's stdin to a pipe; 01911 * otherwise, connect it to @a infile (which may be NULL). If 01912 * @a outfile_pipe is TRUE, connect @a cmd's stdout to a pipe; otherwise, 01913 * connect it to @a outfile (which may be NULL). If @a errfile_pipe 01914 * is TRUE, connect @a cmd's stderr to a pipe; otherwise, connect it 01915 * to @a errfile (which may be NULL). (Callers must pass FALSE for 01916 * each of these boolean values for which the corresponding file 01917 * handle is non-NULL.) 01918 * 01919 * @a args is a list of utf8-encoded <tt>const char *</tt> arguments, 01920 * terminated by @c NULL. @a args[0] is the name of the program, though it 01921 * need not be the same as @a cmd. 01922 * 01923 * If @a inherit is TRUE, the invoked program inherits its environment from 01924 * the caller and @a cmd, if not absolute, is searched for in PATH. 01925 * 01926 * If @a inherit is FALSE @a cmd must be an absolute path and the invoked 01927 * program inherits the environment defined by @a env or runs with an empty 01928 * environment in @a env is NULL. 01929 * 01930 * @note On some platforms, failure to execute @a cmd in the child process 01931 * will result in error output being written to @a errfile, if non-NULL, and 01932 * a non-zero exit status being returned to the parent process. 01933 * 01934 * @note An APR bug affects Windows: passing a NULL @a env does not 01935 * guarantee the invoked program to run with an empty environment when 01936 * @a inherit is FALSE, the program may inherit its parent's environment. 01937 * Explicitly pass an empty @a env to get an empty environment. 01938 * 01939 * @since New in 1.8. 01940 */ 01941 svn_error_t *svn_io_start_cmd3(apr_proc_t *cmd_proc, 01942 const char *path, 01943 const char *cmd, 01944 const char *const *args, 01945 const char *const *env, 01946 svn_boolean_t inherit, 01947 svn_boolean_t infile_pipe, 01948 apr_file_t *infile, 01949 svn_boolean_t outfile_pipe, 01950 apr_file_t *outfile, 01951 svn_boolean_t errfile_pipe, 01952 apr_file_t *errfile, 01953 apr_pool_t *pool); 01954 01955 01956 /** 01957 * Similar to svn_io_start_cmd3() but with @a env always set to NULL. 01958 * 01959 * @deprecated Provided for backward compatibility with the 1.7 API 01960 * @since New in 1.7. 01961 */ 01962 SVN_DEPRECATED 01963 svn_error_t *svn_io_start_cmd2(apr_proc_t *cmd_proc, 01964 const char *path, 01965 const char *cmd, 01966 const char *const *args, 01967 svn_boolean_t inherit, 01968 svn_boolean_t infile_pipe, 01969 apr_file_t *infile, 01970 svn_boolean_t outfile_pipe, 01971 apr_file_t *outfile, 01972 svn_boolean_t errfile_pipe, 01973 apr_file_t *errfile, 01974 apr_pool_t *pool); 01975 01976 /** 01977 * Similar to svn_io_start_cmd2() but with @a infile_pipe, @a 01978 * outfile_pipe, and @a errfile_pipe always FALSE. 01979 * 01980 * @deprecated Provided for backward compatibility with the 1.6 API 01981 * @since New in 1.3. 01982 */ 01983 SVN_DEPRECATED 01984 svn_error_t * 01985 svn_io_start_cmd(apr_proc_t *cmd_proc, 01986 const char *path, 01987 const char *cmd, 01988 const char *const *args, 01989 svn_boolean_t inherit, 01990 apr_file_t *infile, 01991 apr_file_t *outfile, 01992 apr_file_t *errfile, 01993 apr_pool_t *pool); 01994 01995 /** 01996 * Wait for the process @a *cmd_proc to complete and optionally retrieve 01997 * its exit code. @a cmd is used only in error messages. 01998 * 01999 * If @a exitcode is not NULL, set @a *exitcode to the exit code of the 02000 * process and do not consider any exit code to be an error. If @a exitcode 02001 * is NULL, then if the exit code of the process is non-zero then return an 02002 * #SVN_ERR_EXTERNAL_PROGRAM error. 02003 * 02004 * If @a exitwhy is not NULL, set @a *exitwhy to indicate why the process 02005 * terminated and do not consider any reason to be an error. If @a exitwhy 02006 * is NULL, then if the termination reason is not @c APR_PROC_CHECK_EXIT() 02007 * then return an #SVN_ERR_EXTERNAL_PROGRAM error. 02008 * 02009 * @since New in 1.3. 02010 */ 02011 svn_error_t * 02012 svn_io_wait_for_cmd(apr_proc_t *cmd_proc, 02013 const char *cmd, 02014 int *exitcode, 02015 apr_exit_why_e *exitwhy, 02016 apr_pool_t *pool); 02017 02018 /** Run a command to completion, by first calling svn_io_start_cmd() and 02019 * then calling svn_io_wait_for_cmd(). The parameters correspond to 02020 * the same-named parameters of those two functions. 02021 */ 02022 svn_error_t * 02023 svn_io_run_cmd(const char *path, 02024 const char *cmd, 02025 const char *const *args, 02026 int *exitcode, 02027 apr_exit_why_e *exitwhy, 02028 svn_boolean_t inherit, 02029 apr_file_t *infile, 02030 apr_file_t *outfile, 02031 apr_file_t *errfile, 02032 apr_pool_t *pool); 02033 02034 /** Invoke the configured @c diff program, with @a user_args (an array 02035 * of utf8-encoded @a num_user_args arguments) if they are specified 02036 * (that is, if @a user_args is non-NULL), or "-u" if they are not. 02037 * If @a user_args is NULL, the value of @a num_user_args is ignored. 02038 * 02039 * Diff runs in utf8-encoded @a dir, and its exit status is stored in 02040 * @a exitcode, if it is not @c NULL. 02041 * 02042 * If @a label1 and/or @a label2 are not NULL they will be passed to the diff 02043 * process as the arguments of "-L" options. @a label1 and @a label2 are also 02044 * in utf8, and will be converted to native charset along with the other args. 02045 * 02046 * @a from is the first file passed to diff, and @a to is the second. The 02047 * stdout of diff will be sent to @a outfile, and the stderr to @a errfile. 02048 * 02049 * @a diff_cmd must be non-NULL. 02050 * 02051 * Do all allocation in @a pool. 02052 * @since New in 1.6.0. 02053 */ 02054 svn_error_t * 02055 svn_io_run_diff2(const char *dir, 02056 const char *const *user_args, 02057 int num_user_args, 02058 const char *label1, 02059 const char *label2, 02060 const char *from, 02061 const char *to, 02062 int *exitcode, 02063 apr_file_t *outfile, 02064 apr_file_t *errfile, 02065 const char *diff_cmd, 02066 apr_pool_t *pool); 02067 02068 /** Similar to svn_io_run_diff2() but with @a diff_cmd encoded in internal 02069 * encoding used by APR. 02070 * 02071 * @deprecated Provided for backwards compatibility with the 1.5 API. */ 02072 SVN_DEPRECATED 02073 svn_error_t * 02074 svn_io_run_diff(const char *dir, 02075 const char *const *user_args, 02076 int num_user_args, 02077 const char *label1, 02078 const char *label2, 02079 const char *from, 02080 const char *to, 02081 int *exitcode, 02082 apr_file_t *outfile, 02083 apr_file_t *errfile, 02084 const char *diff_cmd, 02085 apr_pool_t *pool); 02086 02087 02088 02089 /** Invoke the configured @c diff3 program, in utf8-encoded @a dir 02090 * like this: 02091 * 02092 * diff3 -E -m @a mine @a older @a yours > @a merged 02093 * 02094 * (See the diff3 documentation for details.) 02095 * 02096 * If @a user_args is non-NULL, replace "-E" with the <tt>const char*</tt> 02097 * elements that @a user_args contains. 02098 * 02099 * @a mine, @a older and @a yours are utf8-encoded paths (relative to 02100 * @a dir or absolute) to three files that already exist. 02101 * 02102 * @a merged is an open file handle, and is left open after the merge 02103 * result is written to it. (@a merged should *not* be the same file 02104 * as @a mine, or nondeterministic things may happen!) 02105 * 02106 * @a mine_label, @a older_label, @a yours_label are utf8-encoded label 02107 * parameters for diff3's -L option. Any of them may be @c NULL, in 02108 * which case the corresponding @a mine, @a older, or @a yours parameter is 02109 * used instead. 02110 * 02111 * Set @a *exitcode to diff3's exit status. If @a *exitcode is anything 02112 * other than 0 or 1, then return #SVN_ERR_EXTERNAL_PROGRAM. (Note the 02113 * following from the diff3 info pages: "An exit status of 0 means 02114 * `diff3' was successful, 1 means some conflicts were found, and 2 02115 * means trouble.") 02116 * 02117 * @a diff3_cmd must be non-NULL. 02118 * 02119 * Do all allocation in @a pool. 02120 * 02121 * @since New in 1.4. 02122 */ 02123 svn_error_t * 02124 svn_io_run_diff3_3(int *exitcode, 02125 const char *dir, 02126 const char *mine, 02127 const char *older, 02128 const char *yours, 02129 const char *mine_label, 02130 const char *older_label, 02131 const char *yours_label, 02132 apr_file_t *merged, 02133 const char *diff3_cmd, 02134 const apr_array_header_t *user_args, 02135 apr_pool_t *pool); 02136 02137 /** Similar to svn_io_run_diff3_3(), but with @a diff3_cmd encoded in 02138 * internal encoding used by APR. 02139 * 02140 * @deprecated Provided for backwards compatibility with the 1.5 API. 02141 * @since New in 1.4. 02142 */ 02143 SVN_DEPRECATED 02144 svn_error_t * 02145 svn_io_run_diff3_2(int *exitcode, 02146 const char *dir, 02147 const char *mine, 02148 const char *older, 02149 const char *yours, 02150 const char *mine_label, 02151 const char *older_label, 02152 const char *yours_label, 02153 apr_file_t *merged, 02154 const char *diff3_cmd, 02155 const apr_array_header_t *user_args, 02156 apr_pool_t *pool); 02157 02158 /** Similar to svn_io_run_diff3_2(), but with @a user_args set to @c NULL. 02159 * 02160 * @deprecated Provided for backwards compatibility with the 1.3 API. 02161 */ 02162 SVN_DEPRECATED 02163 svn_error_t * 02164 svn_io_run_diff3(const char *dir, 02165 const char *mine, 02166 const char *older, 02167 const char *yours, 02168 const char *mine_label, 02169 const char *older_label, 02170 const char *yours_label, 02171 apr_file_t *merged, 02172 int *exitcode, 02173 const char *diff3_cmd, 02174 apr_pool_t *pool); 02175 02176 02177 /** Parse utf8-encoded @a mimetypes_file as a MIME types file (such as 02178 * is provided with Apache HTTP Server), and set @a *type_map to a 02179 * hash mapping <tt>const char *</tt> filename extensions to 02180 * <tt>const char *</tt> MIME types. 02181 * 02182 * @since New in 1.5. 02183 */ 02184 svn_error_t * 02185 svn_io_parse_mimetypes_file(apr_hash_t **type_map, 02186 const char *mimetypes_file, 02187 apr_pool_t *pool); 02188 02189 02190 /** Examine utf8-encoded @a file to determine if it can be described by a 02191 * known (as in, known by this function) Multipurpose Internet Mail 02192 * Extension (MIME) type. If so, set @a *mimetype to a character string 02193 * describing the MIME type, else set it to @c NULL. 02194 * 02195 * If not @c NULL, @a mimetype_map is a hash mapping <tt>const char *</tt> 02196 * filename extensions to <tt>const char *</tt> MIME types, and is the 02197 * first source consulted regarding @a file's MIME type. 02198 * 02199 * Use @a pool for any necessary allocations. 02200 * 02201 * @since New in 1.5. 02202 */ 02203 svn_error_t * 02204 svn_io_detect_mimetype2(const char **mimetype, 02205 const char *file, 02206 apr_hash_t *mimetype_map, 02207 apr_pool_t *pool); 02208 02209 02210 /** Like svn_io_detect_mimetype2, but with @a mimetypes_map set to 02211 * @c NULL. 02212 * 02213 * @deprecated Provided for backward compatibility with the 1.4 API 02214 */ 02215 SVN_DEPRECATED 02216 svn_error_t * 02217 svn_io_detect_mimetype(const char **mimetype, 02218 const char *file, 02219 apr_pool_t *pool); 02220 02221 02222 /** Examine up to @a len bytes of data in @a buf to determine if the 02223 * can be considered binary data, in which case return TRUE. 02224 * If the data can be considered plain-text data, return FALSE. 02225 * 02226 * @since New in 1.7. 02227 */ 02228 svn_boolean_t 02229 svn_io_is_binary_data(const void *buf, apr_size_t len); 02230 02231 02232 /** Wrapper for apr_file_open(). @a fname is utf8-encoded. 02233 Always passed flag | APR_BINARY to apr. */ 02234 svn_error_t * 02235 svn_io_file_open(apr_file_t **new_file, 02236 const char *fname, 02237 apr_int32_t flag, 02238 apr_fileperms_t perm, 02239 apr_pool_t *pool); 02240 02241 02242 /** Wrapper for apr_file_close(). */ 02243 svn_error_t * 02244 svn_io_file_close(apr_file_t *file, 02245 apr_pool_t *pool); 02246 02247 02248 /** Wrapper for apr_file_getc(). */ 02249 svn_error_t * 02250 svn_io_file_getc(char *ch, 02251 apr_file_t *file, 02252 apr_pool_t *pool); 02253 02254 02255 /** Wrapper for apr_file_putc(). 02256 * @since New in 1.7 02257 */ 02258 svn_error_t * 02259 svn_io_file_putc(char ch, 02260 apr_file_t *file, 02261 apr_pool_t *pool); 02262 02263 02264 /** Wrapper for apr_file_info_get(). */ 02265 svn_error_t * 02266 svn_io_file_info_get(apr_finfo_t *finfo, 02267 apr_int32_t wanted, 02268 apr_file_t *file, 02269 apr_pool_t *pool); 02270 02271 02272 /** Set @a *filesize_p to the size of @a file. Use @a pool for temporary 02273 * allocations. 02274 * 02275 * @note Use svn_io_file_info_get() to get more information about 02276 * apr_file_t. 02277 * 02278 * @since New in 1.10 02279 */ 02280 svn_error_t * 02281 svn_io_file_size_get(svn_filesize_t *filesize_p, apr_file_t *file, 02282 apr_pool_t *pool); 02283 02284 /** Fetch the current offset of @a file into @a *offset_p. Use @a pool for 02285 * temporary allocations. 02286 * 02287 * @since New in 1.10 02288 */ 02289 svn_error_t * 02290 svn_io_file_get_offset(apr_off_t *offset_p, 02291 apr_file_t *file, 02292 apr_pool_t *pool); 02293 02294 /** Wrapper for apr_file_read(). */ 02295 svn_error_t * 02296 svn_io_file_read(apr_file_t *file, 02297 void *buf, 02298 apr_size_t *nbytes, 02299 apr_pool_t *pool); 02300 02301 02302 /** Wrapper for apr_file_read_full(). 02303 * 02304 * If @a hit_eof is not NULL, EOF will be indicated there and no 02305 * svn_error_t error object will be created upon EOF. 02306 * 02307 * @since New in 1.7 02308 */ 02309 svn_error_t * 02310 svn_io_file_read_full2(apr_file_t *file, 02311 void *buf, 02312 apr_size_t nbytes, 02313 apr_size_t *bytes_read, 02314 svn_boolean_t *hit_eof, 02315 apr_pool_t *pool); 02316 02317 02318 /** Similar to svn_io_file_read_full2 with hit_eof being set 02319 * to @c NULL. 02320 * 02321 * @deprecated Provided for backward compatibility with the 1.6 API 02322 */ 02323 SVN_DEPRECATED 02324 svn_error_t * 02325 svn_io_file_read_full(apr_file_t *file, 02326 void *buf, 02327 apr_size_t nbytes, 02328 apr_size_t *bytes_read, 02329 apr_pool_t *pool); 02330 02331 02332 /** Wrapper for apr_file_seek(). */ 02333 svn_error_t * 02334 svn_io_file_seek(apr_file_t *file, 02335 apr_seek_where_t where, 02336 apr_off_t *offset, 02337 apr_pool_t *pool); 02338 02339 /** Set the file pointer of the #APR_BUFFERED @a file to @a offset. In 02340 * contrast to #svn_io_file_seek, this function will attempt to resize the 02341 * internal data buffer to @a block_size bytes and to read data aligned to 02342 * multiples of that value. The beginning of the block will be returned 02343 * in @a buffer_start, if that is not NULL. 02344 * Uses @a scratch_pool for temporary allocations. 02345 * 02346 * @note Due to limitations of the APR API, the alignment may not be 02347 * successful. If you never use any other seek function on @a file, 02348 * however, you are virtually guaranteed to get at least 4kByte alignment 02349 * for all reads. 02350 * 02351 * @note Calling this for non-buffered files is legal but inefficient. 02352 * 02353 * @since New in 1.9 02354 */ 02355 svn_error_t * 02356 svn_io_file_aligned_seek(apr_file_t *file, 02357 apr_off_t block_size, 02358 apr_off_t *buffer_start, 02359 apr_off_t offset, 02360 apr_pool_t *scratch_pool); 02361 02362 /** Wrapper for apr_file_write(). */ 02363 svn_error_t * 02364 svn_io_file_write(apr_file_t *file, 02365 const void *buf, 02366 apr_size_t *nbytes, 02367 apr_pool_t *pool); 02368 02369 /** Wrapper for apr_file_flush(). 02370 * @since New in 1.9 02371 */ 02372 svn_error_t * 02373 svn_io_file_flush(apr_file_t *file, 02374 apr_pool_t *scratch_pool); 02375 02376 02377 02378 /** Wrapper for apr_file_write_full(). */ 02379 svn_error_t * 02380 svn_io_file_write_full(apr_file_t *file, 02381 const void *buf, 02382 apr_size_t nbytes, 02383 apr_size_t *bytes_written, 02384 apr_pool_t *pool); 02385 02386 /** 02387 * Writes @a nbytes bytes from @a *buf to a temporary file inside the same 02388 * directory as @a *final_path. Then syncs the temporary file to disk and 02389 * closes the file. After this rename the temporary file to @a final_path, 02390 * possibly replacing an existing file. 02391 * 02392 * If @a copy_perms_path is not NULL, copy the permissions applied on @a 02393 * @a copy_perms_path on the temporary file before renaming. 02394 * 02395 * If @a flush_to_disk is non-zero, do not return until the node has 02396 * actually been written on the disk. 02397 * 02398 * @note The flush to disk operation can be very expensive on systems 02399 * that implement flushing on all IO layers, like Windows. Please use 02400 * @a flush_to_disk flag only for critical data. 02401 * 02402 * @since New in 1.10. 02403 */ 02404 svn_error_t * 02405 svn_io_write_atomic2(const char *final_path, 02406 const void *buf, 02407 apr_size_t nbytes, 02408 const char *copy_perms_path, 02409 svn_boolean_t flush_to_disk, 02410 apr_pool_t *scratch_pool); 02411 02412 /** Similar to svn_io_write_atomic2(), but with @a flush_to_disk set 02413 * to @c TRUE. 02414 * 02415 * @since New in 1.9. 02416 * 02417 * @deprecated Provided for backward compatibility with the 1.9 API 02418 */ 02419 SVN_DEPRECATED 02420 svn_error_t * 02421 svn_io_write_atomic(const char *final_path, 02422 const void *buf, 02423 apr_size_t nbytes, 02424 const char* copy_perms_path, 02425 apr_pool_t *scratch_pool); 02426 02427 /** 02428 * Open a unique file in @a dirpath, and write @a nbytes from @a buf to 02429 * the file before flushing it to disk and closing it. Return the name 02430 * of the newly created file in @a *tmp_path, allocated in @a pool. 02431 * 02432 * If @a dirpath is @c NULL, use the path returned from svn_io_temp_dir(). 02433 * (Note that when using the system-provided temp directory, it may not 02434 * be possible to atomically rename the resulting file due to cross-device 02435 * issues.) 02436 * 02437 * The file will be deleted according to @a delete_when. 02438 * 02439 * @since New in 1.6. 02440 */ 02441 svn_error_t * 02442 svn_io_write_unique(const char **tmp_path, 02443 const char *dirpath, 02444 const void *buf, 02445 apr_size_t nbytes, 02446 svn_io_file_del_t delete_when, 02447 apr_pool_t *pool); 02448 02449 /** Wrapper for apr_file_trunc(). 02450 * @since New in 1.6. */ 02451 svn_error_t * 02452 svn_io_file_trunc(apr_file_t *file, 02453 apr_off_t offset, 02454 apr_pool_t *pool); 02455 02456 02457 /** Wrapper for apr_stat(). @a fname is utf8-encoded. */ 02458 svn_error_t * 02459 svn_io_stat(apr_finfo_t *finfo, 02460 const char *fname, 02461 apr_int32_t wanted, 02462 apr_pool_t *pool); 02463 02464 02465 /** Rename and/or move the node (not necessarily a regular file) at 02466 * @a from_path to a new path @a to_path within the same filesystem. 02467 * In some cases, an existing node at @a to_path will be overwritten. 02468 * 02469 * @a from_path and @a to_path are utf8-encoded. If @a flush_to_disk 02470 * is non-zero, do not return until the node has actually been moved on 02471 * the disk. 02472 * 02473 * @note The flush to disk operation can be very expensive on systems 02474 * that implement flushing on all IO layers, like Windows. Please use 02475 * @a flush_to_disk flag only for critical data. 02476 * 02477 * @since New in 1.10. 02478 */ 02479 svn_error_t * 02480 svn_io_file_rename2(const char *from_path, const char *to_path, 02481 svn_boolean_t flush_to_disk, apr_pool_t *pool); 02482 02483 /** Similar to svn_io_file_rename2(), but with @a flush_to_disk set 02484 * to @c FALSE. 02485 * 02486 * @deprecated Provided for backward compatibility with the 1.9 API 02487 */ 02488 SVN_DEPRECATED 02489 svn_error_t * 02490 svn_io_file_rename(const char *from_path, 02491 const char *to_path, 02492 apr_pool_t *pool); 02493 02494 02495 /** Move the file from @a from_path to @a to_path, even across device 02496 * boundaries. Overwrite @a to_path if it exists. 02497 * 02498 * @note This function is different from svn_io_file_rename in that the 02499 * latter fails in the 'across device boundaries' case. 02500 * 02501 * @since New in 1.3. 02502 */ 02503 svn_error_t * 02504 svn_io_file_move(const char *from_path, 02505 const char *to_path, 02506 apr_pool_t *pool); 02507 02508 02509 /** Wrapper for apr_dir_make(). @a path is utf8-encoded. */ 02510 svn_error_t * 02511 svn_io_dir_make(const char *path, 02512 apr_fileperms_t perm, 02513 apr_pool_t *pool); 02514 02515 /** Same as svn_io_dir_make(), but sets the hidden attribute on the 02516 directory on systems that support it. */ 02517 svn_error_t * 02518 svn_io_dir_make_hidden(const char *path, 02519 apr_fileperms_t perm, 02520 apr_pool_t *pool); 02521 02522 /** 02523 * Same as svn_io_dir_make(), but attempts to set the sgid on the 02524 * directory on systems that support it. Does not return an error if 02525 * the attempt to set the sgid bit fails. On Unix filesystems, 02526 * setting the sgid bit on a directory ensures that files and 02527 * subdirectories created within inherit group ownership from the 02528 * parent instead of from the primary gid. 02529 * 02530 * @since New in 1.1. 02531 */ 02532 svn_error_t * 02533 svn_io_dir_make_sgid(const char *path, 02534 apr_fileperms_t perm, 02535 apr_pool_t *pool); 02536 02537 /** Wrapper for apr_dir_open(). @a dirname is utf8-encoded. */ 02538 svn_error_t * 02539 svn_io_dir_open(apr_dir_t **new_dir, 02540 const char *dirname, 02541 apr_pool_t *pool); 02542 02543 /** Wrapper for apr_dir_close(). 02544 * 02545 * @since New in 1.7. 02546 */ 02547 svn_error_t * 02548 svn_io_dir_close(apr_dir_t *thedir); 02549 02550 /** Wrapper for apr_dir_remove(). @a dirname is utf8-encoded. 02551 * @note This function has this name to avoid confusion with 02552 * svn_io_remove_dir2(), which is recursive. 02553 */ 02554 svn_error_t * 02555 svn_io_dir_remove_nonrecursive(const char *dirname, 02556 apr_pool_t *pool); 02557 02558 02559 /** Wrapper for apr_dir_read(). Ensures that @a finfo->name is 02560 * utf8-encoded, which means allocating @a finfo->name in @a pool, 02561 * which may or may not be the same as @a finfo's pool. Use @a pool 02562 * for error allocation as well. 02563 */ 02564 svn_error_t * 02565 svn_io_dir_read(apr_finfo_t *finfo, 02566 apr_int32_t wanted, 02567 apr_dir_t *thedir, 02568 apr_pool_t *pool); 02569 02570 /** Wrapper for apr_file_name_get(). @a *filename is utf8-encoded. 02571 * 02572 * @note The file name may be NULL. 02573 * 02574 * @since New in 1.7. */ 02575 svn_error_t * 02576 svn_io_file_name_get(const char **filename, 02577 apr_file_t *file, 02578 apr_pool_t *pool); 02579 02580 02581 02582 /** Version/format files. 02583 * 02584 * @defgroup svn_io_format_files Version/format files 02585 * @{ 02586 */ 02587 02588 /** Set @a *version to the integer that starts the file at @a path. If the 02589 * file does not begin with a series of digits followed by a newline, 02590 * return the error #SVN_ERR_BAD_VERSION_FILE_FORMAT. Use @a pool for 02591 * all allocations. 02592 */ 02593 svn_error_t * 02594 svn_io_read_version_file(int *version, 02595 const char *path, 02596 apr_pool_t *pool); 02597 02598 /** Create (or overwrite) the file at @a path with new contents, 02599 * formatted as a non-negative integer @a version followed by a single 02600 * newline. On successful completion the file will be read-only. Use 02601 * @a pool for all allocations. 02602 */ 02603 svn_error_t * 02604 svn_io_write_version_file(const char *path, 02605 int version, 02606 apr_pool_t *pool); 02607 02608 /** Read a line of text from a file, up to a specified length. 02609 * 02610 * Allocate @a *stringbuf in @a result_pool, and read into it one line 02611 * from @a file. Reading stops either after a line-terminator was found 02612 * or after @a max_len bytes have been read. 02613 * 02614 * If end-of-file is reached or @a max_len bytes have been read, and @a eof 02615 * is not NULL, then set @a *eof to @c TRUE. 02616 * 02617 * The line-terminator is not stored in @a *stringbuf. 02618 * The line-terminator is detected automatically and stored in @a *eol 02619 * if @a eol is not NULL. If EOF is reached and @a file does not end 02620 * with a newline character, and @a eol is not NULL, @ *eol is set to NULL. 02621 * 02622 * @a scratch_pool is used for temporary allocations. 02623 * 02624 * Hint: To read all data until a line-terminator is hit, pass APR_SIZE_MAX 02625 * for @a max_len. 02626 * 02627 * @since New in 1.8. 02628 */ 02629 svn_error_t * 02630 svn_io_file_readline(apr_file_t *file, 02631 svn_stringbuf_t **stringbuf, 02632 const char **eol, 02633 svn_boolean_t *eof, 02634 apr_size_t max_len, 02635 apr_pool_t *result_pool, 02636 apr_pool_t *scratch_pool); 02637 02638 /** @} */ 02639 02640 #ifdef __cplusplus 02641 } 02642 #endif /* __cplusplus */ 02643 02644 #endif /* SVN_IO_H */
1.6.1