Use openssl's sha1 and sha256, optionally (#15472)
[minetest.git] / irr / src / CMemoryFile.h
blob83d77cb773ddea2889e18da2a9f060031586ed32
1 // Copyright (C) 2002-2012 Nikolaus Gebhardt
2 // This file is part of the "Irrlicht Engine".
3 // For conditions of distribution and use, see copyright notice in irrlicht.h
5 #pragma once
7 #include "IMemoryReadFile.h"
8 #include "IWriteFile.h"
9 #include "irrString.h"
11 namespace irr
14 namespace io
17 /*!
18 Class for reading from memory.
20 class CMemoryReadFile final : public IMemoryReadFile
22 public:
23 //! Constructor
24 CMemoryReadFile(const void *memory, long len, const io::path &fileName, bool deleteMemoryWhenDropped);
26 //! Destructor
27 virtual ~CMemoryReadFile();
29 //! returns how much was read
30 size_t read(void *buffer, size_t sizeToRead) override;
32 //! changes position in file, returns true if successful
33 bool seek(long finalPos, bool relativeMovement = false) override;
35 //! returns size of file
36 long getSize() const override;
38 //! returns where in the file we are.
39 long getPos() const override;
41 //! returns name of file
42 const io::path &getFileName() const override;
44 //! Get the type of the class implementing this interface
45 EREAD_FILE_TYPE getType() const override
47 return ERFT_MEMORY_READ_FILE;
50 //! Get direct access to internal buffer
51 const void *getBuffer() const override
53 return Buffer;
56 private:
57 const void *Buffer;
58 long Len;
59 long Pos;
60 io::path Filename;
61 bool deleteMemoryWhenDropped;
64 /*!
65 Class for writing to memory.
67 class CMemoryWriteFile : public IWriteFile
69 public:
70 //! Constructor
71 CMemoryWriteFile(void *memory, long len, const io::path &fileName, bool deleteMemoryWhenDropped);
73 //! Destructor
74 virtual ~CMemoryWriteFile();
76 //! returns how much was written
77 size_t write(const void *buffer, size_t sizeToWrite) override;
79 //! changes position in file, returns true if successful
80 bool seek(long finalPos, bool relativeMovement = false) override;
82 //! returns where in the file we are.
83 long getPos() const override;
85 //! returns name of file
86 const io::path &getFileName() const override;
88 bool flush() override;
90 private:
91 void *Buffer;
92 long Len;
93 long Pos;
94 io::path Filename;
95 bool deleteMemoryWhenDropped;
98 } // end namespace io
99 } // end namespace irr