files.h 1.68 KB
Newer Older
Matteo's avatar
Matteo committed
1
2
3
4
5
6
/**
 * @file files.h
 * @author Matteo Spanio (dev2@audioinnova.com)
 * @brief A collection of functions to handle files.
 * @version 1.0
 * @date 2023-05-13
Matteo's avatar
Matteo committed
7
 *
Matteo's avatar
Matteo committed
8
 * @copyright Copyright (c) 2023
Matteo's avatar
Matteo committed
9
 *
Matteo's avatar
Matteo committed
10
11
12
13
 */

#ifndef FILES_H
#define FILES_H
Matteo's avatar
Matteo committed
14
15
#include <stdlib.h>

Matteo's avatar
update  
Matteo committed
16
17
18
#include <filesystem>
#include <fstream>
#include <iostream>
Matteo's avatar
Matteo committed
19
#include <string>
Matteo's avatar
update  
Matteo committed
20

Matteo's avatar
Matteo committed
21
22
23
/**
 * @namespace files
 * @brief A collection of functions to handle files.
Matteo's avatar
Matteo committed
24
 *
Matteo's avatar
Matteo committed
25
 */
Matteo's avatar
update  
Matteo committed
26
namespace files {
Matteo's avatar
Matteo committed
27
28
29
30
31
32
33
34
35
36
37
/**
 * @fn void saveFile(std::filesystem::path fileName, std::string content, bool
 * append)
 * @brief Save content to a file
 *
 * @param fileName the name of the file
 * @param content the content to be saved
 * @param append if true, the content will be appended to the file, otherwise
 * the file will be overwritten
 */
void saveFile(std::filesystem::path fileName, std::string content, bool append);
Matteo's avatar
update  
Matteo committed
38

Matteo's avatar
Matteo committed
39
40
41
42
43
44
45
46
47
48
/**
 * @fn void findFileNameFromPath(std::string* path, std::string* fileName,
 * std::string* extension)
 * @brief Separates video file name from its extension.
 *
 * @param[in] path Full video path;
 * @param[out] fileName Video file name;
 * @param[out] extension Video extension.
 */
void findFileNameFromPath(std::string* path, std::string* fileName, std::string* extension);
Matteo's avatar
update  
Matteo committed
49

Matteo's avatar
Matteo committed
50
51
52
53
54
55
56
57
58
59
60
61
62
/**
 * @fn int findFileName(std::string videoPath, std::string &fileName,
 * std::string &extension)
 * @brief Check if the specified input video file exists and is supported.
 *
 * @param[in] videoPath Full video path;
 * @param[out] fileName Video file name;
 * @param[out] extension Video extension.
 * @return int -1 if the format is not supported, 0 otherwise.
 */
int findFileName(std::string videoPath, std::string& fileName, std::string& extension);
}  // namespace files
#endif  // FILES_H