aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/irrlicht-1.8/source/Irrlicht/CMountPointReader.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/CMountPointReader.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/CMountPointReader.cpp350
1 files changed, 175 insertions, 175 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/CMountPointReader.cpp b/libraries/irrlicht-1.8/source/Irrlicht/CMountPointReader.cpp
index e78c3ff..e100c37 100644
--- a/libraries/irrlicht-1.8/source/Irrlicht/CMountPointReader.cpp
+++ b/libraries/irrlicht-1.8/source/Irrlicht/CMountPointReader.cpp
@@ -1,175 +1,175 @@
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 "CMountPointReader.h" 5#include "CMountPointReader.h"
6 6
7#ifdef __IRR_COMPILE_WITH_MOUNT_ARCHIVE_LOADER_ 7#ifdef __IRR_COMPILE_WITH_MOUNT_ARCHIVE_LOADER_
8 8
9#include "CReadFile.h" 9#include "CReadFile.h"
10#include "os.h" 10#include "os.h"
11 11
12namespace irr 12namespace irr
13{ 13{
14namespace io 14namespace io
15{ 15{
16 16
17//! Constructor 17//! Constructor
18CArchiveLoaderMount::CArchiveLoaderMount( io::IFileSystem* fs) 18CArchiveLoaderMount::CArchiveLoaderMount( io::IFileSystem* fs)
19: FileSystem(fs) 19: FileSystem(fs)
20{ 20{
21 #ifdef _DEBUG 21 #ifdef _DEBUG
22 setDebugName("CArchiveLoaderMount"); 22 setDebugName("CArchiveLoaderMount");
23 #endif 23 #endif
24} 24}
25 25
26 26
27//! returns true if the file maybe is able to be loaded by this class 27//! returns true if the file maybe is able to be loaded by this class
28bool CArchiveLoaderMount::isALoadableFileFormat(const io::path& filename) const 28bool CArchiveLoaderMount::isALoadableFileFormat(const io::path& filename) const
29{ 29{
30 io::path fname(filename); 30 io::path fname(filename);
31 deletePathFromFilename(fname); 31 deletePathFromFilename(fname);
32 32
33 if (!fname.size()) 33 if (!fname.size())
34 return true; 34 return true;
35 IFileList* list = FileSystem->createFileList(); 35 IFileList* list = FileSystem->createFileList();
36 bool ret = false; 36 bool ret = false;
37 if (list) 37 if (list)
38 { 38 {
39 // check if name is found as directory 39 // check if name is found as directory
40 if (list->findFile(filename, true)) 40 if (list->findFile(filename, true))
41 ret=true; 41 ret=true;
42 list->drop(); 42 list->drop();
43 } 43 }
44 return ret; 44 return ret;
45} 45}
46 46
47//! Check to see if the loader can create archives of this type. 47//! Check to see if the loader can create archives of this type.
48bool CArchiveLoaderMount::isALoadableFileFormat(E_FILE_ARCHIVE_TYPE fileType) const 48bool CArchiveLoaderMount::isALoadableFileFormat(E_FILE_ARCHIVE_TYPE fileType) const
49{ 49{
50 return fileType == EFAT_FOLDER; 50 return fileType == EFAT_FOLDER;
51} 51}
52 52
53//! Check if the file might be loaded by this class 53//! Check if the file might be loaded by this class
54bool CArchiveLoaderMount::isALoadableFileFormat(io::IReadFile* file) const 54bool CArchiveLoaderMount::isALoadableFileFormat(io::IReadFile* file) const
55{ 55{
56 return false; 56 return false;
57} 57}
58 58
59//! Creates an archive from the filename 59//! Creates an archive from the filename
60IFileArchive* CArchiveLoaderMount::createArchive(const io::path& filename, bool ignoreCase, bool ignorePaths) const 60IFileArchive* CArchiveLoaderMount::createArchive(const io::path& filename, bool ignoreCase, bool ignorePaths) const
61{ 61{
62 IFileArchive *archive = 0; 62 IFileArchive *archive = 0;
63 63
64 EFileSystemType current = FileSystem->setFileListSystem(FILESYSTEM_NATIVE); 64 EFileSystemType current = FileSystem->setFileListSystem(FILESYSTEM_NATIVE);
65 65
66 const io::path save = FileSystem->getWorkingDirectory(); 66 const io::path save = FileSystem->getWorkingDirectory();
67 io::path fullPath = FileSystem->getAbsolutePath(filename); 67 io::path fullPath = FileSystem->getAbsolutePath(filename);
68 FileSystem->flattenFilename(fullPath); 68 FileSystem->flattenFilename(fullPath);
69 69
70 if (FileSystem->changeWorkingDirectoryTo(fullPath)) 70 if (FileSystem->changeWorkingDirectoryTo(fullPath))
71 { 71 {
72 archive = new CMountPointReader(FileSystem, fullPath, ignoreCase, ignorePaths); 72 archive = new CMountPointReader(FileSystem, fullPath, ignoreCase, ignorePaths);
73 } 73 }
74 74
75 FileSystem->changeWorkingDirectoryTo(save); 75 FileSystem->changeWorkingDirectoryTo(save);
76 FileSystem->setFileListSystem(current); 76 FileSystem->setFileListSystem(current);
77 77
78 return archive; 78 return archive;
79} 79}
80 80
81//! creates/loads an archive from the file. 81//! creates/loads an archive from the file.
82//! \return Pointer to the created archive. Returns 0 if loading failed. 82//! \return Pointer to the created archive. Returns 0 if loading failed.
83IFileArchive* CArchiveLoaderMount::createArchive(io::IReadFile* file, bool ignoreCase, bool ignorePaths) const 83IFileArchive* CArchiveLoaderMount::createArchive(io::IReadFile* file, bool ignoreCase, bool ignorePaths) const
84{ 84{
85 return 0; 85 return 0;
86} 86}
87 87
88//! compatible Folder Architecture 88//! compatible Folder Architecture
89CMountPointReader::CMountPointReader(IFileSystem * parent, const io::path& basename, bool ignoreCase, bool ignorePaths) 89CMountPointReader::CMountPointReader(IFileSystem * parent, const io::path& basename, bool ignoreCase, bool ignorePaths)
90 : CFileList(basename, ignoreCase, ignorePaths), Parent(parent) 90 : CFileList(basename, ignoreCase, ignorePaths), Parent(parent)
91{ 91{
92 //! ensure CFileList path ends in a slash 92 //! ensure CFileList path ends in a slash
93 if (Path.lastChar() != '/' ) 93 if (Path.lastChar() != '/' )
94 Path.append('/'); 94 Path.append('/');
95 95
96 const io::path& work = Parent->getWorkingDirectory(); 96 const io::path& work = Parent->getWorkingDirectory();
97 97
98 Parent->changeWorkingDirectoryTo(basename); 98 Parent->changeWorkingDirectoryTo(basename);
99 buildDirectory(); 99 buildDirectory();
100 Parent->changeWorkingDirectoryTo(work); 100 Parent->changeWorkingDirectoryTo(work);
101 101
102 sort(); 102 sort();
103} 103}
104 104
105 105
106//! returns the list of files 106//! returns the list of files
107const IFileList* CMountPointReader::getFileList() const 107const IFileList* CMountPointReader::getFileList() const
108{ 108{
109 return this; 109 return this;
110} 110}
111 111
112void CMountPointReader::buildDirectory() 112void CMountPointReader::buildDirectory()
113{ 113{
114 IFileList * list = Parent->createFileList(); 114 IFileList * list = Parent->createFileList();
115 if (!list) 115 if (!list)
116 return; 116 return;
117 117
118 const u32 size = list->getFileCount(); 118 const u32 size = list->getFileCount();
119 for (u32 i=0; i < size; ++i) 119 for (u32 i=0; i < size; ++i)
120 { 120 {
121 io::path full = list->getFullFileName(i); 121 io::path full = list->getFullFileName(i);
122 full = full.subString(Path.size(), full.size() - Path.size()); 122 full = full.subString(Path.size(), full.size() - Path.size());
123 123
124 if (!list->isDirectory(i)) 124 if (!list->isDirectory(i))
125 { 125 {
126 addItem(full, list->getFileOffset(i), list->getFileSize(i), false, RealFileNames.size()); 126 addItem(full, list->getFileOffset(i), list->getFileSize(i), false, RealFileNames.size());
127 RealFileNames.push_back(list->getFullFileName(i)); 127 RealFileNames.push_back(list->getFullFileName(i));
128 } 128 }
129 else 129 else
130 { 130 {
131 const io::path rel = list->getFileName(i); 131 const io::path rel = list->getFileName(i);
132 RealFileNames.push_back(list->getFullFileName(i)); 132 RealFileNames.push_back(list->getFullFileName(i));
133 133
134 io::path pwd = Parent->getWorkingDirectory(); 134 io::path pwd = Parent->getWorkingDirectory();
135 if (pwd.lastChar() != '/') 135 if (pwd.lastChar() != '/')
136 pwd.append('/'); 136 pwd.append('/');
137 pwd.append(rel); 137 pwd.append(rel);
138 138
139 if ( rel != "." && rel != ".." ) 139 if ( rel != "." && rel != ".." )
140 { 140 {
141 addItem(full, 0, 0, true, 0); 141 addItem(full, 0, 0, true, 0);
142 Parent->changeWorkingDirectoryTo(pwd); 142 Parent->changeWorkingDirectoryTo(pwd);
143 buildDirectory(); 143 buildDirectory();
144 Parent->changeWorkingDirectoryTo(".."); 144 Parent->changeWorkingDirectoryTo("..");
145 } 145 }
146 } 146 }
147 } 147 }
148 148
149 list->drop(); 149 list->drop();
150} 150}
151 151
152//! opens a file by index 152//! opens a file by index
153IReadFile* CMountPointReader::createAndOpenFile(u32 index) 153IReadFile* CMountPointReader::createAndOpenFile(u32 index)
154{ 154{
155 if (index >= Files.size()) 155 if (index >= Files.size())
156 return 0; 156 return 0;
157 157
158 return createReadFile(RealFileNames[Files[index].ID]); 158 return createReadFile(RealFileNames[Files[index].ID]);
159} 159}
160 160
161//! opens a file by file name 161//! opens a file by file name
162IReadFile* CMountPointReader::createAndOpenFile(const io::path& filename) 162IReadFile* CMountPointReader::createAndOpenFile(const io::path& filename)
163{ 163{
164 s32 index = findFile(filename, false); 164 s32 index = findFile(filename, false);
165 if (index != -1) 165 if (index != -1)
166 return createAndOpenFile(index); 166 return createAndOpenFile(index);
167 else 167 else
168 return 0; 168 return 0;
169} 169}
170 170
171 171
172} // io 172} // io
173} // irr 173} // irr
174 174
175#endif // __IRR_COMPILE_WITH_MOUNT_ARCHIVE_LOADER_ 175#endif // __IRR_COMPILE_WITH_MOUNT_ARCHIVE_LOADER_