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

#ifndef FILES_H
#define FILES_H
Matteo's avatar
update  
Matteo committed
14
15
16
17
18
19
#include <filesystem>
#include <fstream>
#include <string>
#include <iostream>
#include <stdlib.h>

Matteo's avatar
Matteo committed
20
21
22
23
24
/**
 * @namespace files
 * @brief A collection of functions to handle files.
 * 
 */
Matteo's avatar
update  
Matteo committed
25
26
namespace files {
    /**
Matteo's avatar
Matteo committed
27
     * @fn void saveFile(std::filesystem::path fileName, std::string content, bool append)
Matteo's avatar
update  
Matteo committed
28
29
30
31
32
33
34
35
36
     * @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
Matteo committed
37
     * @fn void findFileNameFromPath(std::string* path, std::string* fileName, std::string* extension)
Matteo's avatar
update  
Matteo committed
38
39
40
41
42
43
44
45
46
     * @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
Matteo committed
47
     * @fn int findFileName(std::string videoPath, std::string &fileName, std::string &extension)
Matteo's avatar
update  
Matteo committed
48
49
50
51
52
53
54
55
     * @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);
Matteo's avatar
Matteo committed
56
57
}
#endif // FILES_H