aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/irrlicht-1.8/source/Irrlicht/CMemoryFile.cpp
diff options
context:
space:
mode:
authorDavid Walter Seikel2013-01-13 18:54:10 +1000
committerDavid Walter Seikel2013-01-13 18:54:10 +1000
commit959831f4ef5a3e797f576c3de08cd65032c997ad (patch)
treee7351908be5995f0b325b2ebeaa02d5a34b82583 /libraries/irrlicht-1.8/source/Irrlicht/CMemoryFile.cpp
parentAdd info about changes to Irrlicht. (diff)
downloadSledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.zip
SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.tar.gz
SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.tar.bz2
SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.tar.xz
Remove damned ancient DOS line endings from Irrlicht. Hopefully I did not go overboard.
Diffstat (limited to 'libraries/irrlicht-1.8/source/Irrlicht/CMemoryFile.cpp')
-rw-r--r--libraries/irrlicht-1.8/source/Irrlicht/CMemoryFile.cpp244
1 files changed, 122 insertions, 122 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/CMemoryFile.cpp b/libraries/irrlicht-1.8/source/Irrlicht/CMemoryFile.cpp
index d25c1f2..cb6b04f 100644
--- a/libraries/irrlicht-1.8/source/Irrlicht/CMemoryFile.cpp
+++ b/libraries/irrlicht-1.8/source/Irrlicht/CMemoryFile.cpp
@@ -1,122 +1,122 @@
1// Copyright (C) 2002-2012 Nikolaus Gebhardt 1// Copyright (C) 2002-2012 Nikolaus Gebhardt
2// This file is part of the "Irrlicht Engine". 2// This file is part of the "Irrlicht Engine".
3// For conditions of distribution and use, see copyright notice in irrlicht.h 3// For conditions of distribution and use, see copyright notice in irrlicht.h
4 4
5#include "CMemoryFile.h" 5#include "CMemoryFile.h"
6#include "irrString.h" 6#include "irrString.h"
7 7
8namespace irr 8namespace irr
9{ 9{
10namespace io 10namespace io
11{ 11{
12 12
13 13
14CMemoryFile::CMemoryFile(void* memory, long len, const io::path& fileName, bool d) 14CMemoryFile::CMemoryFile(void* memory, long len, const io::path& fileName, bool d)
15: Buffer(memory), Len(len), Pos(0), Filename(fileName), deleteMemoryWhenDropped(d) 15: Buffer(memory), Len(len), Pos(0), Filename(fileName), deleteMemoryWhenDropped(d)
16{ 16{
17 #ifdef _DEBUG 17 #ifdef _DEBUG
18 setDebugName("CMemoryFile"); 18 setDebugName("CMemoryFile");
19 #endif 19 #endif
20} 20}
21 21
22 22
23CMemoryFile::~CMemoryFile() 23CMemoryFile::~CMemoryFile()
24{ 24{
25 if (deleteMemoryWhenDropped) 25 if (deleteMemoryWhenDropped)
26 delete [] (c8*)Buffer; 26 delete [] (c8*)Buffer;
27} 27}
28 28
29 29
30//! returns how much was read 30//! returns how much was read
31s32 CMemoryFile::read(void* buffer, u32 sizeToRead) 31s32 CMemoryFile::read(void* buffer, u32 sizeToRead)
32{ 32{
33 s32 amount = static_cast<s32>(sizeToRead); 33 s32 amount = static_cast<s32>(sizeToRead);
34 if (Pos + amount > Len) 34 if (Pos + amount > Len)
35 amount -= Pos + amount - Len; 35 amount -= Pos + amount - Len;
36 36
37 if (amount <= 0) 37 if (amount <= 0)
38 return 0; 38 return 0;
39 39
40 c8* p = (c8*)Buffer; 40 c8* p = (c8*)Buffer;
41 memcpy(buffer, p + Pos, amount); 41 memcpy(buffer, p + Pos, amount);
42 42
43 Pos += amount; 43 Pos += amount;
44 44
45 return amount; 45 return amount;
46} 46}
47 47
48//! returns how much was written 48//! returns how much was written
49s32 CMemoryFile::write(const void* buffer, u32 sizeToWrite) 49s32 CMemoryFile::write(const void* buffer, u32 sizeToWrite)
50{ 50{
51 s32 amount = static_cast<s32>(sizeToWrite); 51 s32 amount = static_cast<s32>(sizeToWrite);
52 if (Pos + amount > Len) 52 if (Pos + amount > Len)
53 amount -= Pos + amount - Len; 53 amount -= Pos + amount - Len;
54 54
55 if (amount <= 0) 55 if (amount <= 0)
56 return 0; 56 return 0;
57 57
58 c8* p = (c8*)Buffer; 58 c8* p = (c8*)Buffer;
59 memcpy(p + Pos, buffer, amount); 59 memcpy(p + Pos, buffer, amount);
60 60
61 Pos += amount; 61 Pos += amount;
62 62
63 return amount; 63 return amount;
64} 64}
65 65
66 66
67 67
68//! changes position in file, returns true if successful 68//! changes position in file, returns true if successful
69//! if relativeMovement==true, the pos is changed relative to current pos, 69//! if relativeMovement==true, the pos is changed relative to current pos,
70//! otherwise from begin of file 70//! otherwise from begin of file
71bool CMemoryFile::seek(long finalPos, bool relativeMovement) 71bool CMemoryFile::seek(long finalPos, bool relativeMovement)
72{ 72{
73 if (relativeMovement) 73 if (relativeMovement)
74 { 74 {
75 if (Pos + finalPos > Len) 75 if (Pos + finalPos > Len)
76 return false; 76 return false;
77 77
78 Pos += finalPos; 78 Pos += finalPos;
79 } 79 }
80 else 80 else
81 { 81 {
82 if (finalPos > Len) 82 if (finalPos > Len)
83 return false; 83 return false;
84 84
85 Pos = finalPos; 85 Pos = finalPos;
86 } 86 }
87 87
88 return true; 88 return true;
89} 89}
90 90
91 91
92//! returns size of file 92//! returns size of file
93long CMemoryFile::getSize() const 93long CMemoryFile::getSize() const
94{ 94{
95 return Len; 95 return Len;
96} 96}
97 97
98 98
99//! returns where in the file we are. 99//! returns where in the file we are.
100long CMemoryFile::getPos() const 100long CMemoryFile::getPos() const
101{ 101{
102 return Pos; 102 return Pos;
103} 103}
104 104
105 105
106//! returns name of file 106//! returns name of file
107const io::path& CMemoryFile::getFileName() const 107const io::path& CMemoryFile::getFileName() const
108{ 108{
109 return Filename; 109 return Filename;
110} 110}
111 111
112 112
113IReadFile* createMemoryReadFile(void* memory, long size, const io::path& fileName, bool deleteMemoryWhenDropped) 113IReadFile* createMemoryReadFile(void* memory, long size, const io::path& fileName, bool deleteMemoryWhenDropped)
114{ 114{
115 CMemoryFile* file = new CMemoryFile(memory, size, fileName, deleteMemoryWhenDropped); 115 CMemoryFile* file = new CMemoryFile(memory, size, fileName, deleteMemoryWhenDropped);
116 return file; 116 return file;
117} 117}
118 118
119 119
120} // end namespace io 120} // end namespace io
121} // end namespace irr 121} // end namespace irr
122 122