]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/blob - contrib/subversion/subversion/include/private/svn_io_private.h
MFC r275385 (by bapt):
[FreeBSD/stable/10.git] / contrib / subversion / subversion / include / private / svn_io_private.h
1 /**
2  * @copyright
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
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
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
19  *    under the License.
20  * ====================================================================
21  * @endcopyright
22  *
23  * @file svn_io_private.h
24  * @brief Private IO API
25  */
26
27 #ifndef SVN_IO_PRIVATE_H
28 #define SVN_IO_PRIVATE_H
29
30 #include <apr.h>
31
32 #ifdef __cplusplus
33 extern "C" {
34 #endif /* __cplusplus */
35
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)
41 #else
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)
45 #endif
46
47 /* 90% of the lines we encounter will be less than this many chars.
48  *
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.
53  */
54 #define SVN__LINE_CHUNK_SIZE 80
55
56
57 /** Set @a *executable TRUE if @a file_info is executable for the
58  * user, FALSE otherwise.
59  *
60  * Always returns FALSE on Windows or platforms without user support.
61  */
62 svn_error_t *
63 svn_io__is_finfo_executable(svn_boolean_t *executable,
64                             apr_finfo_t *file_info,
65                             apr_pool_t *pool);
66
67 /** Set @a *read_only TRUE if @a file_info is read-only for the user,
68  * FALSE otherwise.
69  */
70 svn_error_t *
71 svn_io__is_finfo_read_only(svn_boolean_t *read_only,
72                            apr_finfo_t *file_info,
73                            apr_pool_t *pool);
74
75
76 /**
77  * Lock file at @a lock_file. If that file does not exist, create an empty
78  * file.
79  *
80  * Lock will be automatically released when @a pool is cleared or destroyed.
81  * Use @a pool for memory allocations.
82  */
83 svn_error_t *
84 svn_io__file_lock_autocreate(const char *lock_file,
85                              apr_pool_t *pool);
86
87
88 /** Buffer test handler function for a generic stream. @see svn_stream_t
89  * and svn_stream__is_buffered().
90  *
91  * @since New in 1.7.
92  */
93 typedef svn_boolean_t (*svn_stream__is_buffered_fn_t)(void *baton);
94
95 /** Set @a stream's buffer test function to @a is_buffered_fn
96  *
97  * @since New in 1.7.
98  */
99 void
100 svn_stream__set_is_buffered(svn_stream_t *stream,
101                             svn_stream__is_buffered_fn_t is_buffered_fn);
102
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.
108  *
109  * @since New in 1.7.
110  */
111 svn_boolean_t
112 svn_stream__is_buffered(svn_stream_t *stream);
113
114 /** Return the underlying file, if any, associated with the stream, or
115  * NULL if not available.  Accessing the file bypasses the stream.
116  */
117 apr_file_t *
118 svn_stream__aprfile(svn_stream_t *stream);
119
120 /* Creates as *INSTALL_STREAM a stream that once completed can be installed
121    using Windows checkouts much slower than Unix.
122
123    While writing the stream is temporarily stored in TMP_ABSPATH.
124  */
125 svn_error_t *
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);
130
131 /* Installs a stream created with svn_stream__create_for_install in its final
132    location FINAL_ABSPATH, potentially using platform specific optimizations.
133
134    If MAKE_PARENTS is TRUE, this function will create missing parent
135    directories if needed.
136  */
137 svn_error_t *
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);
142
143 /* Deletes the install stream (when installing is not necessary after all) */
144 svn_error_t *
145 svn_stream__install_delete(svn_stream_t *install_stream,
146                            apr_pool_t *scratch_pool);
147
148 /* Optimized apr_file_stat / apr_file_info_get operating on a closed
149    install stream */
150 svn_error_t *
151 svn_stream__install_get_info(apr_finfo_t *finfo,
152                              svn_stream_t *install_stream,
153                              apr_int32_t wanted,
154                              apr_pool_t *scratch_pool);
155
156
157 #if defined(WIN32)
158
159 /* ### Move to something like io.h or subr.h, to avoid making it
160        part of the DLL api */
161
162 /* This is semantically the same as the APR utf8_to_unicode_path
163    function, but reimplemented here because APR does not export it.
164
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.
169  */
170 svn_error_t*
171 svn_io__utf8_to_unicode_longpath(const WCHAR **result,
172                                  const char *source,
173                                  apr_pool_t *result_pool);
174
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. */
179 svn_error_t *
180 svn_io__win_delete_file_on_close(apr_file_t *file,
181                                  const char *path,
182                                  apr_pool_t *pool);
183
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.*/
188 svn_error_t *
189 svn_io__win_rename_open_file(apr_file_t *file,
190                              const char *from_path,
191                              const char *to_path,
192                              apr_pool_t *pool);
193
194 #endif /* WIN32 */
195
196 #ifdef __cplusplus
197 }
198 #endif /* __cplusplus */
199
200
201 #endif /* SVN_IO_PRIVATE_H */