-
Notifications
You must be signed in to change notification settings - Fork 0
/
FileManager.h
66 lines (47 loc) · 1.26 KB
/
FileManager.h
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//
// Created by user on 19-4-24.
//
#ifndef WEBSERVER_FILEMANAGER_H
#define WEBSERVER_FILEMANAGER_H
#include <filesystem>
#include <sys/sendfile.h>
#include <sys/mman.h>
#include <sys/eventfd.h>
#include <sys/syscall.h>
#include <sys/stat.h>
#include <linux/aio_abi.h>
#include <unistd.h>
//#include <aio.h>
#include <string>
#include <time.h>
#include <fcntl.h>
#include <unistd.h>
#include <unordered_map>
#include "Array.h"
#include "HTTPParse.h"
#include "ThreadPool.h"
void SendFile(long long id, HTTPRequest *header, int infd, int size);
class FileManager {
public:
FileManager(std::string htdocs);
~FileManager();
bool init();
bool read(HTTPRequest *header);
bool isPHP(char *filename, char *end, int *err);
int getEventFD();
int io_submit(long n, struct iocb **cb);
int io_getevents(long min_nr, long nr, io_event *events, timespec *tmo);
int io_cancel(iocb *cb, io_event *event);
private:
char *find_format(char *begin, char *end);
private:
std::string path;
std::string urn;
ThreadPool *threadPool;
std::function<void(long long, HTTPRequest *, int, int)> send;
//PoolHeader *pool;
int efd;
aio_context_t ctx;
std::unordered_map<std::string, int> record;
};
#endif //WEBSERVER_FILEMANAGER_H