IFS/src/include/IFS/Util.h
Go to the documentation of this file.
1 /****
2  * Util.h
3  * Various bits for file system implementations to use
4  *
5  * Created on: 10 Sep 2018
6  *
7  * Copyright 2019 mikee47 <mike@sillyhouse.net>
8  *
9  * This file is part of the IFS Library
10  *
11  * This library is free software: you can redistribute it and/or modify it under the terms of the
12  * GNU General Public License as published by the Free Software Foundation, version 3 or later.
13  *
14  * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
15  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  * See the GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License along with this library.
19  * If not, see <https://www.gnu.org/licenses/>.
20  *
21  ****/
22 
23 #pragma once
24 
25 #include "Stat.h"
26 
27 namespace IFS
28 {
37 bool isRootPath(const char*& path);
38 
39 #define FS_CHECK_PATH(path) isRootPath(path);
40 
41 /*
42  * Methods with a DirHandle parameter use this to check and cast to locally defined FileDir*
43  */
44 #define GET_FILEDIR() \
45  CHECK_MOUNTED() \
46  if(dir == nullptr) { \
47  return Error::InvalidHandle; \
48  } \
49  auto d = reinterpret_cast<FileDir*>(dir);
50 
51 // Final check before returning completed stat structure
52 void checkStat(Stat& stat);
53 
54 } // namespace IFS
bool isRootPath(const char *&path)
Check if path is root directory.
Definition: DirectoryTemplate.h:36
void checkStat(Stat &stat)