| 163 | */ |
| 164 | |
| 165 | void path_build( PATHNAME * f, string * file ) |
| 166 | { |
| 167 | file_build1( f, file ); |
| 168 | |
| 169 | /* Do not prepend root if it is '.' or the directory is rooted. */ |
| 170 | if ( f->f_root.len |
| 171 | && !( f->f_root.len == 1 && f->f_root.ptr[ 0 ] == '.' ) |
| 172 | && !( f->f_dir.len && f->f_dir.ptr[ 0 ] == '/' ) |
| 173 | #if PATH_DELIM == '\\' |
| 174 | && !( f->f_dir.len && f->f_dir.ptr[ 0 ] == '\\' ) |
| 175 | && !( f->f_dir.len && f->f_dir.ptr[ 1 ] == ':' ) |
| 176 | #endif |
| 177 | ) |
| 178 | { |
| 179 | string_append_range( file, f->f_root.ptr, f->f_root.ptr + f->f_root.len |
| 180 | ); |
| 181 | /* If 'root' already ends with a path delimeter, do not add another one. |
| 182 | */ |
| 183 | if ( !is_path_delim( f->f_root.ptr[ f->f_root.len - 1 ] ) ) |
| 184 | string_push_back( file, as_path_delim( f->f_root.ptr[ f->f_root.len |
| 185 | ] ) ); |
| 186 | } |
| 187 | |
| 188 | if ( f->f_dir.len ) |
| 189 | string_append_range( file, f->f_dir.ptr, f->f_dir.ptr + f->f_dir.len ); |
| 190 | |
| 191 | /* Put path separator between dir and file. */ |
| 192 | /* Special case for root dir: do not add another path separator. */ |
| 193 | if ( f->f_dir.len && ( f->f_base.len || f->f_suffix.len ) |
| 194 | #if PATH_DELIM == '\\' |
| 195 | && !( f->f_dir.len == 3 && f->f_dir.ptr[ 1 ] == ':' ) |
| 196 | #endif |
| 197 | && !( f->f_dir.len == 1 && is_path_delim( f->f_dir.ptr[ 0 ] ) ) ) |
| 198 | string_push_back( file, as_path_delim( f->f_dir.ptr[ f->f_dir.len ] ) ); |
| 199 | |
| 200 | if ( f->f_base.len ) |
| 201 | string_append_range( file, f->f_base.ptr, f->f_base.ptr + f->f_base.len |
| 202 | ); |
| 203 | |
| 204 | if ( f->f_suffix.len ) |
| 205 | string_append_range( file, f->f_suffix.ptr, f->f_suffix.ptr + |
| 206 | f->f_suffix.len ); |
| 207 | |
| 208 | if ( f->f_member.len ) |
| 209 | { |
| 210 | string_push_back( file, '(' ); |
| 211 | string_append_range( file, f->f_member.ptr, f->f_member.ptr + |
| 212 | f->f_member.len ); |
| 213 | string_push_back( file, ')' ); |
| 214 | } |
| 215 | } |
| 216 | |
| 217 | |
| 218 | /* |
no test coverage detected