Blame


1 32cb896c 2018-03-11 stsp /*
2 32cb896c 2018-03-11 stsp * Copyright (c) 2018 Stefan Sperling <stsp@openbsd.org>
3 32cb896c 2018-03-11 stsp *
4 32cb896c 2018-03-11 stsp * Permission to use, copy, modify, and distribute this software for any
5 32cb896c 2018-03-11 stsp * purpose with or without fee is hereby granted, provided that the above
6 32cb896c 2018-03-11 stsp * copyright notice and this permission notice appear in all copies.
7 32cb896c 2018-03-11 stsp *
8 32cb896c 2018-03-11 stsp * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 32cb896c 2018-03-11 stsp * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 32cb896c 2018-03-11 stsp * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 32cb896c 2018-03-11 stsp * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 32cb896c 2018-03-11 stsp * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 32cb896c 2018-03-11 stsp * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 32cb896c 2018-03-11 stsp * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 32cb896c 2018-03-11 stsp */
16 32cb896c 2018-03-11 stsp
17 32cb896c 2018-03-11 stsp /* Utilities for dealing with filesystem paths. */
18 32cb896c 2018-03-11 stsp
19 32cb896c 2018-03-11 stsp #define GOT_DEFAULT_FILE_MODE (S_IRUSR|S_IWUSR | S_IRGRP | S_IROTH)
20 32cb896c 2018-03-11 stsp #define GOT_DEFAULT_DIR_MODE (S_IRWXU | S_IRGRP|S_IXGRP | S_IROTH|S_IXOTH)
21 32cb896c 2018-03-11 stsp
22 32cb896c 2018-03-11 stsp /* Determine whether a path is an absolute path. */
23 32cb896c 2018-03-11 stsp int got_path_is_absolute(const char *);
24 32cb896c 2018-03-11 stsp
25 32cb896c 2018-03-11 stsp /*
26 32cb896c 2018-03-11 stsp * Return an absolute version of a relative path.
27 32cb896c 2018-03-11 stsp * The result is allocated with malloc(3).
28 32cb896c 2018-03-11 stsp */
29 32cb896c 2018-03-11 stsp char *got_path_get_absolute(const char *);
30 32cb896c 2018-03-11 stsp
31 32cb896c 2018-03-11 stsp /*
32 32cb896c 2018-03-11 stsp * Normalize a path for internal processing.
33 32cb896c 2018-03-11 stsp * The result is allocated with malloc(3).
34 32cb896c 2018-03-11 stsp */
35 32cb896c 2018-03-11 stsp char *got_path_normalize(const char *);
36 32cb896c 2018-03-11 stsp
37 32cb896c 2018-03-11 stsp /* Open a new temporary file for writing.
38 32cb896c 2018-03-11 stsp * The file is not visible in the filesystem. */
39 32cb896c 2018-03-11 stsp FILE *got_opentemp(void);
40 9d31a1d8 2018-03-11 stsp
41 9d31a1d8 2018-03-11 stsp /* Open a new temporary file for writing.
42 9d31a1d8 2018-03-11 stsp * The file is visible in the filesystem. */
43 9d31a1d8 2018-03-11 stsp const struct got_error *got_opentemp_named(char **, FILE **, const char *);
44 9d31a1d8 2018-03-11 stsp
45 9d31a1d8 2018-03-11 stsp /* Count the number of path segments separated by '/'. */
46 9d31a1d8 2018-03-11 stsp const struct got_error *
47 9d31a1d8 2018-03-11 stsp got_path_segment_count(int *count, const char *path);