📄 svn_io.h
字号:
apr_pool_t *pool);/** Set @a *apr_time to the time of last modification of the contents of the * file @a path. @a path is utf8-encoded. * * @note This is the APR mtime which corresponds to the traditional mtime * on Unix, and the last write time on Windows. */svn_error_t *svn_io_file_affected_time(apr_time_t *apr_time, const char *path, apr_pool_t *pool);/** Set the timestamp of file @a path to @a apr_time. @a path is * utf8-encoded. * * @note This is the APR mtime which corresponds to the traditional mtime * on Unix, and the last write time on Windows. */svn_error_t *svn_io_set_file_affected_time(apr_time_t apr_time, const char *path, apr_pool_t *pool);/** Set @a *different_p to non-zero if @a file1 and @a file2 have different * sizes, else set to zero. Both @a file1 and @a file2 are utf8-encoded. * * Setting @a *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 @a *different_p is set to 0. */svn_error_t *svn_io_filesizes_different_p(svn_boolean_t *different_p, const char *file1, const char *file2, apr_pool_t *pool);/** Put the md5 checksum of @a file into @a digest. * @a digest points to @c APR_MD5_DIGESTSIZE bytes of storage. * Use @a pool only for temporary allocations. */svn_error_t *svn_io_file_checksum(unsigned char digest[], const char *file, apr_pool_t *pool);/** Set @a *same to TRUE if @a file1 and @a file2 have the same * contents, else set it to FALSE. Use @a pool for temporary allocations. */svn_error_t *svn_io_files_contents_same_p(svn_boolean_t *same, const char *file1, const char *file2, apr_pool_t *pool);/** Create file at @a file with contents @a contents. * will be created. Path @a file is utf8-encoded. * Use @a pool for memory allocations. */svn_error_t *svn_io_file_create(const char *file, const char *contents, apr_pool_t *pool);/** * Lock file at @a lock_file. If @a exclusive is TRUE, * obtain exclusive lock, otherwise obtain shared lock. * Lock will be automatically released when @a pool is cleared or destroyed. * Use @a pool for memory allocations. * * @deprecated Provided for backward compatibility with the 1.0 API. */svn_error_t *svn_io_file_lock(const char *lock_file, svn_boolean_t exclusive, apr_pool_t *pool);/** * Lock file at @a lock_file. If @a exclusive is TRUE, * obtain exclusive lock, otherwise obtain shared lock. * * If @a nonblocking is TRUE, do not wait for the lock if it * is not available: throw an error instead. * * Lock will be automatically released when @a pool is cleared or destroyed. * Use @a pool for memory allocations. * * @since New in 1.1. */svn_error_t *svn_io_file_lock2(const char *lock_file, svn_boolean_t exclusive, svn_boolean_t nonblocking, apr_pool_t *pool);/** * Flush any unwritten data from @a file to disk. Use @a pool for * memory allocations. * * @since New in 1.1. */svn_error_t *svn_io_file_flush_to_disk(apr_file_t *file, apr_pool_t *pool);/** Copy file @a file from location @a src_path to location @a dest_path. * Use @a pool for memory allocations. */svn_error_t *svn_io_dir_file_copy(const char *src_path, const char *dest_path, const char *file, apr_pool_t *pool);/** Generic byte-streams * * @defgroup svn_io_byte_streams generic byte streams * @{ *//** An abstract stream of bytes--either incoming or outgoing or both. * * The creator of a stream sets functions to handle read and write. * Both of these handlers accept a baton whose value is determined at * stream creation time; this baton can point to a structure * containing data associated with the stream. If a caller attempts * to invoke a handler which has not been set, it will generate a * runtime assertion failure. The creator can also set a handler for * close requests so that it can flush buffered data or whatever; * if a close handler is not specified, a close request on the stream * will simply be ignored. Note that svn_stream_close() does not * deallocate the memory used to allocate the stream structure; free * the pool you created the stream in to free that memory. * * The read and write handlers accept length arguments via pointer. * On entry to the handler, the pointed-to value should be the amount * of data which can be read or the amount of data to write. When the * handler returns, the value is reset to the amount of data actually * read or written. Handlers are obliged to complete a read or write * to the maximum extent possible; thus, a short read with no * associated error implies the end of the input stream, and a short * write should never occur without an associated error. */typedef struct svn_stream_t svn_stream_t;/** Read handler function for a generic stream. @see svn_stream_t. */typedef svn_error_t *(*svn_read_fn_t)(void *baton, char *buffer, apr_size_t *len);/** Write handler function for a generic stream. @see svn_stream_t. */typedef svn_error_t *(*svn_write_fn_t)(void *baton, const char *data, apr_size_t *len);/** Close handler function for a generic stream. @see svn_stream_t. */typedef svn_error_t *(*svn_close_fn_t)(void *baton);/** Create a generic stream. @see svn_stream_t. */svn_stream_t *svn_stream_create(void *baton, apr_pool_t *pool);/** Set @a stream's baton to @a baton */void svn_stream_set_baton(svn_stream_t *stream, void *baton);/** Set @a stream's read function to @a read_fn */void svn_stream_set_read(svn_stream_t *stream, svn_read_fn_t read_fn);/** Set @a stream's write function to @a write_fn */void svn_stream_set_write(svn_stream_t *stream, svn_write_fn_t write_fn);/** Set @a stream's close function to @a close_fn */void svn_stream_set_close(svn_stream_t *stream, svn_close_fn_t close_fn);/** Create a stream that is empty for reading and infinite for writing. */svn_stream_t *svn_stream_empty(apr_pool_t *pool);/** Return a stream allocated in @a pool which forwards all requests * to @a stream. Destruction is explicitly excluded from forwarding. * * @see notes/destruction-of-stacked-resources * * @since New in 1.4. */svn_stream_t *svn_stream_disown(svn_stream_t *stream, apr_pool_t *pool);/** Create a stream from an APR file. For convenience, if @a file is * @c NULL, an empty stream created by svn_stream_empty() is returned. * * This function should normally be called with @a disown set to false, * in which case closing the stream will also close the underlying file. * * If @a disown is true, the stream will disown the underlying file, * meaning that svn_stream_close() will not close the file. * * @since New in 1.4. */svn_stream_t * svn_stream_from_aprfile2(apr_file_t *file, svn_boolean_t disown, apr_pool_t *pool);/** Similar to svn_stream_from_aprfile2(), except that the file will * always be disowned. * * @note The stream returned is not considered to "own" the underlying * file, meaning that svn_stream_close() on the stream will not * close the file. * * @deprecated Provided for backward compatibility with the 1.3 API. */svn_stream_t *svn_stream_from_aprfile(apr_file_t *file, apr_pool_t *pool);/** Set @a *out to a generic stream connected to stdout, allocated in * @a pool. The stream and its underlying APR handle will be closed * when @a pool is cleared or destroyed. */svn_error_t *svn_stream_for_stdout(svn_stream_t **out, apr_pool_t *pool);/** Return a generic stream connected to stringbuf @a str. Allocate the * stream in @a pool. */svn_stream_t *svn_stream_from_stringbuf(svn_stringbuf_t *str, apr_pool_t *pool);/** Return a stream that decompresses all data read and compresses all * data written. The stream @a stream is used to read and write all * compressed data. All compression data structures are allocated on * @a pool. If compression support is not compiled in then * svn_stream_compressed() returns @a stream unmodified. Make sure you * call svn_stream_close() on the stream returned by this function, * so that all data are flushed and cleaned up. */svn_stream_t *svn_stream_compressed(svn_stream_t *stream, apr_pool_t *pool);/** Return a stream that calculates checksums for all data read * and written. The stream @a stream is used to read and write all data. * The stream and the resulting digests are allocated in @a pool. * * When the stream is closed, @a read_digest and @a write_digest * are set to point to the resulting digests. * * Both @a read_digest and @a write_digest * can be @c NULL, in which case the respective checksum isn't calculated. * * If @a read_all is true, make sure that all data available on @a * stream is read (and checksummed) when the stream is closed. * * Read and write operations can be mixed without interfering. * * The @a stream passed into this function is closed when the created * stream is closed. * * @since New in 1.4. */svn_stream_t *svn_stream_checksummed(svn_stream_t *stream, const unsigned char **read_digest, const unsigned char **write_digest, svn_boolean_t read_all, apr_pool_t *pool);/** Read from a generic stream. @see svn_stream_t. */svn_error_t *svn_stream_read(svn_stream_t *stream, char *buffer, apr_size_t *len);/** Write to a generic stream. @see svn_stream_t. */svn_error_t *svn_stream_write(svn_stream_t *stream, const char *data, apr_size_t *len);/** Close a generic stream. @see svn_stream_t. */svn_error_t *svn_stream_close(svn_stream_t *stream);/** Write to @a stream using a printf-style @a fmt specifier, passed through * apr_psprintf() using memory from @a pool. */svn_error_t *svn_stream_printf(svn_stream_t *stream, apr_pool_t *pool, const char *fmt, ...) __attribute__ ((format(printf, 3, 4)));/** Write to @a stream using a printf-style @a fmt specifier, passed through * apr_psprintf() using memory from @a pool. The resulting string * will be translated to @a encoding before it is sent to @a stream. * * @note Use @c APR_LOCALE_CHARSET to translate to the encoding of the * current locale. * * @since New in 1.3. */svn_error_t *svn_stream_printf_from_utf8(svn_stream_t *stream, const char *encoding, apr_pool_t *pool, const char *fmt, ...) __attribute__ ((format(printf, 4, 5)));/** Allocate @a *stringbuf in @a pool, and read into it one line (terminated * by @a eol) from @a stream. The line-terminator is read from the stream, * but is not added to the end of the stringbuf. Instead, the stringbuf * ends with a usual '\\0'. * * If @a stream runs out of bytes before encountering a line-terminator, * then set @a *eof to @c TRUE, otherwise set @a *eof to FALSE. */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);/** * Read the contents of the readable stream @a from and write them to the * writable stream @a to. * * @since New in 1.1. */svn_error_t *svn_stream_copy(svn_stream_t *from, svn_stream_t *to, apr_pool_t *pool);/** Set @a *same to TRUE if @a stream1 and @a stream2 have the same * contents, else set it to FALSE. Use @a pool for temporary allocations. * * @since New in 1.4. */svn_error_t *svn_stream_contents_same(svn_boolean_t *same, svn_stream_t *stream1, svn_stream_t *stream2, apr_pool_t *pool);/** @} *//** Sets @a *result to a string containing the contents of @a filename, a * utf8-encoded path. * * If @a filename is "-", return the error @c SVN_ERR_UNSUPPORTED_FEATURE * and don't touch @a *result. * * ### Someday, "-" will fill @a *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? */svn_error_t *svn_stringbuf_from_file(svn_stringbuf_t **result, const char *filename, apr_pool_t *pool);/** Sets @a *result to a string containing the contents of the already opened * @a 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_aprfile(svn_stringbuf_t **result, apr_file_t *file, apr_pool_t *pool);/** Remove file @a path, a utf8-encoded path. This wraps apr_file_remove(), * converting any error to a Subversion error. */svn_error_t *svn_io_remove_file(const char *path, apr_pool_t *pool);/** Recursively remove directory @a path. @a path is utf8-encoded. */svn_error_t *svn_io_remove_dir(const char *path, apr_pool_t *pool);/** Read all of the disk entries in directory @a path, a utf8-encoded * path. Set @a *dirents to a hash mapping dirent names (<tt>char *</tt>) to * undefined non-NULL values, allocated in @a pool. * * @note The `.' and `..' directories normally returned by * apr_dir_read() are NOT returned in the hash. * * @since New in 1.4. */svn_error_t *svn_io_get_dir_filenames(apr_hash_t **dirents, const char *path, apr_pool_t *pool);/** Read all of the disk entries in directory @a path, a utf8-encoded
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -