acme
Foundational cross-platform layer of the ca2 framework
Loading...
Searching...
No Matches
file.h
1// Created by camilo on 2023-03-14 09:49 <3ThomasBorregaardSorensen!!
2#pragma once
3
4
5#include "acme/operating_system/windows_common/handle.h"
6#include "acme/filesystem/filesystem/windows_path.h"
7
8
9namespace windows
10{
11
12
13 class CLASS_DECL_ACME file :
15 {
16 public:
17
18
19 ::file::path & m_path;
20 ::windows_path & m_windowspath;
21 ::file::e_open & m_eopen;
22
23
24 file(::file::path & path, ::windows_path & windowspath, ::file::e_open & eopen, HANDLE handleFile = INVALID_HANDLE_VALUE);
25 ~file();
26
27
28 bool safe_create_file(const ::file::path & path, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile);
29
30 void _create_file(const ::file::path & path, ::file::e_open eopen);
31
32 void create_file(const ::file::path & path, ::file::e_open eopen);
33
34
39 [[nodiscard ]] DWORD defer_write(const void * p, ::memsize s, LPOVERLAPPED lpOverlapped = nullptr);
40
41 void write(const void * p, ::memsize s, LPOVERLAPPED lpOverlapped = nullptr);
42
47 [[nodiscard ]] ::memsize read(void * p, ::memsize s, LPOVERLAPPED lpOverlapped = nullptr);
48
49 void flush_file_buffers();
50
51 ::i64 get_file_size() const;
52
53 void ensure_file_size(::i64 iSize);
54
55 void set_file_size(::i64 iSize);
56
57 void set_file_pointer_ex(::i64 iOffset, PLARGE_INTEGER lpNewFilePointer, DWORD dwMoveMethod);
58
59 void set_file_pointer(::i64 iOffset, DWORD dwMoveMethod);
60
61 ::i64 get_file_pointer() const;
62
63 void set_end_of_file();
64
65 void lock_file(::i64 iOffset, ::i64 iCount);
66
67 void unlock_file(::i64 iOffset, ::i64 iCount);
68
69 void set_file_time(const FILETIME * lpCreationTime, const FILETIME * lpLastAccessTime, const FILETIME * lpLastWriteTime);
70
71 void get_file_time(LPFILETIME lpCreationTime, LPFILETIME lpLastAccessTime, LPFILETIME lpLastWriteTime);
72
73 void get_file_information(BY_HANDLE_FILE_INFORMATION & information) const;
74
75 [[nodiscard]] ::file::path get_final_path_by_handle() const;
76
77 [[ noreturn ]] void throw_last_error_exception(const ::scoped_string & scopedstrErrorMessage = nullptr, DWORD lasterror = 0) const;
78
79
80 };
81
82
83 class CLASS_DECL_ACME file_instance :
84 public ::windows::file
85 {
86 public:
87
88
89 ::file::path m_pathInstance;
90 ::windows_path m_windowspathInstance;
91 ::file::e_open m_eopenInstance;
92
93
94 file_instance() :
95 file(m_pathInstance, m_windowspathInstance, m_eopenInstance)
96 {
97
98 m_eopenInstance = ::file::e_open_none;
99
100 }
101
102
103 ~file_instance() {}
104
105
106 };
107
108
109} // namespace windows
110
111
112
Definition path.h:52
Definition file.h:15
DWORD defer_write(const void *p, ::memsize s, LPOVERLAPPED lpOverlapped=nullptr)
Definition file.cpp:249
::memsize read(void *p, ::memsize s, LPOVERLAPPED lpOverlapped=nullptr)
Definition file.cpp:294
Definition handle.h:13
Definition windows_path.h:7
Definition filesystem.h:16