3
* ====================================================================
4
* Copyright (c) 2000-2004 CollabNet. All rights reserved.
6
* This software is licensed as described in the file COPYING, which
7
* you should have received as part of this distribution. The terms
8
* are also available at http://subversion.tigris.org/license-1.html.
9
* If newer versions of this license are posted there, you may use a
10
* newer version instead, at your option.
12
* This software consists of voluntary contributions made by many
13
* individuals. For exact contribution history, see the revision
14
* history and logs, available at http://subversion.tigris.org/.
15
* ====================================================================
19
* @brief General file I/O for Subversion
22
/* ==================================================================== */
29
#include <apr_pools.h>
30
#include <apr_file_io.h>
31
#include <apr_thread_proc.h>
33
#include "svn_types.h"
34
#include "svn_error.h"
35
#include "svn_string.h"
39
#endif /* __cplusplus */
43
/** Determine the @a kind of @a path.
45
* If utf8-encoded @a path exists, set @a *kind to the appropriate kind,
46
* else set it to @c svn_node_unknown.
48
* If @a path is a file, @a *kind is set to @c svn_node_file.
50
* If @a path is a directory, @a *kind is set to @c svn_node_dir.
52
* If @a path does not exist in its final component, @a *kind is set to
55
* If intermediate directories on the way to @a path don't exist, an
56
* error is returned, and @a *kind's value is undefined.
58
svn_error_t *svn_io_check_path (const char *path,
59
svn_node_kind_t *kind,
65
* Like svn_io_check_path(), but also set *is_special to @c TRUE if
66
* the path is not a normal file.
68
svn_error_t *svn_io_check_special_path (const char *path,
69
svn_node_kind_t *kind,
70
svn_boolean_t *is_special,
73
/** Like svn_io_check_path(), but resolve symlinks. This returns the
74
same varieties of @a kind as svn_io_check_path(). */
75
svn_error_t *svn_io_check_resolved_path (const char *path,
76
svn_node_kind_t *kind,
80
/** Open a new file (for writing) with a unique name based on utf-8
81
* encoded @a path, in the same directory as @a path. The file handle is
82
* returned in @a *f, and the name, which ends with @a suffix, is returned
83
* in @a *unique_name_p, also utf8-encoded. If @a delete_on_close is set,
84
* then the @c APR_DELONCLOSE flag will be used when opening the file. The
85
* @c APR_BUFFERED flag will always be used.
87
* The first attempt will just append @a suffix. If the result is not
88
* a unique name, then subsequent attempts will append a dot,
89
* followed by an iteration number ("2", then "3", and so on),
90
* followed by the suffix. For example, if @a path is
94
* then successive calls to
96
* @c svn_io_open_unique_file(&f, &unique_name, @a path, ".tmp", pool)
100
* tests/t1/A/D/G/pi.tmp
101
* tests/t1/A/D/G/pi.2.tmp
102
* tests/t1/A/D/G/pi.3.tmp
103
* tests/t1/A/D/G/pi.4.tmp
104
* tests/t1/A/D/G/pi.5.tmp
107
* @a *unique_name_p will never be exactly the same as @a path, even
108
* if @a path does not exist.
110
* It doesn't matter if @a path is a file or directory, the unique name will
111
* be in @a path's parent either way.
113
* Allocate @a *f and @a *unique_name_p in @a pool.
115
* If no unique name can be found, @c SVN_ERR_IO_UNIQUE_NAMES_EXHAUSTED is
116
* the error returned.
118
* Claim of Historical Inevitability: this function was written
121
* - @c tmpnam() is not thread-safe.
122
* - @c tempname() tries standard system tmp areas first.
124
svn_error_t *svn_io_open_unique_file (apr_file_t **f,
125
const char **unique_name_p,
128
svn_boolean_t delete_on_close,
134
* Like svn_io_open_unique_file, except that instead of creating a
135
* file, a symlink is generated that references the path @a dest.
137
svn_error_t *svn_io_create_unique_link (const char **unique_name_p,
147
* Set @a *dest to the path that the symlink at @a path references.
148
* Allocate the string from @a pool.
150
svn_error_t *svn_io_read_link (svn_string_t **dest,
155
/** Set @a *dir to a directory path (allocated in @a pool) deemed
156
* usable for the creation of temporary files and subdirectories.
158
svn_error_t *svn_io_temp_dir (const char **dir,
162
/** Copy @a src to @a dst atomically. Overwrite @a dst if it exists, else
163
* create it. Both @a src and @a dst are utf8-encoded filenames. If
164
* @a copy_perms is true, set @a dst's permissions to match those of @a src.
166
svn_error_t *svn_io_copy_file (const char *src,
168
svn_boolean_t copy_perms,
174
* Copy symbolic link @a src to @a dst atomically. Overwrite @a dst
175
* if it exists, else create it. Both @a src and @a dst are
176
* utf8-encoded filenames. After copying, the @a dst link will point
177
* to the same thing @a src does.
179
svn_error_t *svn_io_copy_link (const char *src,
184
/** Recursively copy directory @a src into @a dst_parent, as a new entry named
185
* @a dst_basename. If @a dst_basename already exists in @a dst_parent,
186
* return error. @a copy_perms will be passed through to @c svn_io_copy_file
187
* when any files are copied. @a src, @a dst_parent, and @a dst_basename are
190
* If @a cancel_func is non-null, invoke it with @a cancel_baton at
191
* various points during the operation. If it returns any error
192
* (typically @c SVN_ERR_CANCELLED), return that error immediately.
194
svn_error_t *svn_io_copy_dir_recursively (const char *src,
195
const char *dst_parent,
196
const char *dst_basename,
197
svn_boolean_t copy_perms,
198
svn_cancel_func_t cancel_func,
204
/** Create directory @a path on the file system, creating intermediate
205
* directories as required, like <tt>mkdir -p</tt>. Report no error if @a
206
* path already exists. @a path is utf8-encoded.
208
* This is essentially a wrapper for @c apr_dir_make_recursive(), passing
209
* @c APR_OS_DEFAULT as the permissions.
211
svn_error_t *svn_io_make_dir_recursively (const char *path, apr_pool_t *pool);
214
/** Set @a *is_empty_p to @c TRUE if directory @a path is empty, else to
215
* @c FALSE if it is not empty. @a path must be a directory, and is
216
* utf8-encoded. Use @a pool for temporary allocation.
219
svn_io_dir_empty (svn_boolean_t *is_empty_p,
224
/** Append @a src to @a dst. @a dst will be appended to if it exists, else it
225
* will be created. Both @a src and @a dst are utf8-encoded.
227
svn_error_t *svn_io_append_file (const char *src,
232
/** Make a file as read-only as the operating system allows.
233
* @a path is the utf8-encoded path to the file. If @a ignore_enoent is
234
* @c TRUE, don't fail if the target file doesn't exist.
236
svn_error_t *svn_io_set_file_read_only (const char *path,
237
svn_boolean_t ignore_enoent,
241
/** Make a file as writable as the operating system allows.
242
* @a path is the utf8-encoded path to the file. If @a ignore_enoent is
243
* @c TRUE, don't fail if the target file doesn't exist.
244
* @warning On Unix this function will do the equivalent of chmod a+w path.
245
* If this is not what you want you should not use this function, but rather
246
* use apr_file_perms_set().
248
svn_error_t *svn_io_set_file_read_write (const char *path,
249
svn_boolean_t ignore_enoent,
253
/** Minimally change the read-write permissions of a file.
256
* When making @a path read-write on operating systems with unix style
257
* permissions, set the permissions on @a path to the permissions that
258
* are set when a new file is created (effectively honoring the user's
261
* When making the file read-only on operating systems with unix style
262
* permissions, remove all write permissions.
264
* On other operating systems, toggle the file's "writability" as much as
265
* the operating system allows.
267
* @a path is the utf8-encoded path to the file. If @a enable_write
268
* is @c TRUE, then make the file read-write. If @c FALSE, make it
269
* write-only. If @a ignore_enoent is @c TRUE, don't fail if the target
270
* file doesn't exist.
272
svn_error_t *svn_io_set_file_read_write_carefully (const char *path,
273
svn_boolean_t enable_write,
274
svn_boolean_t ignore_enoent,
277
/** Toggle a file's "executability".
279
* When making the file executable on operating systems with unix style
280
* permissions, never add an execute permission where there is not
281
* already a read permission: that is, only make the file executable
282
* for the user, group or world if the corresponding read permission
283
* is already set for user, group or world.
285
* When making the file non-executable on operating systems with unix style
286
* permissions, remove all execute permissions.
288
* On other operating systems, toggle the file's "executability" as much as
289
* the operating system allows.
291
* @a path is the utf8-encoded path to the file. If @a executable
292
* is @c TRUE, then make the file executable. If @c FALSE, make in
293
* non-executable. If @a ignore_enoent is @c TRUE, don't fail if the target
294
* file doesn't exist.
296
svn_error_t *svn_io_set_file_executable (const char *path,
297
svn_boolean_t executable,
298
svn_boolean_t ignore_enoent,
301
/** Determine whether a file is executable by the current user.
302
* Set @a *executable to @c TRUE if the file @a path is executable by the
303
* current user, otherwise set it to @c FALSE.
305
* On Windows and on platforms without userids, always returns @c FALSE.
307
svn_error_t *svn_io_is_file_executable(svn_boolean_t *executable,
312
/** Read a line from @a file into @a buf, but not exceeding @a *limit bytes.
313
* Does not include newline, instead '\\0' is put there.
314
* Length (as in strlen) is returned in @a *limit.
315
* @a buf should be pre-allocated.
316
* @a file should be already opened.
318
* When the file is out of lines, @c APR_EOF will be returned.
321
svn_io_read_length_line (apr_file_t *file, char *buf, apr_size_t *limit,
325
/** Set @a *apr_time to the time of last modification of the contents of the
326
* file @a path. @a path is utf8-encoded.
328
* Note: this is the APR mtime which corresponds to the traditional mtime
329
* on Unix, and the last write time on Windows.
331
svn_error_t *svn_io_file_affected_time (apr_time_t *apr_time,
335
/** Set the timestamp of file @a path to @a apr_time. @a path is
338
* Note: this is the APR mtime which corresponds to the traditional mtime
339
* on Unix, and the last write time on Windows.
341
svn_error_t *svn_io_set_file_affected_time (apr_time_t apr_time,
347
/** Set @a *different_p to non-zero if @a file1 and @a file2 have different
348
* sizes, else set to zero. Both @a file1 and @a file2 are utf8-encoded.
350
* Setting @a *different_p to zero does not mean the files definitely
351
* have the same size, it merely means that the sizes are not
352
* definitely different. That is, if the size of one or both files
353
* cannot be determined, then the sizes are not known to be different,
354
* so @a *different_p is set to 0.
356
svn_error_t *svn_io_filesizes_different_p (svn_boolean_t *different_p,
362
/** Put the md5 checksum of @a file into @a digest.
363
* @a digest points to @c APR_MD5_DIGESTSIZE bytes of storage.
364
* Use @a pool only for temporary allocations.
366
svn_error_t *svn_io_file_checksum (unsigned char digest[],
371
/** Set @a *same to non-zero if @a file1 and @a file2 have the same
372
* contents, else set it to zero. Use @a pool for temporary allocations.
374
svn_error_t *svn_io_files_contents_same_p (svn_boolean_t *same,
379
/** Create file at @a file with contents @a contents.
380
* will be created. Path @a file is utf8-encoded.
381
* Use @a pool for memory allocations.
383
svn_error_t *svn_io_file_create (const char *file,
384
const char *contents,
388
* @deprecated Provided for backward compatibility with the 1.0 API.
390
* Lock file at @a lock_file. If @a exclusive is TRUE,
391
* obtain exclusive lock, otherwise obtain shared lock.
392
* Lock will be automatically released when @a pool is cleared or destroyed.
393
* Use @a pool for memory allocations.
395
svn_error_t *svn_io_file_lock (const char *lock_file,
396
svn_boolean_t exclusive,
402
* Lock file at @a lock_file. If @a exclusive is TRUE,
403
* obtain exclusive lock, otherwise obtain shared lock.
405
* If @a nonblocking is TRUE, do not wait for the lock if it
406
* is not available: throw an error instead.
408
* Lock will be automatically released when @a pool is cleared or destroyed.
409
* Use @a pool for memory allocations.
411
svn_error_t *svn_io_file_lock2 (const char *lock_file,
412
svn_boolean_t exclusive,
413
svn_boolean_t nonblocking,
418
* Flush any unwritten data from @a file to disk. Use @a pool for
419
* memory allocations.
421
svn_error_t *svn_io_file_flush_to_disk (apr_file_t *file,
424
/** Copy file @a file from location @a src_path to location @a dest_path.
425
* Use @a pool for memory allocations.
427
svn_error_t *svn_io_dir_file_copy (const char *src_path,
428
const char *dest_path,
433
/** Generic byte-streams
435
* @defgroup svn_io_byte_streams generic byte streams
439
/** An abstract stream of bytes--either incoming or outgoing or both.
441
* The creator of a stream sets functions to handle read and write.
442
* Both of these handlers accept a baton whose value is determined at
443
* stream creation time; this baton can point to a structure
444
* containing data associated with the stream. If a caller attempts
445
* to invoke a handler which has not been set, it will generate a
446
* runtime assertion failure. The creator can also set a handler for
447
* close requests so that it can flush buffered data or whatever;
448
* if a close handler is not specified, a close request on the stream
449
* will simply be ignored. Note that svn_stream_close() does not
450
* deallocate the memory used to allocate the stream structure; free
451
* the pool you created the stream in to free that memory.
453
* The read and write handlers accept length arguments via pointer.
454
* On entry to the handler, the pointed-to value should be the amount
455
* of data which can be read or the amount of data to write. When the
456
* handler returns, the value is reset to the amount of data actually
457
* read or written. Handlers are obliged to complete a read or write
458
* to the maximum extent possible; thus, a short read with no
459
* associated error implies the end of the input stream, and a short
460
* write should never occur without an associated error.
462
typedef struct svn_stream_t svn_stream_t;
466
/** Read handler function for a generic stream. */
467
typedef svn_error_t *(*svn_read_fn_t) (void *baton,
471
/** Write handler function for a generic stream. */
472
typedef svn_error_t *(*svn_write_fn_t) (void *baton,
476
/** Close handler function for a generic stream. */
477
typedef svn_error_t *(*svn_close_fn_t) (void *baton);
480
/** Creating a generic stream. */
481
svn_stream_t *svn_stream_create (void *baton, apr_pool_t *pool);
483
/** Set @a stream's baton to @a baton */
484
void svn_stream_set_baton (svn_stream_t *stream, void *baton);
486
/** Set @a stream's read function to @a read_fn */
487
void svn_stream_set_read (svn_stream_t *stream, svn_read_fn_t read_fn);
489
/** Set @a stream's write function to @a write_fn */
490
void svn_stream_set_write (svn_stream_t *stream, svn_write_fn_t write_fn);
492
/** Set @a stream's close function to @a close_fn */
493
void svn_stream_set_close (svn_stream_t *stream, svn_close_fn_t close_fn);
496
/** Convenience function to create a generic stream which is empty. */
497
svn_stream_t *svn_stream_empty (apr_pool_t *pool);
500
/** Convenience function for creating streams which operate on APR
501
* files. For convenience, if @a file is NULL then @c svn_stream_empty(pool)
502
* is returned. Note that the stream returned by these operations is not
503
* considered to "own" the underlying file, meaning that @c svn_stream_close()
504
* on the stream will not close the file.
506
svn_stream_t *svn_stream_from_aprfile (apr_file_t *file, apr_pool_t *pool);
508
/** Set @a *out to a generic stream connected to stdout, allocated in
509
* @a pool. The stream and its underlying APR handle will be closed
510
* when @a pool is cleared or destroyed.
512
svn_error_t *svn_stream_for_stdout (svn_stream_t **out, apr_pool_t *pool);
514
/** Return a generic stream connected to stringbuf @a str. Allocate the
517
svn_stream_t *svn_stream_from_stringbuf (svn_stringbuf_t *str,
520
/** Return a stream that decompresses all data read and compresses all
521
* data written. The stream @a stream is used to read and write all
522
* compressed data. All compression data structures are allocated on
523
* @a pool. If compression support is not compiled in then @c
524
* svn_stream_compressed() returns @a stream unmodified. Make sure you
525
* call @c svn_stream_close() on the stream returned by this function,
526
* so that all data are flushed and cleaned up.
528
svn_stream_t *svn_stream_compressed (svn_stream_t *stream,
531
/** Read from a generic stream. */
532
svn_error_t *svn_stream_read (svn_stream_t *stream, char *buffer,
535
/** Write to a generic stream. */
536
svn_error_t *svn_stream_write (svn_stream_t *stream, const char *data,
539
/** Close a generic stream. */
540
svn_error_t *svn_stream_close (svn_stream_t *stream);
543
/** Write to @a stream using a printf-style @a fmt specifier, passed through
544
* @c apr_psprintf using memory from @a pool.
546
svn_error_t *svn_stream_printf (svn_stream_t *stream,
550
__attribute__ ((format(printf, 3, 4)));
552
/** Allocate @a *stringbuf in @a pool, and read into it one line (terminated
553
* by @a eol) from @a stream. The line-terminator is read from the stream,
554
* but is not added to the end of the stringbuf. Instead, the stringbuf
555
* ends with a usual '\\0'.
557
* If @a stream runs out of bytes before encountering a line-terminator,
558
* then set @a *eof to @c TRUE, otherwise set @a *eof to FALSE.
561
svn_stream_readline (svn_stream_t *stream,
562
svn_stringbuf_t **stringbuf,
570
* Read the contents of the readable stream @a from and write them to the
571
* writable stream @a to.
573
svn_error_t *svn_stream_copy (svn_stream_t *from, svn_stream_t *to,
578
/** Sets @a *result to a string containing the contents of @a filename, a
581
* If @a filename is "-", return the error @c SVN_ERR_UNSUPPORTED_FEATURE
582
* and don't touch @a *result.
584
* ### Someday, "-" will fill @a *result from stdin. The problem right
585
* now is that if the same command invokes the editor, stdin is crap,
586
* and the editor acts funny or dies outright. One solution is to
587
* disallow stdin reading and invoking the editor, but how to do that
590
svn_error_t *svn_stringbuf_from_file (svn_stringbuf_t **result,
591
const char *filename,
594
/** Sets @a *result to a string containing the contents of the already opened
595
* @a file. Reads from the current position in file to the end. Does not
596
* close the file or reset the cursor position.
598
svn_error_t *svn_stringbuf_from_aprfile (svn_stringbuf_t **result,
602
/** Remove file @a path, a utf8-encoded path. This wraps @c apr_file_remove(),
603
* converting any error to a Subversion error.
605
svn_error_t *svn_io_remove_file (const char *path, apr_pool_t *pool);
607
/** Recursively remove directory @a path. @a path is utf8-encoded. */
608
svn_error_t *svn_io_remove_dir (const char *path, apr_pool_t *pool);
611
/** Read all of the disk entries in directory @a path, a utf8-encoded
612
* path. Set @a *dirents to a hash mapping dirent names (<tt>char *</tt>) to
613
* enumerated dirent filetypes (@c svn_node_kind_t *).
615
* Note: the `.' and `..' directories normally returned by
616
* @c apr_dir_read are NOT returned in the hash.
618
svn_error_t *svn_io_get_dirents (apr_hash_t **dirents,
623
/** Callback function type for @c svn_io_dir_walk */
624
typedef svn_error_t * (*svn_io_walk_func_t) (void *baton,
626
const apr_finfo_t *finfo,
629
/** This function will recursively walk over the files and directories
630
* rooted at @a dirname, a utf8-encoded path. For each file or directory,
631
* @a walk_func is invoked, passing in the @a walk_baton, the utf8-encoded
632
* full path to the entry, an @c apr_finfo_t structure, and a temporary
633
* pool for allocations. For any directory, @a walk_func will be invoked
634
* on the directory itself before being invoked on any subdirectories or
635
* files within the directory.
637
* The set of information passed to @a walk_func is specified by @a wanted,
638
* and the items specified by @c APR_FINFO_TYPE and @c APR_FINFO_NAME.
640
* All allocations will be performed in @a pool.
642
svn_error_t *svn_io_dir_walk (const char *dirname,
644
svn_io_walk_func_t walk_func,
648
/** Invoke @a cmd with @a args, using utf8-encoded @a path as working
649
* directory. Connect @a cmd's stdin, stdout, and stderr to @a infile,
650
* @a outfile, and @a errfile, except where they are null.
652
* If set, @a exitcode will contain the exit code of the process upon return,
653
* and @a exitwhy will indicate why the process terminated. If @a exitwhy is
654
* not set and the exit reason is not @c APR_PROC_CHECK_EXIT(), or if
655
* @a exitcode is not set and the exit code is non-zero, then an
656
* @c SVN_ERR_EXTERNAL_PROGRAM error will be returned.
658
* @a args is a list of utf8-encoded <tt>const char *</tt> arguments,
659
* terminated by @c NULL. @a args[0] is the name of the program, though it
660
* need not be the same as @a cmd.
662
* @a inherit sets whether the invoked program shall inherit its environment or
665
svn_error_t *svn_io_run_cmd (const char *path,
667
const char *const *args,
669
apr_exit_why_e *exitwhy,
670
svn_boolean_t inherit,
676
/** Invoke @c the configured diff program, with @a user_args (an array
677
* of utf8-encoded @a num_user_args arguments), if they are specified,
678
* or "-u" if they are not.
680
* Diff runs in utf8-encoded @a dir, and its exit status is stored in
681
* @a exitcode, if it is not @c NULL.
683
* If @a label1 and/or @a label2 are not null they will be passed to the diff
684
* process as the arguments of "-L" options. @a label1 and @a label2 are also
685
* in utf8, and will be converted to native charset along with the other args.
687
* @a from is the first file passed to diff, and @a to is the second. The
688
* stdout of diff will be sent to @a outfile, and the stderr to @a errfile.
690
* @a diff_cmd must be non-null.
692
* Do all allocation in @a pool.
694
svn_error_t *svn_io_run_diff (const char *dir,
695
const char *const *user_args,
704
const char *diff_cmd,
708
/** Invoke @c the configured diff3 program, in utf8-encoded @a dir
711
* diff3 -Em @a mine @a older @a yours > @a merged
713
* (See the diff3 documentation for details.)
715
* @a mine, @a older, and @a yours are utf8-encoded paths, relative to @a dir,
716
* to three files that already exist. @a merged is an open file handle, and
717
* is left open after the merge result is written to it. (@a merged
718
* should *not* be the same file as @a mine, or nondeterministic things
721
* @a mine_label, @a older_label, @a yours_label are utf8-encoded label
722
* parameters for diff3's -L option. Any of them may be @c NULL, in
723
* which case the corresponding @a mine, @a older, or @a yours parameter is
726
* Set @a *exitcode to diff3's exit status. If @a *exitcode is anything
727
* other than 0 or 1, then return @c SVN_ERR_EXTERNAL_PROGRAM. (Note the
728
* following from the diff3 info pages: "An exit status of 0 means
729
* `diff3' was successful, 1 means some conflicts were found, and 2
732
* @a diff3_cmd must be non-null.
734
* Do all allocation in @a pool.
736
svn_error_t *svn_io_run_diff3 (const char *dir,
740
const char *mine_label,
741
const char *older_label,
742
const char *yours_label,
745
const char *diff3_cmd,
749
/** Examine utf8-encoded @a file to determine if it can be described by a
750
* known (as in, known by this function) Multipurpose Internet Mail
751
* Extension (MIME) type. If so, set @a *mimetype to a character string
752
* describing the MIME type, else set it to @c NULL. Use @a pool for any
753
* necessary allocations.
755
svn_error_t *svn_io_detect_mimetype (const char **mimetype,
760
/** Wrapper for @c apr_file_open(), which see. @a fname is utf8-encoded. */
762
svn_io_file_open (apr_file_t **new_file, const char *fname,
763
apr_int32_t flag, apr_fileperms_t perm,
767
/** Wrapper for @c apr_file_close(), which see. */
769
svn_io_file_close (apr_file_t *file, apr_pool_t *pool);
772
/** Wrapper for @c apr_file_getc(), which see. */
774
svn_io_file_getc (char *ch, apr_file_t *file, apr_pool_t *pool);
777
/** Wrapper for @c apr_file_info_get(), which see. */
779
svn_io_file_info_get (apr_finfo_t *finfo, apr_int32_t wanted,
780
apr_file_t *file, apr_pool_t *pool);
783
/** Wrapper for @c apr_file_read(), which see. */
785
svn_io_file_read (apr_file_t *file, void *buf,
786
apr_size_t *nbytes, apr_pool_t *pool);
789
/** Wrapper for @c apr_file_read_full(), which see. */
791
svn_io_file_read_full (apr_file_t *file, void *buf,
792
apr_size_t nbytes, apr_size_t *bytes_read,
796
/** Wrapper for @c apr_file_seek(), which see. */
798
svn_io_file_seek (apr_file_t *file, apr_seek_where_t where,
799
apr_off_t *offset, apr_pool_t *pool);
802
/** Wrapper for @c apr_file_write(), which see. */
804
svn_io_file_write (apr_file_t *file, const void *buf,
805
apr_size_t *nbytes, apr_pool_t *pool);
808
/** Wrapper for @c apr_file_write_full(), which see. */
810
svn_io_file_write_full (apr_file_t *file, const void *buf,
811
apr_size_t nbytes, apr_size_t *bytes_written,
815
/** Wrapper for @c apr_stat(), which see. @a fname is utf8-encoded. */
817
svn_io_stat (apr_finfo_t *finfo, const char *fname,
818
apr_int32_t wanted, apr_pool_t *pool);
821
/** Wrapper for @c apr_file_rename(), which see. @a from_path and @a to_path
825
svn_io_file_rename (const char *from_path, const char *to_path,
829
/** Wrapper for @c apr_dir_make(), which see. @a path is utf8-encoded. */
831
svn_io_dir_make (const char *path, apr_fileperms_t perm, apr_pool_t *pool);
833
/** Same as svn_io_dir_make, but sets the hidden attribute on the
834
directory on systems that support it. */
836
svn_io_dir_make_hidden (const char *path, apr_fileperms_t perm,
842
* Same as svn_io_dir_make, but attempts to set the sgid on the
843
* directory on systems that support it. Does not return an error if
844
* the attempt to set the sgid bit fails. On Unix filesystems,
845
* setting the sgid bit on a directory ensures that files and
846
* subdirectories created within inherit group ownership from the
847
* parent instead of from the primary gid. */
849
svn_io_dir_make_sgid (const char *path, apr_fileperms_t perm,
852
/** Wrapper for @c apr_dir_open(), which see. @a dirname is utf8-encoded. */
854
svn_io_dir_open (apr_dir_t **new_dir, const char *dirname, apr_pool_t *pool);
857
/** Wrapper for @c apr_dir_remove(), which see. @a dirname is utf8-encoded.
858
* Note: this function has this name to avoid confusion with
859
* @c svn_io_remove_dir, which is recursive.
862
svn_io_dir_remove_nonrecursive (const char *dirname, apr_pool_t *pool);
865
/** Wrapper for @c apr_dir_read, which see. Ensures that @a finfo->name is
866
* utf8-encoded, which means allocating @a finfo->name in @a pool, which may
867
* or may not be the same as @a finfo's pool. Use @a pool for error allocation
871
svn_io_dir_read (apr_finfo_t *finfo,
878
/** Version/format files.
880
* @defgroup svn_io_format_files version/format files
884
/** Set @a *version to the integer that starts the file at @a path. If the
885
* file does not begin with a series of digits followed by a newline,
886
* return the error @c SVN_ERR_BAD_VERSION_FILE_FORMAT. Use @a pool for
890
svn_io_read_version_file (int *version, const char *path, apr_pool_t *pool);
892
/** Create (or overwrite) the file at @a path with new contents,
893
* formatted as a non-negative integer @a version followed by a single
894
* newline. On successful completion the file will be read-only. Use
895
* @a pool for all allocations.
898
svn_io_write_version_file (const char *path, int version, apr_pool_t *pool);
904
#endif /* __cplusplus */
906
#endif /* SVN_IO_H */