aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/irrlicht-1.8/source/Irrlicht/CReadFile.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/CReadFile.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/CReadFile.cpp')
-rw-r--r--libraries/irrlicht-1.8/source/Irrlicht/CReadFile.cpp228
1 files changed, 114 insertions, 114 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/CReadFile.cpp b/libraries/irrlicht-1.8/source/Irrlicht/CReadFile.cpp
index 2f067e6..cafbb03 100644
--- a/libraries/irrlicht-1.8/source/Irrlicht/CReadFile.cpp
+++ b/libraries/irrlicht-1.8/source/Irrlicht/CReadFile.cpp
@@ -1,114 +1,114 @@
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 "CReadFile.h" 5#include "CReadFile.h"
6 6
7namespace irr 7namespace irr
8{ 8{
9namespace io 9namespace io
10{ 10{
11 11
12 12
13CReadFile::CReadFile(const io::path& fileName) 13CReadFile::CReadFile(const io::path& fileName)
14: File(0), FileSize(0), Filename(fileName) 14: File(0), FileSize(0), Filename(fileName)
15{ 15{
16 #ifdef _DEBUG 16 #ifdef _DEBUG
17 setDebugName("CReadFile"); 17 setDebugName("CReadFile");
18 #endif 18 #endif
19 19
20 openFile(); 20 openFile();
21} 21}
22 22
23 23
24CReadFile::~CReadFile() 24CReadFile::~CReadFile()
25{ 25{
26 if (File) 26 if (File)
27 fclose(File); 27 fclose(File);
28} 28}
29 29
30 30
31//! returns how much was read 31//! returns how much was read
32s32 CReadFile::read(void* buffer, u32 sizeToRead) 32s32 CReadFile::read(void* buffer, u32 sizeToRead)
33{ 33{
34 if (!isOpen()) 34 if (!isOpen())
35 return 0; 35 return 0;
36 36
37 return (s32)fread(buffer, 1, sizeToRead, File); 37 return (s32)fread(buffer, 1, sizeToRead, File);
38} 38}
39 39
40 40
41//! changes position in file, returns true if successful 41//! changes position in file, returns true if successful
42//! if relativeMovement==true, the pos is changed relative to current pos, 42//! if relativeMovement==true, the pos is changed relative to current pos,
43//! otherwise from begin of file 43//! otherwise from begin of file
44bool CReadFile::seek(long finalPos, bool relativeMovement) 44bool CReadFile::seek(long finalPos, bool relativeMovement)
45{ 45{
46 if (!isOpen()) 46 if (!isOpen())
47 return false; 47 return false;
48 48
49 return fseek(File, finalPos, relativeMovement ? SEEK_CUR : SEEK_SET) == 0; 49 return fseek(File, finalPos, relativeMovement ? SEEK_CUR : SEEK_SET) == 0;
50} 50}
51 51
52 52
53//! returns size of file 53//! returns size of file
54long CReadFile::getSize() const 54long CReadFile::getSize() const
55{ 55{
56 return FileSize; 56 return FileSize;
57} 57}
58 58
59 59
60//! returns where in the file we are. 60//! returns where in the file we are.
61long CReadFile::getPos() const 61long CReadFile::getPos() const
62{ 62{
63 return ftell(File); 63 return ftell(File);
64} 64}
65 65
66 66
67//! opens the file 67//! opens the file
68void CReadFile::openFile() 68void CReadFile::openFile()
69{ 69{
70 if (Filename.size() == 0) // bugfix posted by rt 70 if (Filename.size() == 0) // bugfix posted by rt
71 { 71 {
72 File = 0; 72 File = 0;
73 return; 73 return;
74 } 74 }
75 75
76#if defined ( _IRR_WCHAR_FILESYSTEM ) 76#if defined ( _IRR_WCHAR_FILESYSTEM )
77 File = _wfopen(Filename.c_str(), L"rb"); 77 File = _wfopen(Filename.c_str(), L"rb");
78#else 78#else
79 File = fopen(Filename.c_str(), "rb"); 79 File = fopen(Filename.c_str(), "rb");
80#endif 80#endif
81 81
82 if (File) 82 if (File)
83 { 83 {
84 // get FileSize 84 // get FileSize
85 85
86 fseek(File, 0, SEEK_END); 86 fseek(File, 0, SEEK_END);
87 FileSize = getPos(); 87 FileSize = getPos();
88 fseek(File, 0, SEEK_SET); 88 fseek(File, 0, SEEK_SET);
89 } 89 }
90} 90}
91 91
92 92
93//! returns name of file 93//! returns name of file
94const io::path& CReadFile::getFileName() const 94const io::path& CReadFile::getFileName() const
95{ 95{
96 return Filename; 96 return Filename;
97} 97}
98 98
99 99
100 100
101IReadFile* createReadFile(const io::path& fileName) 101IReadFile* createReadFile(const io::path& fileName)
102{ 102{
103 CReadFile* file = new CReadFile(fileName); 103 CReadFile* file = new CReadFile(fileName);
104 if (file->isOpen()) 104 if (file->isOpen())
105 return file; 105 return file;
106 106
107 file->drop(); 107 file->drop();
108 return 0; 108 return 0;
109} 109}
110 110
111 111
112} // end namespace io 112} // end namespace io
113} // end namespace irr 113} // end namespace irr
114 114