FileManager v1.7.0
Manage access to files with async model
Loading...
Searching...
No Matches
Utility.h
1#pragma once
2
3#include <filesystem>
4#include <cmath>
5
6#ifdef __LINUX__
7#define FILE_MANAGER_API __attribute__((visibility("default")))
8#else
9#define FILE_MANAGER_API __declspec(dllexport)
10
11#pragma warning(disable: 4251)
12#pragma warning(disable: 4275)
13#endif
14
15namespace file_manager
16{
17 inline namespace size_literals
18 {
22 inline unsigned long long operator "" _kib(unsigned long long count)
23 {
24 return count * 1024;
25 }
26
30 inline unsigned long long operator "" _mib(unsigned long long count)
31 {
32 return count * static_cast<unsigned long long>(std::pow(1024, 2));
33 }
34
38 inline unsigned long long operator "" _gib(unsigned long long count)
39 {
40 return count * static_cast<unsigned long long>(std::pow(1024, 3));
41 }
42 }
43
44 namespace utility
45 {
47 struct FILE_MANAGER_API pathHash
48 {
49 size_t operator () (const std::filesystem::path& filePath) const noexcept;
50 };
51 }
52
53 namespace _utility
54 {
55 template<typename OperationT>
56 concept Operation = requires (uint64_t left, uint64_t right)
57 {
58 { OperationT()(left, right) } -> std::convertible_to<uint64_t>;
59 };
60
61 void addCache(std::filesystem::path&& filePath, std::string&& data);
62
63 template<template<typename> typename OperationT> requires _utility::Operation<OperationT<uint64_t>>
64 void changeCurrentCacheSize(uint64_t amount);
65 }
66}
67
68namespace threading
69{
70 class ThreadPool;
71}
filesystem::path hash function
Definition Utility.h:48