aboutsummaryrefslogtreecommitdiff
path: root/zenstore/include
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2021-09-19 18:35:56 +0200
committerStefan Boberg <[email protected]>2021-09-19 18:35:56 +0200
commit8b5213bd050634e17b6215cbe25228b4cc6128ef (patch)
tree9356fcb1dbbf4c6e53ac010fb96ddf2ae0ef3323 /zenstore/include
parentExclude build outputs from vs-chromium (diff)
downloadzen-8b5213bd050634e17b6215cbe25228b4cc6128ef.tar.xz
zen-8b5213bd050634e17b6215cbe25228b4cc6128ef.zip
Changed BasicFile implementation
* No longer uses ATL on Windows (we just use raw Win32 API) * Added non-throwing Open() implementation * Added beginnings of a test suite, for verifying cross-platform implementation
Diffstat (limited to 'zenstore/include')
-rw-r--r--zenstore/include/zenstore/basicfile.h21
1 files changed, 15 insertions, 6 deletions
diff --git a/zenstore/include/zenstore/basicfile.h b/zenstore/include/zenstore/basicfile.h
index c6f61d466..0daa5d39f 100644
--- a/zenstore/include/zenstore/basicfile.h
+++ b/zenstore/include/zenstore/basicfile.h
@@ -2,34 +2,43 @@
#pragma once
-#include <zencore/iobuffer.h>
-#include <zencore/zencore.h>
+#include "zenstore.h"
+#include <zencore/iobuffer.h>
#include <zencore/windows.h>
-#include <atlfile.h>
#include <filesystem>
namespace zen {
/**
* Probably the most basic file abstraction in the universe
+ *
+ * One thing of note is that there is no notion of a "current file position"
+ * in this API -- all reads and writes are done from explicit offsets in
+ * the file. This avoids concurrency issues which can occur otherwise.
+ *
*/
class BasicFile
{
public:
+ BasicFile() = default;
+ ~BasicFile();
void Open(std::filesystem::path FileName, bool IsCreate);
+ void Open(std::filesystem::path FileName, bool IsCreate, std::error_code& Ec);
+ void Close();
void Read(void* Data, uint64_t Size, uint64_t Offset);
void Write(const void* Data, uint64_t Size, uint64_t Offset);
void Flush();
uint64_t FileSize();
- void* Handle() { return m_File; }
- void Close();
+ void* Handle() { return m_FileHandle; }
IoBuffer ReadAll();
private:
- CAtlFile m_File;
+ void* m_FileHandle = nullptr; // This is either null or valid
};
+ZENCORE_API void basicfile_forcelink();
+
} // namespace zen