diff options
author | David Walter Seikel | 2013-01-13 18:54:10 +1000 |
---|---|---|
committer | David Walter Seikel | 2013-01-13 18:54:10 +1000 |
commit | 959831f4ef5a3e797f576c3de08cd65032c997ad (patch) | |
tree | e7351908be5995f0b325b2ebeaa02d5a34b82583 /libraries/irrlicht-1.8/source/Irrlicht/CWriteFile.cpp | |
parent | Add info about changes to Irrlicht. (diff) | |
download | SledjHamr-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/CWriteFile.cpp')
-rw-r--r-- | libraries/irrlicht-1.8/source/Irrlicht/CWriteFile.cpp | 246 |
1 files changed, 123 insertions, 123 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/CWriteFile.cpp b/libraries/irrlicht-1.8/source/Irrlicht/CWriteFile.cpp index f72ef38..6be6fd4 100644 --- a/libraries/irrlicht-1.8/source/Irrlicht/CWriteFile.cpp +++ b/libraries/irrlicht-1.8/source/Irrlicht/CWriteFile.cpp | |||
@@ -1,123 +1,123 @@ | |||
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 "CWriteFile.h" | 5 | #include "CWriteFile.h" |
6 | #include <stdio.h> | 6 | #include <stdio.h> |
7 | 7 | ||
8 | namespace irr | 8 | namespace irr |
9 | { | 9 | { |
10 | namespace io | 10 | namespace io |
11 | { | 11 | { |
12 | 12 | ||
13 | 13 | ||
14 | CWriteFile::CWriteFile(const io::path& fileName, bool append) | 14 | CWriteFile::CWriteFile(const io::path& fileName, bool append) |
15 | : FileSize(0) | 15 | : FileSize(0) |
16 | { | 16 | { |
17 | #ifdef _DEBUG | 17 | #ifdef _DEBUG |
18 | setDebugName("CWriteFile"); | 18 | setDebugName("CWriteFile"); |
19 | #endif | 19 | #endif |
20 | 20 | ||
21 | Filename = fileName; | 21 | Filename = fileName; |
22 | openFile(append); | 22 | openFile(append); |
23 | } | 23 | } |
24 | 24 | ||
25 | 25 | ||
26 | 26 | ||
27 | CWriteFile::~CWriteFile() | 27 | CWriteFile::~CWriteFile() |
28 | { | 28 | { |
29 | if (File) | 29 | if (File) |
30 | fclose(File); | 30 | fclose(File); |
31 | } | 31 | } |
32 | 32 | ||
33 | 33 | ||
34 | 34 | ||
35 | //! returns if file is open | 35 | //! returns if file is open |
36 | inline bool CWriteFile::isOpen() const | 36 | inline bool CWriteFile::isOpen() const |
37 | { | 37 | { |
38 | return File != 0; | 38 | return File != 0; |
39 | } | 39 | } |
40 | 40 | ||
41 | 41 | ||
42 | 42 | ||
43 | //! returns how much was read | 43 | //! returns how much was read |
44 | s32 CWriteFile::write(const void* buffer, u32 sizeToWrite) | 44 | s32 CWriteFile::write(const void* buffer, u32 sizeToWrite) |
45 | { | 45 | { |
46 | if (!isOpen()) | 46 | if (!isOpen()) |
47 | return 0; | 47 | return 0; |
48 | 48 | ||
49 | return (s32)fwrite(buffer, 1, sizeToWrite, File); | 49 | return (s32)fwrite(buffer, 1, sizeToWrite, File); |
50 | } | 50 | } |
51 | 51 | ||
52 | 52 | ||
53 | 53 | ||
54 | //! changes position in file, returns true if successful | 54 | //! changes position in file, returns true if successful |
55 | //! if relativeMovement==true, the pos is changed relative to current pos, | 55 | //! if relativeMovement==true, the pos is changed relative to current pos, |
56 | //! otherwise from begin of file | 56 | //! otherwise from begin of file |
57 | bool CWriteFile::seek(long finalPos, bool relativeMovement) | 57 | bool CWriteFile::seek(long finalPos, bool relativeMovement) |
58 | { | 58 | { |
59 | if (!isOpen()) | 59 | if (!isOpen()) |
60 | return false; | 60 | return false; |
61 | 61 | ||
62 | return fseek(File, finalPos, relativeMovement ? SEEK_CUR : SEEK_SET) == 0; | 62 | return fseek(File, finalPos, relativeMovement ? SEEK_CUR : SEEK_SET) == 0; |
63 | } | 63 | } |
64 | 64 | ||
65 | 65 | ||
66 | 66 | ||
67 | //! returns where in the file we are. | 67 | //! returns where in the file we are. |
68 | long CWriteFile::getPos() const | 68 | long CWriteFile::getPos() const |
69 | { | 69 | { |
70 | return ftell(File); | 70 | return ftell(File); |
71 | } | 71 | } |
72 | 72 | ||
73 | 73 | ||
74 | 74 | ||
75 | //! opens the file | 75 | //! opens the file |
76 | void CWriteFile::openFile(bool append) | 76 | void CWriteFile::openFile(bool append) |
77 | { | 77 | { |
78 | if (Filename.size() == 0) | 78 | if (Filename.size() == 0) |
79 | { | 79 | { |
80 | File = 0; | 80 | File = 0; |
81 | return; | 81 | return; |
82 | } | 82 | } |
83 | 83 | ||
84 | #if defined(_IRR_WCHAR_FILESYSTEM) | 84 | #if defined(_IRR_WCHAR_FILESYSTEM) |
85 | File = _wfopen(Filename.c_str(), append ? L"ab" : L"wb"); | 85 | File = _wfopen(Filename.c_str(), append ? L"ab" : L"wb"); |
86 | #else | 86 | #else |
87 | File = fopen(Filename.c_str(), append ? "ab" : "wb"); | 87 | File = fopen(Filename.c_str(), append ? "ab" : "wb"); |
88 | #endif | 88 | #endif |
89 | 89 | ||
90 | if (File) | 90 | if (File) |
91 | { | 91 | { |
92 | // get FileSize | 92 | // get FileSize |
93 | 93 | ||
94 | fseek(File, 0, SEEK_END); | 94 | fseek(File, 0, SEEK_END); |
95 | FileSize = ftell(File); | 95 | FileSize = ftell(File); |
96 | fseek(File, 0, SEEK_SET); | 96 | fseek(File, 0, SEEK_SET); |
97 | } | 97 | } |
98 | } | 98 | } |
99 | 99 | ||
100 | 100 | ||
101 | 101 | ||
102 | //! returns name of file | 102 | //! returns name of file |
103 | const io::path& CWriteFile::getFileName() const | 103 | const io::path& CWriteFile::getFileName() const |
104 | { | 104 | { |
105 | return Filename; | 105 | return Filename; |
106 | } | 106 | } |
107 | 107 | ||
108 | 108 | ||
109 | 109 | ||
110 | IWriteFile* createWriteFile(const io::path& fileName, bool append) | 110 | IWriteFile* createWriteFile(const io::path& fileName, bool append) |
111 | { | 111 | { |
112 | CWriteFile* file = new CWriteFile(fileName, append); | 112 | CWriteFile* file = new CWriteFile(fileName, append); |
113 | if (file->isOpen()) | 113 | if (file->isOpen()) |
114 | return file; | 114 | return file; |
115 | 115 | ||
116 | file->drop(); | 116 | file->drop(); |
117 | return 0; | 117 | return 0; |
118 | } | 118 | } |
119 | 119 | ||
120 | 120 | ||
121 | } // end namespace io | 121 | } // end namespace io |
122 | } // end namespace irr | 122 | } // end namespace irr |
123 | 123 | ||