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