File: path.h

package info (click to toggle)
libsfdo 0.1.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 736 kB
  • sloc: ansic: 6,491; python: 111; makefile: 4
file content (16 lines) | stat: -rw-r--r-- 389 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#ifndef PATH_H
#define PATH_H

#include <stdbool.h>
#include <stddef.h>

static inline bool sfdo_path_needs_extra_slash(const char *path, size_t len) {
	return len >= 2 && path[len - 1] != '/';
}

static inline size_t sfdo_path_compute_mem_size(const char *path, size_t len) {
	// 1 for NUL + potential 1 for slash
	return len + (sfdo_path_needs_extra_slash(path, len) ? 2 : 1);
}

#endif