#include <apr.h>
#include <apr_pools.h>
#include <apr_file_io.h>
#include <apr_thread_proc.h>
#include "svn_types.h"
#include "svn_error.h"
#include "svn_string.h"
Go to the source code of this file.
Data Structures | |
struct | svn_io_dirent_t |
Represents the kind and special status of a directory entry. More... | |
Typedefs | |
typedef svn_stream_t | svn_stream_t |
An abstract stream of bytes--either incoming or outgoing or both. | |
typedef svn_error_t *(*) | svn_read_fn_t (void *baton, char *buffer, apr_size_t *len) |
Read handler function for a generic stream. | |
typedef svn_error_t *(*) | svn_write_fn_t (void *baton, const char *data, apr_size_t *len) |
Write handler function for a generic stream. | |
typedef svn_error_t *(*) | svn_close_fn_t (void *baton) |
Close handler function for a generic stream. | |
typedef svn_error_t *(*) | svn_io_walk_func_t (void *baton, const char *path, const apr_finfo_t *finfo, apr_pool_t *pool) |
Callback function type for svn_io_dir_walk(). | |
Functions | |
svn_error_t * | svn_io_check_path (const char *path, svn_node_kind_t *kind, apr_pool_t *pool) |
Determine the kind of path. | |
svn_error_t * | svn_io_check_special_path (const char *path, svn_node_kind_t *kind, svn_boolean_t *is_special, apr_pool_t *pool) |
Like svn_io_check_path(), but also set *is_special to TRUE if the path is not a normal file. | |
svn_error_t * | svn_io_check_resolved_path (const char *path, svn_node_kind_t *kind, apr_pool_t *pool) |
Like svn_io_check_path(), but resolve symlinks. | |
svn_error_t * | svn_io_open_unique_file (apr_file_t **f, const char **unique_name_p, const char *path, const char *suffix, svn_boolean_t delete_on_close, apr_pool_t *pool) |
Open a new file (for writing) with a unique name based on utf-8 encoded path, in the same directory as path. | |
svn_error_t * | svn_io_create_unique_link (const char **unique_name_p, const char *path, const char *dest, const char *suffix, apr_pool_t *pool) |
Like svn_io_open_unique_file(), except that instead of creating a file, a symlink is generated that references the path dest. | |
svn_error_t * | svn_io_read_link (svn_string_t **dest, const char *path, apr_pool_t *pool) |
Set *dest to the path that the symlink at path references. | |
svn_error_t * | svn_io_temp_dir (const char **dir, apr_pool_t *pool) |
Set *dir to a directory path (allocated in pool) deemed usable for the creation of temporary files and subdirectories. | |
svn_error_t * | svn_io_copy_file (const char *src, const char *dst, svn_boolean_t copy_perms, apr_pool_t *pool) |
Copy src to dst atomically. | |
svn_error_t * | svn_io_copy_link (const char *src, const char *dst, apr_pool_t *pool) |
Copy symbolic link src to dst atomically. | |
svn_error_t * | svn_io_copy_dir_recursively (const char *src, const char *dst_parent, const char *dst_basename, svn_boolean_t copy_perms, svn_cancel_func_t cancel_func, void *cancel_baton, apr_pool_t *pool) |
Recursively copy directory src into dst_parent, as a new entry named dst_basename. | |
svn_error_t * | svn_io_make_dir_recursively (const char *path, apr_pool_t *pool) |
Create directory path on the file system, creating intermediate directories as required, like mkdir -p . | |
svn_error_t * | svn_io_dir_empty (svn_boolean_t *is_empty_p, const char *path, apr_pool_t *pool) |
Set *is_empty_p to TRUE if directory path is empty, else to FALSE if it is not empty. | |
svn_error_t * | svn_io_append_file (const char *src, const char *dst, apr_pool_t *pool) |
Append src to dst. | |
svn_error_t * | svn_io_set_file_read_only (const char *path, svn_boolean_t ignore_enoent, apr_pool_t *pool) |
Make a file as read-only as the operating system allows. | |
svn_error_t * | svn_io_set_file_read_write (const char *path, svn_boolean_t ignore_enoent, apr_pool_t *pool) |
Make a file as writable as the operating system allows. | |
svn_error_t * | svn_io_set_file_read_write_carefully (const char *path, svn_boolean_t enable_write, svn_boolean_t ignore_enoent, apr_pool_t *pool) |
Minimally change the read-write permissions of a file. | |
svn_error_t * | svn_io_set_file_executable (const char *path, svn_boolean_t executable, svn_boolean_t ignore_enoent, apr_pool_t *pool) |
Toggle a file's "executability". | |
svn_error_t * | svn_io_is_file_executable (svn_boolean_t *executable, const char *path, apr_pool_t *pool) |
Determine whether a file is executable by the current user. | |
svn_error_t * | svn_io_read_length_line (apr_file_t *file, char *buf, apr_size_t *limit, apr_pool_t *pool) |
Read a line from file into buf, but not exceeding *limit bytes. | |
svn_error_t * | svn_io_file_affected_time (apr_time_t *apr_time, const char *path, apr_pool_t *pool) |
Set *apr_time to the time of last modification of the contents of the file path. | |
svn_error_t * | svn_io_set_file_affected_time (apr_time_t apr_time, const char *path, apr_pool_t *pool) |
Set the timestamp of file path to apr_time. | |
svn_error_t * | svn_io_filesizes_different_p (svn_boolean_t *different_p, const char *file1, const char *file2, apr_pool_t *pool) |
Set *different_p to non-zero if file1 and file2 have different sizes, else set to zero. | |
svn_error_t * | svn_io_file_checksum (unsigned char digest[], const char *file, apr_pool_t *pool) |
Put the md5 checksum of file into digest. | |
svn_error_t * | svn_io_files_contents_same_p (svn_boolean_t *same, const char *file1, const char *file2, apr_pool_t *pool) |
Set *same to non-zero if file1 and file2 have the same contents, else set it to zero. | |
svn_error_t * | svn_io_file_create (const char *file, const char *contents, apr_pool_t *pool) |
Create file at file with contents contents. | |
svn_error_t * | svn_io_file_lock (const char *lock_file, svn_boolean_t exclusive, apr_pool_t *pool) |
Lock file at lock_file. | |
svn_error_t * | svn_io_file_lock2 (const char *lock_file, svn_boolean_t exclusive, svn_boolean_t nonblocking, apr_pool_t *pool) |
Lock file at lock_file. | |
svn_error_t * | svn_io_file_flush_to_disk (apr_file_t *file, apr_pool_t *pool) |
Flush any unwritten data from file to disk. | |
svn_error_t * | svn_io_dir_file_copy (const char *src_path, const char *dest_path, const char *file, apr_pool_t *pool) |
Copy file file from location src_path to location dest_path. | |
svn_stream_t * | svn_stream_create (void *baton, apr_pool_t *pool) |
Creating a generic stream. | |
void | svn_stream_set_baton (svn_stream_t *stream, void *baton) |
Set stream's baton to baton. | |
void | svn_stream_set_read (svn_stream_t *stream, svn_read_fn_t read_fn) |
Set stream's read function to read_fn. | |
void | svn_stream_set_write (svn_stream_t *stream, svn_write_fn_t write_fn) |
Set stream's write function to write_fn. | |
void | svn_stream_set_close (svn_stream_t *stream, svn_close_fn_t close_fn) |
Set stream's close function to close_fn. | |
svn_stream_t * | svn_stream_empty (apr_pool_t *pool) |
Convenience function to create a generic stream which is empty. | |
svn_stream_t * | svn_stream_from_aprfile (apr_file_t *file, apr_pool_t *pool) |
Convenience function for creating streams which operate on APR files. | |
svn_error_t * | svn_stream_for_stdout (svn_stream_t **out, apr_pool_t *pool) |
Set *out to a generic stream connected to stdout, allocated in pool. | |
svn_stream_t * | svn_stream_from_stringbuf (svn_stringbuf_t *str, apr_pool_t *pool) |
Return a generic stream connected to stringbuf str. | |
svn_stream_t * | svn_stream_compressed (svn_stream_t *stream, apr_pool_t *pool) |
Return a stream that decompresses all data read and compresses all data written. | |
svn_error_t * | svn_stream_read (svn_stream_t *stream, char *buffer, apr_size_t *len) |
Read from a generic stream. | |
svn_error_t * | svn_stream_write (svn_stream_t *stream, const char *data, apr_size_t *len) |
Write to a generic stream. | |
svn_error_t * | svn_stream_close (svn_stream_t *stream) |
Close a generic stream. | |
svn_error_t * | svn_stream_printf (svn_stream_t *stream, apr_pool_t *pool, const char *fmt,...) |
Write to stream using a printf-style fmt specifier, passed through apr_psprintf() using memory from pool. | |
svn_error_t * | svn_stream_printf_from_utf8 (svn_stream_t *stream, const char *encoding, apr_pool_t *pool, const char *fmt,...) |
Write to stream using a printf-style fmt specifier, passed through apr_psprintf() using memory from pool. | |
svn_error_t * | svn_stream_readline (svn_stream_t *stream, svn_stringbuf_t **stringbuf, const char *eol, svn_boolean_t *eof, apr_pool_t *pool) |
Allocate *stringbuf in pool, and read into it one line (terminated by eol) from stream. | |
svn_error_t * | svn_stream_copy (svn_stream_t *from, svn_stream_t *to, apr_pool_t *pool) |
Read the contents of the readable stream from and write them to the writable stream to. | |
svn_error_t * | svn_stringbuf_from_file (svn_stringbuf_t **result, const char *filename, apr_pool_t *pool) |
Sets *result to a string containing the contents of filename, a utf8-encoded path. | |
svn_error_t * | svn_stringbuf_from_aprfile (svn_stringbuf_t **result, apr_file_t *file, apr_pool_t *pool) |
Sets *result to a string containing the contents of the already opened file. | |
svn_error_t * | svn_io_remove_file (const char *path, apr_pool_t *pool) |
Remove file path, a utf8-encoded path. | |
svn_error_t * | svn_io_remove_dir (const char *path, apr_pool_t *pool) |
Recursively remove directory path. | |
svn_error_t * | svn_io_get_dirents2 (apr_hash_t **dirents, const char *path, apr_pool_t *pool) |
Read all of the disk entries in directory path, a utf8-encoded path. | |
svn_error_t * | svn_io_get_dirents (apr_hash_t **dirents, const char *path, apr_pool_t *pool) |
similar to svn_io_get_dirents2(), but *DIRENTS is a hash table with svn_node_kind_t values. | |
svn_error_t * | svn_io_dir_walk (const char *dirname, apr_int32_t wanted, svn_io_walk_func_t walk_func, void *walk_baton, apr_pool_t *pool) |
This function will recursively walk over the files and directories rooted at dirname, a utf8-encoded path. | |
svn_error_t * | svn_io_start_cmd (apr_proc_t *cmd_proc, const char *path, const char *cmd, const char *const *args, svn_boolean_t inherit, apr_file_t *infile, apr_file_t *outfile, apr_file_t *errfile, apr_pool_t *pool) |
Start cmd with args, using utf8-encoded path as working directory. | |
svn_error_t * | svn_io_wait_for_cmd (apr_proc_t *cmd_proc, const char *cmd, int *exitcode, apr_exit_why_e *exitwhy, apr_pool_t *pool) |
Wait for the process *cmd_proc to complete and optionally retrieve its exit code. | |
svn_error_t * | svn_io_run_cmd (const char *path, const char *cmd, const char *const *args, int *exitcode, apr_exit_why_e *exitwhy, svn_boolean_t inherit, apr_file_t *infile, apr_file_t *outfile, apr_file_t *errfile, apr_pool_t *pool) |
Run a command to completion, by first calling svn_io_start_cmd() and then calling svn_io_wait_for_cmd(). | |
svn_error_t * | svn_io_run_diff (const char *dir, const char *const *user_args, int num_user_args, const char *label1, const char *label2, const char *from, const char *to, int *exitcode, apr_file_t *outfile, apr_file_t *errfile, const char *diff_cmd, apr_pool_t *pool) |
Invoke the configured diff program, with user_args (an array of utf8-encoded num_user_args arguments), if they are specified, or "-u" if they are not. | |
svn_error_t * | svn_io_run_diff3 (const char *dir, const char *mine, const char *older, const char *yours, const char *mine_label, const char *older_label, const char *yours_label, apr_file_t *merged, int *exitcode, const char *diff3_cmd, apr_pool_t *pool) |
Invoke the configured diff3 program, in utf8-encoded dir like this:. | |
svn_error_t * | svn_io_detect_mimetype (const char **mimetype, const char *file, apr_pool_t *pool) |
Examine utf8-encoded file to determine if it can be described by a known (as in, known by this function) Multipurpose Internet Mail Extension (MIME) type. | |
svn_error_t * | svn_io_file_open (apr_file_t **new_file, const char *fname, apr_int32_t flag, apr_fileperms_t perm, apr_pool_t *pool) |
Wrapper for apr_file_open(), which see. | |
svn_error_t * | svn_io_file_close (apr_file_t *file, apr_pool_t *pool) |
Wrapper for apr_file_close(), which see. | |
svn_error_t * | svn_io_file_getc (char *ch, apr_file_t *file, apr_pool_t *pool) |
Wrapper for apr_file_getc(), which see. | |
svn_error_t * | svn_io_file_info_get (apr_finfo_t *finfo, apr_int32_t wanted, apr_file_t *file, apr_pool_t *pool) |
Wrapper for apr_file_info_get(), which see. | |
svn_error_t * | svn_io_file_read (apr_file_t *file, void *buf, apr_size_t *nbytes, apr_pool_t *pool) |
Wrapper for apr_file_read(), which see. | |
svn_error_t * | svn_io_file_read_full (apr_file_t *file, void *buf, apr_size_t nbytes, apr_size_t *bytes_read, apr_pool_t *pool) |
Wrapper for apr_file_read_full(), which see. | |
svn_error_t * | svn_io_file_seek (apr_file_t *file, apr_seek_where_t where, apr_off_t *offset, apr_pool_t *pool) |
Wrapper for apr_file_seek(), which see. | |
svn_error_t * | svn_io_file_write (apr_file_t *file, const void *buf, apr_size_t *nbytes, apr_pool_t *pool) |
Wrapper for apr_file_write(), which see. | |
svn_error_t * | svn_io_file_write_full (apr_file_t *file, const void *buf, apr_size_t nbytes, apr_size_t *bytes_written, apr_pool_t *pool) |
Wrapper for apr_file_write_full(), which see. | |
svn_error_t * | svn_io_stat (apr_finfo_t *finfo, const char *fname, apr_int32_t wanted, apr_pool_t *pool) |
Wrapper for apr_stat(), which see. | |
svn_error_t * | svn_io_file_rename (const char *from_path, const char *to_path, apr_pool_t *pool) |
Wrapper for apr_file_rename(), which see. | |
svn_error_t * | svn_io_file_move (const char *from_path, const char *to_path, apr_pool_t *pool) |
Move the file from from_path to to_path. | |
svn_error_t * | svn_io_dir_make (const char *path, apr_fileperms_t perm, apr_pool_t *pool) |
Wrapper for apr_dir_make(), which see. | |
svn_error_t * | svn_io_dir_make_hidden (const char *path, apr_fileperms_t perm, apr_pool_t *pool) |
Same as svn_io_dir_make(), but sets the hidden attribute on the directory on systems that support it. | |
svn_error_t * | svn_io_dir_make_sgid (const char *path, apr_fileperms_t perm, apr_pool_t *pool) |
Same as svn_io_dir_make(), but attempts to set the sgid on the directory on systems that support it. | |
svn_error_t * | svn_io_dir_open (apr_dir_t **new_dir, const char *dirname, apr_pool_t *pool) |
Wrapper for apr_dir_open(), which see. | |
svn_error_t * | svn_io_dir_remove_nonrecursive (const char *dirname, apr_pool_t *pool) |
Wrapper for apr_dir_remove(), which see. | |
svn_error_t * | svn_io_dir_read (apr_finfo_t *finfo, apr_int32_t wanted, apr_dir_t *thedir, apr_pool_t *pool) |
Wrapper for apr_dir_read(), which see. | |
svn_error_t * | svn_io_read_version_file (int *version, const char *path, apr_pool_t *pool) |
Set *version to the integer that starts the file at path. | |
svn_error_t * | svn_io_write_version_file (const char *path, int version, apr_pool_t *pool) |
Create (or overwrite) the file at path with new contents, formatted as a non-negative integer version followed by a single newline. |
Definition in file svn_io.h.
svn_error_t* svn_io_append_file | ( | const char * | src, | |
const char * | dst, | |||
apr_pool_t * | pool | |||
) |
Append src to dst.
dst will be appended to if it exists, else it will be created. Both src and dst are utf8-encoded.
svn_error_t* svn_io_check_path | ( | const char * | path, | |
svn_node_kind_t * | kind, | |||
apr_pool_t * | pool | |||
) |
Determine the kind of path.
If utf8-encoded path exists, set *kind to the appropriate kind, else set it to svn_node_unknown
.
If path is a file, *kind is set to svn_node_file
.
If path is a directory, *kind is set to svn_node_dir
.
If path does not exist in its final component, *kind is set to svn_node_none
.
If intermediate directories on the way to path don't exist, an error is returned, and *kind's value is undefined.
svn_error_t* svn_io_check_resolved_path | ( | const char * | path, | |
svn_node_kind_t * | kind, | |||
apr_pool_t * | pool | |||
) |
Like svn_io_check_path(), but resolve symlinks.
This returns the same varieties of kind as svn_io_check_path().
svn_error_t* svn_io_check_special_path | ( | const char * | path, | |
svn_node_kind_t * | kind, | |||
svn_boolean_t * | is_special, | |||
apr_pool_t * | pool | |||
) |
Like svn_io_check_path(), but also set *is_special to TRUE
if the path is not a normal file.
svn_error_t* svn_io_copy_dir_recursively | ( | const char * | src, | |
const char * | dst_parent, | |||
const char * | dst_basename, | |||
svn_boolean_t | copy_perms, | |||
svn_cancel_func_t | cancel_func, | |||
void * | cancel_baton, | |||
apr_pool_t * | pool | |||
) |
Recursively copy directory src into dst_parent, as a new entry named dst_basename.
If dst_basename already exists in dst_parent, return error. copy_perms will be passed through to svn_io_copy_file() when any files are copied. src, dst_parent, and dst_basename are all utf8-encoded.
If cancel_func is non-null, invoke it with cancel_baton at various points during the operation. If it returns any error (typically SVN_ERR_CANCELLED
), return that error immediately.
svn_error_t* svn_io_copy_file | ( | const char * | src, | |
const char * | dst, | |||
svn_boolean_t | copy_perms, | |||
apr_pool_t * | pool | |||
) |
Copy src to dst atomically.
Overwrite dst if it exists, else create it. Both src and dst are utf8-encoded filenames. If copy_perms is true, set dst's permissions to match those of src.
svn_error_t* svn_io_copy_link | ( | const char * | src, | |
const char * | dst, | |||
apr_pool_t * | pool | |||
) |
Copy symbolic link src to dst atomically.
Overwrite dst if it exists, else create it. Both src and dst are utf8-encoded filenames. After copying, the dst link will point to the same thing src does.
svn_error_t* svn_io_create_unique_link | ( | const char ** | unique_name_p, | |
const char * | path, | |||
const char * | dest, | |||
const char * | suffix, | |||
apr_pool_t * | pool | |||
) |
Like svn_io_open_unique_file(), except that instead of creating a file, a symlink is generated that references the path dest.
svn_error_t* svn_io_detect_mimetype | ( | const char ** | mimetype, | |
const char * | file, | |||
apr_pool_t * | pool | |||
) |
Examine utf8-encoded file to determine if it can be described by a known (as in, known by this function) Multipurpose Internet Mail Extension (MIME) type.
If so, set *mimetype to a character string describing the MIME type, else set it to NULL
. Use pool for any necessary allocations.
svn_error_t* svn_io_dir_empty | ( | svn_boolean_t * | is_empty_p, | |
const char * | path, | |||
apr_pool_t * | pool | |||
) |
Set *is_empty_p to TRUE
if directory path is empty, else to FALSE
if it is not empty.
path must be a directory, and is utf8-encoded. Use pool for temporary allocation.
svn_error_t* svn_io_dir_file_copy | ( | const char * | src_path, | |
const char * | dest_path, | |||
const char * | file, | |||
apr_pool_t * | pool | |||
) |
Copy file file from location src_path to location dest_path.
Use pool for memory allocations.
svn_error_t* svn_io_dir_make | ( | const char * | path, | |
apr_fileperms_t | perm, | |||
apr_pool_t * | pool | |||
) |
Wrapper for apr_dir_make(), which see.
path is utf8-encoded.
svn_error_t* svn_io_dir_make_sgid | ( | const char * | path, | |
apr_fileperms_t | perm, | |||
apr_pool_t * | pool | |||
) |
Same as svn_io_dir_make(), but attempts to set the sgid on the directory on systems that support it.
Does not return an error if the attempt to set the sgid bit fails. On Unix filesystems, setting the sgid bit on a directory ensures that files and subdirectories created within inherit group ownership from the parent instead of from the primary gid.
svn_error_t* svn_io_dir_open | ( | apr_dir_t ** | new_dir, | |
const char * | dirname, | |||
apr_pool_t * | pool | |||
) |
Wrapper for apr_dir_open(), which see.
dirname is utf8-encoded.
svn_error_t* svn_io_dir_read | ( | apr_finfo_t * | finfo, | |
apr_int32_t | wanted, | |||
apr_dir_t * | thedir, | |||
apr_pool_t * | pool | |||
) |
Wrapper for apr_dir_read(), which see.
Ensures that finfo->name is utf8-encoded, which means allocating finfo->name in pool, which may or may not be the same as finfo's pool. Use pool for error allocation as well.
svn_error_t* svn_io_dir_remove_nonrecursive | ( | const char * | dirname, | |
apr_pool_t * | pool | |||
) |
Wrapper for apr_dir_remove(), which see.
dirname is utf8-encoded.
svn_error_t* svn_io_dir_walk | ( | const char * | dirname, | |
apr_int32_t | wanted, | |||
svn_io_walk_func_t | walk_func, | |||
void * | walk_baton, | |||
apr_pool_t * | pool | |||
) |
This function will recursively walk over the files and directories rooted at dirname, a utf8-encoded path.
For each file or directory, walk_func is invoked, passing in the walk_baton, the utf8-encoded full path to the entry, an apr_finfo_t
structure, and a temporary pool for allocations. For any directory, walk_func will be invoked on the directory itself before being invoked on any subdirectories or files within the directory.
The set of information passed to walk_func is specified by wanted, and the items specified by APR_FINFO_TYPE
and APR_FINFO_NAME
.
All allocations will be performed in pool.
svn_error_t* svn_io_file_affected_time | ( | apr_time_t * | apr_time, | |
const char * | path, | |||
apr_pool_t * | pool | |||
) |
Set *apr_time to the time of last modification of the contents of the file path.
path is utf8-encoded.
svn_error_t* svn_io_file_checksum | ( | unsigned char | digest[], | |
const char * | file, | |||
apr_pool_t * | pool | |||
) |
Put the md5 checksum of file into digest.
digest points to APR_MD5_DIGESTSIZE
bytes of storage. Use pool only for temporary allocations.
svn_error_t* svn_io_file_create | ( | const char * | file, | |
const char * | contents, | |||
apr_pool_t * | pool | |||
) |
Create file at file with contents contents.
will be created. Path file is utf8-encoded. Use pool for memory allocations.
svn_error_t* svn_io_file_flush_to_disk | ( | apr_file_t * | file, | |
apr_pool_t * | pool | |||
) |
Flush any unwritten data from file to disk.
Use pool for memory allocations.
svn_error_t* svn_io_file_lock | ( | const char * | lock_file, | |
svn_boolean_t | exclusive, | |||
apr_pool_t * | pool | |||
) |
Lock file at lock_file.
If exclusive is TRUE, obtain exclusive lock, otherwise obtain shared lock. Lock will be automatically released when pool is cleared or destroyed. Use pool for memory allocations.
svn_error_t* svn_io_file_lock2 | ( | const char * | lock_file, | |
svn_boolean_t | exclusive, | |||
svn_boolean_t | nonblocking, | |||
apr_pool_t * | pool | |||
) |
Lock file at lock_file.
If exclusive is TRUE, obtain exclusive lock, otherwise obtain shared lock.
If nonblocking is TRUE, do not wait for the lock if it is not available: throw an error instead.
Lock will be automatically released when pool is cleared or destroyed. Use pool for memory allocations.
svn_error_t* svn_io_file_move | ( | const char * | from_path, | |
const char * | to_path, | |||
apr_pool_t * | pool | |||
) |
Move the file from from_path to to_path.
Overwrite to_path if it exists.
svn_error_t* svn_io_file_open | ( | apr_file_t ** | new_file, | |
const char * | fname, | |||
apr_int32_t | flag, | |||
apr_fileperms_t | perm, | |||
apr_pool_t * | pool | |||
) |
Wrapper for apr_file_open(), which see.
fname is utf8-encoded.
svn_error_t* svn_io_file_rename | ( | const char * | from_path, | |
const char * | to_path, | |||
apr_pool_t * | pool | |||
) |
Wrapper for apr_file_rename(), which see.
from_path and to_path are utf8-encoded.
svn_error_t* svn_io_files_contents_same_p | ( | svn_boolean_t * | same, | |
const char * | file1, | |||
const char * | file2, | |||
apr_pool_t * | pool | |||
) |
Set *same to non-zero if file1 and file2 have the same contents, else set it to zero.
Use pool for temporary allocations.
svn_error_t* svn_io_filesizes_different_p | ( | svn_boolean_t * | different_p, | |
const char * | file1, | |||
const char * | file2, | |||
apr_pool_t * | pool | |||
) |
Set *different_p to non-zero if file1 and file2 have different sizes, else set to zero.
Both file1 and file2 are utf8-encoded.
Setting *different_p to zero does not mean the files definitely have the same size, it merely means that the sizes are not definitely different. That is, if the size of one or both files cannot be determined, then the sizes are not known to be different, so *different_p is set to 0.
svn_error_t* svn_io_get_dirents | ( | apr_hash_t ** | dirents, | |
const char * | path, | |||
apr_pool_t * | pool | |||
) |
similar to svn_io_get_dirents2(), but *DIRENTS is a hash table with svn_node_kind_t
values.
svn_error_t* svn_io_get_dirents2 | ( | apr_hash_t ** | dirents, | |
const char * | path, | |||
apr_pool_t * | pool | |||
) |
Read all of the disk entries in directory path, a utf8-encoded path.
Set *dirents to a hash mapping dirent names (char *
) to svn_io_dirent_t
structures, allocated in pool.
svn_error_t* svn_io_is_file_executable | ( | svn_boolean_t * | executable, | |
const char * | path, | |||
apr_pool_t * | pool | |||
) |
Determine whether a file is executable by the current user.
Set *executable to TRUE
if the file path is executable by the current user, otherwise set it to FALSE
.
On Windows and on platforms without userids, always returns FALSE
.
svn_error_t* svn_io_make_dir_recursively | ( | const char * | path, | |
apr_pool_t * | pool | |||
) |
Create directory path on the file system, creating intermediate directories as required, like mkdir -p
.
Report no error if path already exists. path is utf8-encoded.
This is essentially a wrapper for apr_dir_make_recursive(), passing APR_OS_DEFAULT
as the permissions.
svn_error_t* svn_io_open_unique_file | ( | apr_file_t ** | f, | |
const char ** | unique_name_p, | |||
const char * | path, | |||
const char * | suffix, | |||
svn_boolean_t | delete_on_close, | |||
apr_pool_t * | pool | |||
) |
Open a new file (for writing) with a unique name based on utf-8 encoded path, in the same directory as path.
The file handle is returned in *f, and the name, which ends with suffix, is returned in *unique_name_p, also utf8-encoded. If delete_on_close is set, then the APR_DELONCLOSE
flag will be used when opening the file. The APR_BUFFERED
flag will always be used.
The first attempt will just append suffix. If the result is not a unique name, then subsequent attempts will append a dot, followed by an iteration number ("2", then "3", and so on), followed by the suffix. For example, if path is
tests/t1/A/D/G/pi
then successive calls to
svn_io_open_unique_file(&f, &unique_name, path, ".tmp", pool)
will open
tests/t1/A/D/G/pi.tmp tests/t1/A/D/G/pi.2.tmp tests/t1/A/D/G/pi.3.tmp tests/t1/A/D/G/pi.4.tmp tests/t1/A/D/G/pi.5.tmp ...
*unique_name_p will never be exactly the same as path, even if path does not exist.
It doesn't matter if path is a file or directory, the unique name will be in path's parent either way.
Allocate *f and *unique_name_p in pool.
If no unique name can be found, SVN_ERR_IO_UNIQUE_NAMES_EXHAUSTED
is the error returned.
Claim of Historical Inevitability: this function was written because
svn_error_t* svn_io_read_length_line | ( | apr_file_t * | file, | |
char * | buf, | |||
apr_size_t * | limit, | |||
apr_pool_t * | pool | |||
) |
Read a line from file into buf, but not exceeding *limit bytes.
Does not include newline, instead '\0' is put there. Length (as in strlen) is returned in *limit. buf should be pre-allocated. file should be already opened.
When the file is out of lines, APR_EOF
will be returned.
svn_error_t* svn_io_read_link | ( | svn_string_t ** | dest, | |
const char * | path, | |||
apr_pool_t * | pool | |||
) |
Set *dest to the path that the symlink at path references.
Allocate the string from pool.
svn_error_t* svn_io_remove_dir | ( | const char * | path, | |
apr_pool_t * | pool | |||
) |
Recursively remove directory path.
path is utf8-encoded.
svn_error_t* svn_io_remove_file | ( | const char * | path, | |
apr_pool_t * | pool | |||
) |
Remove file path, a utf8-encoded path.
This wraps apr_file_remove(), converting any error to a Subversion error.
svn_error_t* svn_io_run_cmd | ( | const char * | path, | |
const char * | cmd, | |||
const char *const * | args, | |||
int * | exitcode, | |||
apr_exit_why_e * | exitwhy, | |||
svn_boolean_t | inherit, | |||
apr_file_t * | infile, | |||
apr_file_t * | outfile, | |||
apr_file_t * | errfile, | |||
apr_pool_t * | pool | |||
) |
Run a command to completion, by first calling svn_io_start_cmd() and then calling svn_io_wait_for_cmd().
The parameters correspond to the the same-named parameters of those two functions.
svn_error_t* svn_io_run_diff | ( | const char * | dir, | |
const char *const * | user_args, | |||
int | num_user_args, | |||
const char * | label1, | |||
const char * | label2, | |||
const char * | from, | |||
const char * | to, | |||
int * | exitcode, | |||
apr_file_t * | outfile, | |||
apr_file_t * | errfile, | |||
const char * | diff_cmd, | |||
apr_pool_t * | pool | |||
) |
Invoke the
configured diff program, with user_args (an array of utf8-encoded num_user_args arguments), if they are specified, or "-u" if they are not.
Diff runs in utf8-encoded dir, and its exit status is stored in exitcode, if it is not NULL
.
If label1 and/or label2 are not null they will be passed to the diff process as the arguments of "-L" options. label1 and label2 are also in utf8, and will be converted to native charset along with the other args.
from is the first file passed to diff, and to is the second. The stdout of diff will be sent to outfile, and the stderr to errfile.
diff_cmd must be non-null.
Do all allocation in pool.
svn_error_t* svn_io_run_diff3 | ( | const char * | dir, | |
const char * | mine, | |||
const char * | older, | |||
const char * | yours, | |||
const char * | mine_label, | |||
const char * | older_label, | |||
const char * | yours_label, | |||
apr_file_t * | merged, | |||
int * | exitcode, | |||
const char * | diff3_cmd, | |||
apr_pool_t * | pool | |||
) |
Invoke the
configured diff3 program, in utf8-encoded dir like this:.
diff3 -Em mine older yours > merged
(See the diff3 documentation for details.)
mine, older, and yours are utf8-encoded paths, relative to dir, to three files that already exist. merged is an open file handle, and is left open after the merge result is written to it. (merged should *not* be the same file as mine, or nondeterministic things may happen!)
mine_label, older_label, yours_label are utf8-encoded label parameters for diff3's -L option. Any of them may be NULL
, in which case the corresponding mine, older, or yours parameter is used instead.
Set *exitcode to diff3's exit status. If *exitcode is anything other than 0 or 1, then return SVN_ERR_EXTERNAL_PROGRAM
. (Note the following from the diff3 info pages: "An exit status of 0 means `diff3' was successful, 1 means some conflicts were found, and 2 means trouble.")
diff3_cmd must be non-null.
Do all allocation in pool.
svn_error_t* svn_io_set_file_affected_time | ( | apr_time_t | apr_time, | |
const char * | path, | |||
apr_pool_t * | pool | |||
) |
Set the timestamp of file path to apr_time.
path is utf8-encoded.
svn_error_t* svn_io_set_file_executable | ( | const char * | path, | |
svn_boolean_t | executable, | |||
svn_boolean_t | ignore_enoent, | |||
apr_pool_t * | pool | |||
) |
Toggle a file's "executability".
When making the file executable on operating systems with unix style permissions, never add an execute permission where there is not already a read permission: that is, only make the file executable for the user, group or world if the corresponding read permission is already set for user, group or world.
When making the file non-executable on operating systems with unix style permissions, remove all execute permissions.
On other operating systems, toggle the file's "executability" as much as the operating system allows.
path is the utf8-encoded path to the file. If executable is TRUE
, then make the file executable. If FALSE
, make in non-executable. If ignore_enoent is TRUE
, don't fail if the target file doesn't exist.
svn_error_t* svn_io_set_file_read_only | ( | const char * | path, | |
svn_boolean_t | ignore_enoent, | |||
apr_pool_t * | pool | |||
) |
Make a file as read-only as the operating system allows.
path is the utf8-encoded path to the file. If ignore_enoent is TRUE
, don't fail if the target file doesn't exist.
svn_error_t* svn_io_set_file_read_write | ( | const char * | path, | |
svn_boolean_t | ignore_enoent, | |||
apr_pool_t * | pool | |||
) |
Make a file as writable as the operating system allows.
path is the utf8-encoded path to the file. If ignore_enoent is TRUE
, don't fail if the target file doesn't exist.
svn_error_t* svn_io_set_file_read_write_carefully | ( | const char * | path, | |
svn_boolean_t | enable_write, | |||
svn_boolean_t | ignore_enoent, | |||
apr_pool_t * | pool | |||
) |
Minimally change the read-write permissions of a file.
When making the file read-only on operating systems with unix style permissions, remove all write permissions.
On other operating systems, toggle the file's "writability" as much as the operating system allows.
path is the utf8-encoded path to the file. If enable_write is TRUE
, then make the file read-write. If FALSE
, make it write-only. If ignore_enoent is TRUE
, don't fail if the target file doesn't exist.
svn_error_t* svn_io_start_cmd | ( | apr_proc_t * | cmd_proc, | |
const char * | path, | |||
const char * | cmd, | |||
const char *const * | args, | |||
svn_boolean_t | inherit, | |||
apr_file_t * | infile, | |||
apr_file_t * | outfile, | |||
apr_file_t * | errfile, | |||
apr_pool_t * | pool | |||
) |
Start cmd with args, using utf8-encoded path as working directory.
Connect cmd's stdin, stdout, and stderr to infile, outfile, and errfile, except where they are null. Return the process handle for the invoked program in *cmd_proc.
args is a list of utf8-encoded const char *
arguments, terminated by NULL
. args[0] is the name of the program, though it need not be the same as cmd.
inherit sets whether the invoked program shall inherit its environment or run "clean".
svn_error_t* svn_io_stat | ( | apr_finfo_t * | finfo, | |
const char * | fname, | |||
apr_int32_t | wanted, | |||
apr_pool_t * | pool | |||
) |
Wrapper for apr_stat(), which see.
fname is utf8-encoded.
svn_error_t* svn_io_wait_for_cmd | ( | apr_proc_t * | cmd_proc, | |
const char * | cmd, | |||
int * | exitcode, | |||
apr_exit_why_e * | exitwhy, | |||
apr_pool_t * | pool | |||
) |
Wait for the process *cmd_proc to complete and optionally retrieve its exit code.
cmd is used only in error messages.
If exitcode is not null, *exitcode will contain the exit code of the process upon return, and if exitwhy is not null, *exitwhy will indicate why the process terminated. If exitwhy is null, and the exit reason is not APR_PROC_CHECK_EXIT()
, or if exitcode is null and the exit code is non-zero, then an SVN_ERR_EXTERNAL_PROGRAM
error will be returned.
svn_error_t* svn_stringbuf_from_aprfile | ( | svn_stringbuf_t ** | result, | |
apr_file_t * | file, | |||
apr_pool_t * | pool | |||
) |
Sets *result to a string containing the contents of the already opened file.
Reads from the current position in file to the end. Does not close the file or reset the cursor position.
svn_error_t* svn_stringbuf_from_file | ( | svn_stringbuf_t ** | result, | |
const char * | filename, | |||
apr_pool_t * | pool | |||
) |
Sets *result to a string containing the contents of filename, a utf8-encoded path.
If filename is "-", return the error SVN_ERR_UNSUPPORTED_FEATURE
and don't touch *result.
### Someday, "-" will fill *result from stdin. The problem right now is that if the same command invokes the editor, stdin is crap, and the editor acts funny or dies outright. One solution is to disallow stdin reading and invoking the editor, but how to do that reliably?