blob: b2685957943ebe863548238726c0390fe89a0a52 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
#pragma once
#include <stddef.h>
#define PATH_MAX 512
/** Reduce a path to its simplest form.
* Kinds of invalid paths:
* - relative - "" "a" "./a"
* - going behind the root directory - "/../"
*
* @return On success, length of the string in *out, <= len. 0 if the path was invalid.
*
* returns an unsigned type because:
* 1. valid paths always return at least 1, for the initial slash
* 2. it makes it easier to assign the result to an unsigned variable and check for error
*/
size_t path_simplify(const char *in, char *out, size_t len);
|