3 * ====================================================================
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
20 * ====================================================================
23 * @file svn_io_private.h
24 * @brief Private IO API
27 #ifndef SVN_IO_PRIVATE_H
28 #define SVN_IO_PRIVATE_H
34 #endif /* __cplusplus */
36 /* The flags to pass to apr_stat to check for executable and/or readonly */
37 #if defined(WIN32) || defined(__OS2__)
38 #define SVN__APR_FINFO_EXECUTABLE (0)
39 #define SVN__APR_FINFO_READONLY (0)
40 #define SVN__APR_FINFO_MASK_OUT (APR_FINFO_PROT | APR_FINFO_OWNER)
42 #define SVN__APR_FINFO_EXECUTABLE (APR_FINFO_PROT)
43 #define SVN__APR_FINFO_READONLY (APR_FINFO_PROT | APR_FINFO_OWNER)
44 #define SVN__APR_FINFO_MASK_OUT (0)
47 /* 90% of the lines we encounter will be less than this many chars.
49 * Line-based functions like svn_stream_readline should fetch data in
50 * blocks no longer than this. Although using a larger prefetch size is
51 * not illegal and must not break any functionality, it may be
52 * significantly less efficient in certain situations.
54 #define SVN__LINE_CHUNK_SIZE 80
57 /** Set @a *executable TRUE if @a file_info is executable for the
58 * user, FALSE otherwise.
60 * Always returns FALSE on Windows or platforms without user support.
63 svn_io__is_finfo_executable(svn_boolean_t *executable,
64 apr_finfo_t *file_info,
67 /** Set @a *read_only TRUE if @a file_info is read-only for the user,
71 svn_io__is_finfo_read_only(svn_boolean_t *read_only,
72 apr_finfo_t *file_info,
77 * Lock file at @a lock_file. If that file does not exist, create an empty
80 * Lock will be automatically released when @a pool is cleared or destroyed.
81 * Use @a pool for memory allocations.
84 svn_io__file_lock_autocreate(const char *lock_file,
88 /** Buffer test handler function for a generic stream. @see svn_stream_t
89 * and svn_stream__is_buffered().
93 typedef svn_boolean_t (*svn_stream__is_buffered_fn_t)(void *baton);
95 /** Set @a stream's buffer test function to @a is_buffered_fn
100 svn_stream__set_is_buffered(svn_stream_t *stream,
101 svn_stream__is_buffered_fn_t is_buffered_fn);
103 /** Return whether this generic @a stream uses internal buffering.
104 * This may be used to work around subtle differences between buffered
105 * and non-buffered APR files. A lazy-open stream cannot report the
106 * true buffering state until after the lazy open: a stream that
107 * initially reports as non-buffered may report as buffered later.
112 svn_stream__is_buffered(svn_stream_t *stream);
114 /** Return the underlying file, if any, associated with the stream, or
115 * NULL if not available. Accessing the file bypasses the stream.
118 svn_stream__aprfile(svn_stream_t *stream);
120 /* Creates as *INSTALL_STREAM a stream that once completed can be installed
121 using Windows checkouts much slower than Unix.
123 While writing the stream is temporarily stored in TMP_ABSPATH.
126 svn_stream__create_for_install(svn_stream_t **install_stream,
127 const char *tmp_abspath,
128 apr_pool_t *result_pool,
129 apr_pool_t *scratch_pool);
131 /* Installs a stream created with svn_stream__create_for_install in its final
132 location FINAL_ABSPATH, potentially using platform specific optimizations.
134 If MAKE_PARENTS is TRUE, this function will create missing parent
135 directories if needed.
138 svn_stream__install_stream(svn_stream_t *install_stream,
139 const char *final_abspath,
140 svn_boolean_t make_parents,
141 apr_pool_t *scratch_pool);
143 /* Deletes the install stream (when installing is not necessary after all) */
145 svn_stream__install_delete(svn_stream_t *install_stream,
146 apr_pool_t *scratch_pool);
148 /* Optimized apr_file_stat / apr_file_info_get operating on a closed
151 svn_stream__install_get_info(apr_finfo_t *finfo,
152 svn_stream_t *install_stream,
154 apr_pool_t *scratch_pool);
159 /* ### Move to something like io.h or subr.h, to avoid making it
160 part of the DLL api */
162 /* This is semantically the same as the APR utf8_to_unicode_path
163 function, but reimplemented here because APR does not export it.
165 Note that this function creates "\\?\" paths so the resulting path
166 can only be used for WINAPI functions that explicitly document support
167 for this kind of paths. Newer Windows functions (Vista+) that support
168 long paths directly DON'T want this kind of escaping.
171 svn_io__utf8_to_unicode_longpath(const WCHAR **result,
173 apr_pool_t *result_pool);
175 /* This Windows-specific function marks the file to be deleted on close using
176 an existing file handle. It can be used to avoid having to reopen the file
177 as part of the delete handling. Return SVN_ERR_UNSUPPORTED_FEATURE if
178 delete on close operation is not supported by OS. */
180 svn_io__win_delete_file_on_close(apr_file_t *file,
184 /* This Windows-specific function renames the file using an existing file
185 handle. It can be used to avoid having to reopen the file as part of the
186 rename operation. Return SVN_ERR_UNSUPPORTED_FEATURE if renaming open
187 file is not supported by OS.*/
189 svn_io__win_rename_open_file(apr_file_t *file,
190 const char *from_path,
198 #endif /* __cplusplus */
201 #endif /* SVN_IO_PRIVATE_H */