diff options
Diffstat (limited to 'libraries/irrlicht-1.8/tools/GUIEditor/CMemoryReadWriteFile.cpp')
-rw-r--r-- | libraries/irrlicht-1.8/tools/GUIEditor/CMemoryReadWriteFile.cpp | 95 |
1 files changed, 0 insertions, 95 deletions
diff --git a/libraries/irrlicht-1.8/tools/GUIEditor/CMemoryReadWriteFile.cpp b/libraries/irrlicht-1.8/tools/GUIEditor/CMemoryReadWriteFile.cpp deleted file mode 100644 index af46b15..0000000 --- a/libraries/irrlicht-1.8/tools/GUIEditor/CMemoryReadWriteFile.cpp +++ /dev/null | |||
@@ -1,95 +0,0 @@ | |||
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 | ||
4 | |||
5 | #include "CMemoryReadWriteFile.h" | ||
6 | |||
7 | using namespace irr; | ||
8 | using namespace io; | ||
9 | |||
10 | CMemoryReadWriteFile::CMemoryReadWriteFile(const c8* filename) | ||
11 | : Data(), FileName(filename), Pos(0) | ||
12 | { | ||
13 | } | ||
14 | |||
15 | |||
16 | s32 CMemoryReadWriteFile::write(const void* buffer, u32 sizeToWrite) | ||
17 | { | ||
18 | // no point in writing 0 bytes | ||
19 | if (sizeToWrite < 1) | ||
20 | return 0; | ||
21 | |||
22 | // expand size | ||
23 | if (Pos + sizeToWrite > Data.size()) | ||
24 | Data.set_used(Pos+sizeToWrite); | ||
25 | |||
26 | // copy data | ||
27 | memcpy( (void*) &Data[Pos], buffer, (size_t) sizeToWrite); | ||
28 | |||
29 | Pos += sizeToWrite; | ||
30 | |||
31 | return sizeToWrite; | ||
32 | |||
33 | } | ||
34 | |||
35 | bool CMemoryReadWriteFile::seek(long finalPos, bool relativeMovement) | ||
36 | { | ||
37 | if (relativeMovement) | ||
38 | { | ||
39 | if (finalPos + Pos < 0) | ||
40 | return 0; | ||
41 | else | ||
42 | Pos += finalPos; | ||
43 | } | ||
44 | else | ||
45 | { | ||
46 | Pos = finalPos; | ||
47 | } | ||
48 | |||
49 | if (Pos > (s32)Data.size()) | ||
50 | Data.set_used(Pos+1); | ||
51 | |||
52 | return true; | ||
53 | |||
54 | } | ||
55 | |||
56 | const io::path& CMemoryReadWriteFile::getFileName() const | ||
57 | { | ||
58 | return FileName; | ||
59 | } | ||
60 | |||
61 | long CMemoryReadWriteFile::getPos() const | ||
62 | { | ||
63 | return Pos; | ||
64 | } | ||
65 | |||
66 | core::array<c8>& CMemoryReadWriteFile::getData() | ||
67 | { | ||
68 | return Data; | ||
69 | } | ||
70 | |||
71 | |||
72 | long CMemoryReadWriteFile::getSize() const | ||
73 | { | ||
74 | return Data.size(); | ||
75 | } | ||
76 | |||
77 | |||
78 | s32 CMemoryReadWriteFile::read(void* buffer, u32 sizeToRead) | ||
79 | { | ||
80 | // cant read past the end | ||
81 | if (Pos + sizeToRead >= Data.size()) | ||
82 | sizeToRead = Data.size() - Pos; | ||
83 | |||
84 | // cant read 0 bytes | ||
85 | if (!sizeToRead) | ||
86 | return 0; | ||
87 | |||
88 | // copy data | ||
89 | memcpy( buffer, (void*) &Data[Pos], (size_t) sizeToRead); | ||
90 | |||
91 | Pos += sizeToRead; | ||
92 | |||
93 | return sizeToRead; | ||
94 | } | ||
95 | |||