path.h
Go to the documentation of this file.
1 /**
2  * @file path.h
3  * @brief Path manipulation helper functions
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2024 Oryx Embedded SARL. All rights reserved.
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software Foundation,
23  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24  *
25  * @author Oryx Embedded SARL (www.oryx-embedded.com)
26  * @version 2.4.0
27  **/
28 
29 #ifndef _PATH_H
30 #define _PATH_H
31 
32 //Dependencies
33 #include "os_port.h"
34 
35 //C++ guard
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 //Path manipulation helper functions
41 bool_t pathIsAbsolute(const char_t *path);
42 bool_t pathIsRelative(const char_t *path);
43 
44 const char_t *pathGetFilename(const char_t *path);
45 void pathRemoveFilename(char_t *path);
46 
47 void pathCopy(char_t *dest, const char_t *src, size_t maxLen);
48 
49 void pathCanonicalize(char_t *path);
50 
51 void pathAddSlash(char_t *path, size_t maxLen);
52 void pathRemoveSlash(char_t *path);
53 
54 void pathCombine(char_t *path, const char_t *more, size_t maxLen);
55 
56 bool_t pathMatch(const char_t *path, const char_t *pattern);
57 
58 //C++ guard
59 #ifdef __cplusplus
60 }
61 #endif
62 
63 #endif
char char_t
Definition: compiler_port.h:48
int bool_t
Definition: compiler_port.h:53
RTOS abstraction layer.
void pathCombine(char_t *path, const char_t *more, size_t maxLen)
Concatenate two paths.
Definition: path.c:370
void pathCanonicalize(char_t *path)
Simplify a path.
Definition: path.c:150
const char_t * pathGetFilename(const char_t *path)
Extract the file name from the supplied path.
Definition: path.c:73
void pathCopy(char_t *dest, const char_t *src, size_t maxLen)
Copy a path.
Definition: path.c:129
void pathAddSlash(char_t *path, size_t maxLen)
Add a slash to the end of a string.
Definition: path.c:312
void pathRemoveFilename(char_t *path)
Remove the trailing file name from the supplied path.
Definition: path.c:112
bool_t pathIsRelative(const char_t *path)
Test if the path is relative.
Definition: path.c:57
bool_t pathIsAbsolute(const char_t *path)
Test if the path is absolute.
Definition: path.c:41
void pathRemoveSlash(char_t *path)
Remove the trailing slash from a given path.
Definition: path.c:340
bool_t pathMatch(const char_t *path, const char_t *pattern)
Check whether a file name matches the specified pattern.
Definition: path.c:408