1 | /*␊ |
2 | Copyright (c) 2022, Grégory Soutadé␊ |
3 | ␊ |
4 | All rights reserved.␊ |
5 | Redistribution and use in source and binary forms, with or without␊ |
6 | modification, are permitted provided that the following conditions are met:␊ |
7 | ␊ |
8 | * Redistributions of source code must retain the above copyright␊ |
9 | notice, this list of conditions and the following disclaimer.␊ |
10 | * Redistributions in binary form must reproduce the above copyright␊ |
11 | notice, this list of conditions and the following disclaimer in the␊ |
12 | documentation and/or other materials provided with the distribution.␊ |
13 | * Neither the name of the copyright holder nor the␊ |
14 | names of its contributors may be used to endorse or promote products␊ |
15 | derived from this software without specific prior written permission.␊ |
16 | ␊ |
17 | THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY␊ |
18 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED␊ |
19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE␊ |
20 | DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY␊ |
21 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES␊ |
22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;␊ |
23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND␊ |
24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT␊ |
25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS␊ |
26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.␊ |
27 | */␊ |
28 | ␊ |
29 | #ifndef _UTILS_COMMON_H_␊ |
30 | #define _UTILS_COMMON_H_␊ |
31 | ␊ |
32 | #define LOANS_DIR "loans/"␊ |
33 | #define ID_HASH_SIZE 16␊ |
34 | ␊ |
35 | #define ARRAY_SIZE(arr) (sizeof(arr)/sizeof(arr[0]))␊ |
36 | ␊ |
37 | /**␊ |
38 | * @brief Display libgourou version␊ |
39 | */␊ |
40 | void version(void);␊ |
41 | ␊ |
42 | /**␊ |
43 | * @brief Find a given filename in current directory and/or in default directories␊ |
44 | *␊ |
45 | * @param filename Filename to search␊ |
46 | * @param inDefaultDirs Search is default directories or not␊ |
47 | *␊ |
48 | * @return A copy of full path␊ |
49 | */␊ |
50 | const char* findFile(const char* filename, bool inDefaultDirs=true);␊ |
51 | ␊ |
52 | /**␊ |
53 | * @brief Does the file (or directory exists)␊ |
54 | */␊ |
55 | bool fileExists(const char* filename);␊ |
56 | ␊ |
57 | /**␊ |
58 | * @brief Recursively created dir␊ |
59 | */␊ |
60 | void mkpath(const char *dir);␊ |
61 | ␊ |
62 | /**␊ |
63 | * @brief Copy file in into file out␊ |
64 | */␊ |
65 | void fileCopy(const char* in, const char* out);␊ |
66 | ␊ |
67 | #endif␊ |