docs/html/filesystem_8h_source.html
| | Jetson Inference
DNN Vision Library |
filesystem.h
Go to the documentation of this file.
1 /*
2 * Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 * DEALINGS IN THE SOFTWARE.
21 */
22
23 #ifndef __FILESYSTEM_UTIL_H__
24 #define __FILESYSTEM_UTIL_H__
25
26 #include <string>
27 #include <vector>
28
29
30
43 std::string absolutePath( const std::string& relative_path );
44
56 std::string locateFile( const std::string& path );
57
67 std::string locateFile( const std::string& path, std::vector<std::string>& locations );
68
77 std::string readFile( const std::string& path );
78
84 std::string pathJoin( const std::string& a, const std::string& b );
85
91 std::string pathDir( const std::string& path );
92
97 std::string pathFilename( const std::string& path );
98
104 std::pair<std::string, std::string> splitPath( const std::string& path );
105
111 {
112FILE_MISSING = 0,
113FILE_REGULAR = (1 << 0),
117FILE_BLOCK = (1 << 4),
119FILE_SOCKET = (1 << 6)
120 };
121
136 bool listDir( const std::string& path, std::vector<std::string>& list, uint32_t mask=0 );
137
146 bool fileExists( const std::string& path, uint32_t mask=0 );
147
154 bool fileIsType( const std::string& path, uint32_t mask );
155
161 uint32_t fileType( const std::string& path );
162
172 size_t fileSize( const std::string& path );
173
180 std::string fileExtension( const std::string& path );
181
187 bool fileHasExtension( const std::string& path, const std::string& extension );
188
193 bool fileHasExtension( const std::string& path, const std::vector<std::string>& extensions );
194
201 bool fileHasExtension( const std::string& path, const char** extensions );
202
209 std::string fileRemoveExtension( const std::string& filename );
210
217 std::string fileChangeExtension( const std::string& filename, const std::string& newExtension );
218
219
220 #endif
221
bool fileExists(const std::string &path, uint32_t mask=0)
Return the directory /** Verify path and return true if the file exists.
@ FILE_REGULAR
Definition: filesystem.h:113
std::string pathFilename(const std::string &path)
Return the filename from the path, including the file extension.
@ FILE_BLOCK
Definition: filesystem.h:117
bool fileIsType(const std::string &path, uint32_t mask)
Return true if the file is one of the types in the fileTypes mask.
std::pair< std::string, std::string > splitPath(const std::string &path)
Split a path into directory and filename components.
std::string fileChangeExtension(const std::string &filename, const std::string &newExtension)
Return the input string with a changed file extension For example, fileChangeExtension("~/workspace/s...
@ FILE_FIFO
Definition: filesystem.h:118
std::string pathJoin(const std::string &a, const std::string &b)
Join two paths, and properly include a path separator (/) as needed.
@ FILE_MISSING
Definition: filesystem.h:112
@ FILE_SOCKET
Definition: filesystem.h:119
size_t fileSize(const std::string &path)
Return the size (in bytes) of the specified file.
@ FILE_CHAR
Definition: filesystem.h:116
@ FILE_LINK
Definition: filesystem.h:115
std::string pathDir(const std::string &path)
Return the parent directory of the specified path, removing the filename and extension.
std::string absolutePath(const std::string &relative_path)
Given a relative path, resolve the absolute path using the working directory.
uint32_t fileType(const std::string &path)
Return the file type, or FILE_MISSING if it doesn't exist.
std::string fileRemoveExtension(const std::string &filename)
Return the input string with the file extension removed For example, fileRemoveExtension("~/workspace...
@ FILE_DIR
Definition: filesystem.h:114
std::string locateFile(const std::string &path)
Locate a file from common system locations.
bool fileHasExtension(const std::string &path, const std::string &extension)
Return true if the file has the given extension, otherwise false.
std::string readFile(const std::string &path)
Read a text file into a string.
std::string fileExtension(const std::string &path)
Extract the file extension from the path.
bool listDir(const std::string &path, std::vector< std::string > &list, uint32_t mask=0)
Return a sorted list of the files in the specified directory.
fileTypes
File types.
Definition: filesystem.h:110