forked from edman007/chiton
-
Notifications
You must be signed in to change notification settings - Fork 0
/
file_manager.hpp
52 lines (44 loc) · 1.82 KB
/
file_manager.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#ifndef __FILE_MANAGER_HPP__
#define __FILE_MANAGER_HPP__
/**************************************************************************
*
* This file is part of Chiton.
*
* Chiton is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Chiton is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Chiton. If not, see <https://www.gnu.org/licenses/>.
*
* Copyright 2020 Ed Martin <[email protected]>
*
**************************************************************************
*/
#include <string>
#include "database.hpp"
#include "chiton_config.hpp"
class FileManager {
public:
FileManager(Database &db, Config &cfg) : db(db), cfg(cfg) {};
//returns a valid path starting at start_time, writes out it's ID to int &file_id
std::string get_next_path(long int &file_id, int camera, const struct timeval &start_time);
//returns the path for the file referenced as id
std::string get_path(long int file_id);
//update metadata about the file
bool update_file_metadata(long int file_id, struct timeval &end_time);
void clean_disk(void);//clean up the disk by deleting files
private:
Database &db;
Config &cfg;
bool mkdir_recursive(std::string path);
void rmdir_r(const std::string &path);//delete directory and all empty parent directories
long get_target_free_bytes(void);//return the bytes that must be deleted
};
#endif