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 /** Return the underlying file, if any, associated with the stream, or 89 * NULL if not available. Accessing the file bypasses the stream. 90 */ 91 apr_file_t * 92 svn_stream__aprfile(svn_stream_t *stream); 93 94 /* Creates as *INSTALL_STREAM a stream that once completed can be installed 95 using Windows checkouts much slower than Unix. 96 97 While writing the stream is temporarily stored in TMP_ABSPATH. 98 */ 99 svn_error_t * 100 svn_stream__create_for_install(svn_stream_t **install_stream, 101 const char *tmp_abspath, 102 apr_pool_t *result_pool, 103 apr_pool_t *scratch_pool); 104 105 /* Installs a stream created with svn_stream__create_for_install in its final 106 location FINAL_ABSPATH, potentially using platform specific optimizations. 107 108 If MAKE_PARENTS is TRUE, this function will create missing parent 109 directories if needed. 110 */ 111 svn_error_t * 112 svn_stream__install_stream(svn_stream_t *install_stream, 113 const char *final_abspath, 114 svn_boolean_t make_parents, 115 apr_pool_t *scratch_pool); 116 117 /* Deletes the install stream (when installing is not necessary after all) */ 118 svn_error_t * 119 svn_stream__install_delete(svn_stream_t *install_stream, 120 apr_pool_t *scratch_pool); 121 122 /* Optimized apr_file_stat / apr_file_info_get operating on a closed 123 install stream */ 124 svn_error_t * 125 svn_stream__install_get_info(apr_finfo_t *finfo, 126 svn_stream_t *install_stream, 127 apr_int32_t wanted, 128 apr_pool_t *scratch_pool); 129 130 /* Internal version of svn_stream_from_aprfile2() supporting the 131 additional TRUNCATE_ON_SEEK argument. */ 132 svn_stream_t * 133 svn_stream__from_aprfile(apr_file_t *file, 134 svn_boolean_t disown, 135 svn_boolean_t truncate_on_seek, 136 apr_pool_t *pool); 137 138 #if defined(WIN32) 139 140 /* ### Move to something like io.h or subr.h, to avoid making it 141 part of the DLL api */ 142 143 /* This is semantically the same as the APR utf8_to_unicode_path 144 function, but reimplemented here because APR does not export it. 145 146 Note that this function creates "\\?\" paths so the resulting path 147 can only be used for WINAPI functions that explicitly document support 148 for this kind of paths. Newer Windows functions (Vista+) that support 149 long paths directly DON'T want this kind of escaping. 150 */ 151 svn_error_t* 152 svn_io__utf8_to_unicode_longpath(const WCHAR **result, 153 const char *source, 154 apr_pool_t *result_pool); 155 156 /* This Windows-specific function marks the file to be deleted on close using 157 an existing file handle. It can be used to avoid having to reopen the file 158 as part of the delete handling. Return SVN_ERR_UNSUPPORTED_FEATURE if 159 delete on close operation is not supported by OS. */ 160 svn_error_t * 161 svn_io__win_delete_file_on_close(apr_file_t *file, 162 const char *path, 163 apr_pool_t *pool); 164 165 /* This Windows-specific function renames the file using an existing file 166 handle. It can be used to avoid having to reopen the file as part of the 167 rename operation. Return SVN_ERR_UNSUPPORTED_FEATURE if renaming open 168 file is not supported by OS.*/ 169 svn_error_t * 170 svn_io__win_rename_open_file(apr_file_t *file, 171 const char *from_path, 172 const char *to_path, 173 apr_pool_t *pool); 174 175 #endif /* WIN32 */ 176 177 #ifdef __cplusplus 178 } 179 #endif /* __cplusplus */ 180 181 182 #endif /* SVN_IO_PRIVATE_H */ 183