aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/irrlicht-1.8/source/Irrlicht/CFileList.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/CFileList.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 '')
-rw-r--r--libraries/irrlicht-1.8/source/Irrlicht/CFileList.cpp330
1 files changed, 165 insertions, 165 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/CFileList.cpp b/libraries/irrlicht-1.8/source/Irrlicht/CFileList.cpp
index 1b8ff4f..eec1875 100644
--- a/libraries/irrlicht-1.8/source/Irrlicht/CFileList.cpp
+++ b/libraries/irrlicht-1.8/source/Irrlicht/CFileList.cpp
@@ -1,165 +1,165 @@
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 "CFileList.h" 5#include "CFileList.h"
6#include "IrrCompileConfig.h" 6#include "IrrCompileConfig.h"
7#include "irrArray.h" 7#include "irrArray.h"
8#include "coreutil.h" 8#include "coreutil.h"
9 9
10#include "os.h" 10#include "os.h"
11 11
12namespace irr 12namespace irr
13{ 13{
14namespace io 14namespace io
15{ 15{
16 16
17static const io::path emptyFileListEntry; 17static const io::path emptyFileListEntry;
18 18
19CFileList::CFileList(const io::path& path, bool ignoreCase, bool ignorePaths) 19CFileList::CFileList(const io::path& path, bool ignoreCase, bool ignorePaths)
20 : IgnorePaths(ignorePaths), IgnoreCase(ignoreCase), Path(path) 20 : IgnorePaths(ignorePaths), IgnoreCase(ignoreCase), Path(path)
21{ 21{
22 #ifdef _DEBUG 22 #ifdef _DEBUG
23 setDebugName("CFileList"); 23 setDebugName("CFileList");
24 #endif 24 #endif
25 25
26 Path.replace('\\', '/'); 26 Path.replace('\\', '/');
27} 27}
28 28
29CFileList::~CFileList() 29CFileList::~CFileList()
30{ 30{
31 Files.clear(); 31 Files.clear();
32} 32}
33 33
34u32 CFileList::getFileCount() const 34u32 CFileList::getFileCount() const
35{ 35{
36 return Files.size(); 36 return Files.size();
37} 37}
38 38
39void CFileList::sort() 39void CFileList::sort()
40{ 40{
41 Files.sort(); 41 Files.sort();
42} 42}
43 43
44const io::path& CFileList::getFileName(u32 index) const 44const io::path& CFileList::getFileName(u32 index) const
45{ 45{
46 if (index >= Files.size()) 46 if (index >= Files.size())
47 return emptyFileListEntry; 47 return emptyFileListEntry;
48 48
49 return Files[index].Name; 49 return Files[index].Name;
50} 50}
51 51
52 52
53//! Gets the full name of a file in the list, path included, based on an index. 53//! Gets the full name of a file in the list, path included, based on an index.
54const io::path& CFileList::getFullFileName(u32 index) const 54const io::path& CFileList::getFullFileName(u32 index) const
55{ 55{
56 if (index >= Files.size()) 56 if (index >= Files.size())
57 return emptyFileListEntry; 57 return emptyFileListEntry;
58 58
59 return Files[index].FullName; 59 return Files[index].FullName;
60} 60}
61 61
62//! adds a file or folder 62//! adds a file or folder
63u32 CFileList::addItem(const io::path& fullPath, u32 offset, u32 size, bool isDirectory, u32 id) 63u32 CFileList::addItem(const io::path& fullPath, u32 offset, u32 size, bool isDirectory, u32 id)
64{ 64{
65 SFileListEntry entry; 65 SFileListEntry entry;
66 entry.ID = id ? id : Files.size(); 66 entry.ID = id ? id : Files.size();
67 entry.Offset = offset; 67 entry.Offset = offset;
68 entry.Size = size; 68 entry.Size = size;
69 entry.Name = fullPath; 69 entry.Name = fullPath;
70 entry.Name.replace('\\', '/'); 70 entry.Name.replace('\\', '/');
71 entry.IsDirectory = isDirectory; 71 entry.IsDirectory = isDirectory;
72 72
73 // remove trailing slash 73 // remove trailing slash
74 if (entry.Name.lastChar() == '/') 74 if (entry.Name.lastChar() == '/')
75 { 75 {
76 entry.IsDirectory = true; 76 entry.IsDirectory = true;
77 entry.Name[entry.Name.size()-1] = 0; 77 entry.Name[entry.Name.size()-1] = 0;
78 entry.Name.validate(); 78 entry.Name.validate();
79 } 79 }
80 80
81 if (IgnoreCase) 81 if (IgnoreCase)
82 entry.Name.make_lower(); 82 entry.Name.make_lower();
83 83
84 entry.FullName = entry.Name; 84 entry.FullName = entry.Name;
85 85
86 core::deletePathFromFilename(entry.Name); 86 core::deletePathFromFilename(entry.Name);
87 87
88 if (IgnorePaths) 88 if (IgnorePaths)
89 entry.FullName = entry.Name; 89 entry.FullName = entry.Name;
90 90
91 //os::Printer::log(Path.c_str(), entry.FullName); 91 //os::Printer::log(Path.c_str(), entry.FullName);
92 92
93 Files.push_back(entry); 93 Files.push_back(entry);
94 94
95 return Files.size() - 1; 95 return Files.size() - 1;
96} 96}
97 97
98//! Returns the ID of a file in the file list, based on an index. 98//! Returns the ID of a file in the file list, based on an index.
99u32 CFileList::getID(u32 index) const 99u32 CFileList::getID(u32 index) const
100{ 100{
101 return index < Files.size() ? Files[index].ID : 0; 101 return index < Files.size() ? Files[index].ID : 0;
102} 102}
103 103
104bool CFileList::isDirectory(u32 index) const 104bool CFileList::isDirectory(u32 index) const
105{ 105{
106 bool ret = false; 106 bool ret = false;
107 if (index < Files.size()) 107 if (index < Files.size())
108 ret = Files[index].IsDirectory; 108 ret = Files[index].IsDirectory;
109 109
110 _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; 110 _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
111 return ret; 111 return ret;
112} 112}
113 113
114//! Returns the size of a file 114//! Returns the size of a file
115u32 CFileList::getFileSize(u32 index) const 115u32 CFileList::getFileSize(u32 index) const
116{ 116{
117 return index < Files.size() ? Files[index].Size : 0; 117 return index < Files.size() ? Files[index].Size : 0;
118} 118}
119 119
120//! Returns the size of a file 120//! Returns the size of a file
121u32 CFileList::getFileOffset(u32 index) const 121u32 CFileList::getFileOffset(u32 index) const
122{ 122{
123 return index < Files.size() ? Files[index].Offset : 0; 123 return index < Files.size() ? Files[index].Offset : 0;
124} 124}
125 125
126 126
127//! Searches for a file or folder within the list, returns the index 127//! Searches for a file or folder within the list, returns the index
128s32 CFileList::findFile(const io::path& filename, bool isDirectory = false) const 128s32 CFileList::findFile(const io::path& filename, bool isDirectory = false) const
129{ 129{
130 SFileListEntry entry; 130 SFileListEntry entry;
131 // we only need FullName to be set for the search 131 // we only need FullName to be set for the search
132 entry.FullName = filename; 132 entry.FullName = filename;
133 entry.IsDirectory = isDirectory; 133 entry.IsDirectory = isDirectory;
134 134
135 // exchange 135 // exchange
136 entry.FullName.replace('\\', '/'); 136 entry.FullName.replace('\\', '/');
137 137
138 // remove trailing slash 138 // remove trailing slash
139 if (entry.FullName.lastChar() == '/') 139 if (entry.FullName.lastChar() == '/')
140 { 140 {
141 entry.IsDirectory = true; 141 entry.IsDirectory = true;
142 entry.FullName[entry.FullName.size()-1] = 0; 142 entry.FullName[entry.FullName.size()-1] = 0;
143 entry.FullName.validate(); 143 entry.FullName.validate();
144 } 144 }
145 145
146 if (IgnoreCase) 146 if (IgnoreCase)
147 entry.FullName.make_lower(); 147 entry.FullName.make_lower();
148 148
149 if (IgnorePaths) 149 if (IgnorePaths)
150 core::deletePathFromFilename(entry.FullName); 150 core::deletePathFromFilename(entry.FullName);
151 151
152 return Files.binary_search(entry); 152 return Files.binary_search(entry);
153} 153}
154 154
155 155
156//! Returns the base path of the file list 156//! Returns the base path of the file list
157const io::path& CFileList::getPath() const 157const io::path& CFileList::getPath() const
158{ 158{
159 return Path; 159 return Path;
160} 160}
161 161
162 162
163} // end namespace irr 163} // end namespace irr
164} // end namespace io 164} // end namespace io
165 165