Mercurial > fife-parpg
annotate engine/core/vfs/vfsdirectory.cpp @ 697:ecaa4d98f05f tip
Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
* Most of the GUIChan code has been refactored into its own gui/guichan module. However, references to the GuiFont class still persist in the Engine and GuiManager code and these will need further refactoring.
* GuiManager is now an abstract base class which specific implementations (e.g. GUIChan) should subclass.
* The GUIChan GUI code is now a concrete implementation of GuiManager, most of which is in the new GuiChanGuiManager class.
* The GUI code in the Console class has been refactored out of the Console and into the GUIChan module as its own GuiChanConsoleWidget class. The rest of the Console class related to executing commands was left largely unchanged.
* Existing client code may need to downcast the GuiManager pointer received from FIFE::Engine::getGuiManager() to GuiChanGuiManager, since not all functionality is represented in the GuiManager abstract base class. Python client code can use the new GuiChanGuiManager.castTo static method for this purpose.
author | M. George Hansen <technopolitica@gmail.com> |
---|---|
date | Sat, 18 Jun 2011 00:28:40 -1000 |
parents | f67e9f47526d |
children |
rev | line source |
---|---|
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
1 /*************************************************************************** |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
2 * Copyright (C) 2005-2008 by the FIFE team * |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
3 * http://www.fifengine.de * |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
4 * This file is part of FIFE. * |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
5 * * |
46
90005975cdbb
* Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
6 * FIFE is free software; you can redistribute it and/or * |
90005975cdbb
* Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
7 * modify it under the terms of the GNU Lesser General Public * |
90005975cdbb
* Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
8 * License as published by the Free Software Foundation; either * |
90005975cdbb
* Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
9 * version 2.1 of the License, or (at your option) any later version. * |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
10 * * |
46
90005975cdbb
* Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
11 * This library is distributed in the hope that it will be useful, * |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
46
90005975cdbb
* Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * |
90005975cdbb
* Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
14 * Lesser General Public License for more details. * |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
15 * * |
46
90005975cdbb
* Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
16 * You should have received a copy of the GNU Lesser General Public * |
90005975cdbb
* Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
17 * License along with this library; if not, write to the * |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
18 * Free Software Foundation, Inc., * |
46
90005975cdbb
* Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
20 ***************************************************************************/ |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
21 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
22 // Standard C++ library includes |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
23 #include <fstream> |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
24 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
25 // 3rd party library includes |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
26 #include <boost/filesystem/operations.hpp> |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
27 #include <boost/filesystem/path.hpp> |
689
f67e9f47526d
Fixed the VFSDirectory so that it is compatible with the different versions of boost::filesystem. It chooses the correct functions based on the boost version being used.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
421
diff
changeset
|
28 #include <boost/version.hpp> |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
29 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
30 // FIFE includes |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
31 // These includes are split up in two parts, separated by one empty line |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
32 // First block: files included from the FIFE root src directory |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
33 // Second block: files included from the same folder |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
34 #include "vfs/raw/rawdata.h" |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
35 #include "vfs/raw/rawdatafile.h" |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
36 #include "util/log/logger.h" |
421
293e812316c0
Fixed a bug where the editor would exit because of a boost exception when browsing to a directory that the user does not have access to. The vfs now catches the boost exception and throws a FIFE exception. Updated the filebrowser to catch the exception and display a warning to the user. fixes[t:413]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
390
diff
changeset
|
37 #include "util/base/exception.h" |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
38 #include "vfsdirectory.h" |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
39 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
40 namespace bfs = boost::filesystem; |
689
f67e9f47526d
Fixed the VFSDirectory so that it is compatible with the different versions of boost::filesystem. It chooses the correct functions based on the boost version being used.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
421
diff
changeset
|
41 |
f67e9f47526d
Fixed the VFSDirectory so that it is compatible with the different versions of boost::filesystem. It chooses the correct functions based on the boost version being used.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
421
diff
changeset
|
42 namespace |
f67e9f47526d
Fixed the VFSDirectory so that it is compatible with the different versions of boost::filesystem. It chooses the correct functions based on the boost version being used.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
421
diff
changeset
|
43 { |
f67e9f47526d
Fixed the VFSDirectory so that it is compatible with the different versions of boost::filesystem. It chooses the correct functions based on the boost version being used.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
421
diff
changeset
|
44 // grab the major and minor version of boost, |
f67e9f47526d
Fixed the VFSDirectory so that it is compatible with the different versions of boost::filesystem. It chooses the correct functions based on the boost version being used.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
421
diff
changeset
|
45 // calculations taken from boost/version.hpp |
f67e9f47526d
Fixed the VFSDirectory so that it is compatible with the different versions of boost::filesystem. It chooses the correct functions based on the boost version being used.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
421
diff
changeset
|
46 #define BOOST_MAJOR_VERSION BOOST_VERSION / 100000 |
f67e9f47526d
Fixed the VFSDirectory so that it is compatible with the different versions of boost::filesystem. It chooses the correct functions based on the boost version being used.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
421
diff
changeset
|
47 #define BOOST_MINOR_VERSION BOOST_VERSION / 100 % 1000 |
f67e9f47526d
Fixed the VFSDirectory so that it is compatible with the different versions of boost::filesystem. It chooses the correct functions based on the boost version being used.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
421
diff
changeset
|
48 |
f67e9f47526d
Fixed the VFSDirectory so that it is compatible with the different versions of boost::filesystem. It chooses the correct functions based on the boost version being used.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
421
diff
changeset
|
49 #if (BOOST_MAJOR_VERSION >= 1 && BOOST_MINOR_VERSION >= 46) |
f67e9f47526d
Fixed the VFSDirectory so that it is compatible with the different versions of boost::filesystem. It chooses the correct functions based on the boost version being used.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
421
diff
changeset
|
50 // this define will tell us to use boost filesystem |
f67e9f47526d
Fixed the VFSDirectory so that it is compatible with the different versions of boost::filesystem. It chooses the correct functions based on the boost version being used.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
421
diff
changeset
|
51 // version 3 since this is the default version of the library |
f67e9f47526d
Fixed the VFSDirectory so that it is compatible with the different versions of boost::filesystem. It chooses the correct functions based on the boost version being used.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
421
diff
changeset
|
52 // starting in boost version 1.46 and above |
f67e9f47526d
Fixed the VFSDirectory so that it is compatible with the different versions of boost::filesystem. It chooses the correct functions based on the boost version being used.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
421
diff
changeset
|
53 #define USE_BOOST_FILESYSTEM_V3 |
f67e9f47526d
Fixed the VFSDirectory so that it is compatible with the different versions of boost::filesystem. It chooses the correct functions based on the boost version being used.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
421
diff
changeset
|
54 #elif (BOOST_MAJOR_VERSION >= 1 && BOOST_MINOR_VERSION >= 36) |
f67e9f47526d
Fixed the VFSDirectory so that it is compatible with the different versions of boost::filesystem. It chooses the correct functions based on the boost version being used.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
421
diff
changeset
|
55 // this define will tell us not to use the deprecated functions |
f67e9f47526d
Fixed the VFSDirectory so that it is compatible with the different versions of boost::filesystem. It chooses the correct functions based on the boost version being used.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
421
diff
changeset
|
56 // in boost filesystem version 2 library which were introduced |
f67e9f47526d
Fixed the VFSDirectory so that it is compatible with the different versions of boost::filesystem. It chooses the correct functions based on the boost version being used.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
421
diff
changeset
|
57 // in boost version 1.36 and above |
f67e9f47526d
Fixed the VFSDirectory so that it is compatible with the different versions of boost::filesystem. It chooses the correct functions based on the boost version being used.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
421
diff
changeset
|
58 #define USE_NON_DEPRECATED_BOOST_FILESYSTEM_V2 |
f67e9f47526d
Fixed the VFSDirectory so that it is compatible with the different versions of boost::filesystem. It chooses the correct functions based on the boost version being used.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
421
diff
changeset
|
59 #endif |
f67e9f47526d
Fixed the VFSDirectory so that it is compatible with the different versions of boost::filesystem. It chooses the correct functions based on the boost version being used.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
421
diff
changeset
|
60 } |
f67e9f47526d
Fixed the VFSDirectory so that it is compatible with the different versions of boost::filesystem. It chooses the correct functions based on the boost version being used.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
421
diff
changeset
|
61 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
62 namespace FIFE { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
63 static Logger _log(LM_VFS); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
64 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
65 VFSDirectory::VFSDirectory(VFS* vfs, const std::string& root) : VFSSource(vfs), m_root(root) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
66 FL_DBG(_log, LMsg("VFSDirectory created with root path ") << m_root); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
67 if(!m_root.empty() && *(m_root.end() - 1) != '/') |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
68 m_root.append(1,'/'); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
69 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
70 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
71 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
72 VFSDirectory::~VFSDirectory() { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
73 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
74 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
75 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
76 bool VFSDirectory::fileExists(const std::string& name) const { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
77 std::string fullpath = m_root + name; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
78 std::ifstream file(fullpath.c_str()); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
79 if (file) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
80 return true; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
81 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
82 return false; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
83 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
84 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
85 RawData* VFSDirectory::open(const std::string& file) const { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
86 return new RawData(new RawDataFile(m_root + file)); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
87 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
88 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
89 std::set<std::string> VFSDirectory::listFiles(const std::string& path) const { |
202
1d9154c535cf
fixed bug where the root directory path name was being added to the filename twice. It was initially added in the listFiles/listDirectories functions and then added again in the private function list. I modified the code so it is only added in the list function now.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
189
diff
changeset
|
90 return list(path, false); |
1d9154c535cf
fixed bug where the root directory path name was being added to the filename twice. It was initially added in the listFiles/listDirectories functions and then added again in the private function list. I modified the code so it is only added in the list function now.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
189
diff
changeset
|
91 } |
1d9154c535cf
fixed bug where the root directory path name was being added to the filename twice. It was initially added in the listFiles/listDirectories functions and then added again in the private function list. I modified the code so it is only added in the list function now.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
189
diff
changeset
|
92 |
1d9154c535cf
fixed bug where the root directory path name was being added to the filename twice. It was initially added in the listFiles/listDirectories functions and then added again in the private function list. I modified the code so it is only added in the list function now.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
189
diff
changeset
|
93 std::set<std::string> VFSDirectory::listDirectories(const std::string& path) const { |
1d9154c535cf
fixed bug where the root directory path name was being added to the filename twice. It was initially added in the listFiles/listDirectories functions and then added again in the private function list. I modified the code so it is only added in the list function now.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
189
diff
changeset
|
94 return list(path, true); |
1d9154c535cf
fixed bug where the root directory path name was being added to the filename twice. It was initially added in the listFiles/listDirectories functions and then added again in the private function list. I modified the code so it is only added in the list function now.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
189
diff
changeset
|
95 } |
1d9154c535cf
fixed bug where the root directory path name was being added to the filename twice. It was initially added in the listFiles/listDirectories functions and then added again in the private function list. I modified the code so it is only added in the list function now.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
189
diff
changeset
|
96 |
1d9154c535cf
fixed bug where the root directory path name was being added to the filename twice. It was initially added in the listFiles/listDirectories functions and then added again in the private function list. I modified the code so it is only added in the list function now.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
189
diff
changeset
|
97 std::set<std::string> VFSDirectory::list(const std::string& path, bool directorys) const { |
1d9154c535cf
fixed bug where the root directory path name was being added to the filename twice. It was initially added in the listFiles/listDirectories functions and then added again in the private function list. I modified the code so it is only added in the list function now.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
189
diff
changeset
|
98 std::set<std::string> list; |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
99 std::string dir = m_root; |
202
1d9154c535cf
fixed bug where the root directory path name was being added to the filename twice. It was initially added in the listFiles/listDirectories functions and then added again in the private function list. I modified the code so it is only added in the list function now.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
189
diff
changeset
|
100 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
101 // Avoid double slashes |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
102 if(path[0] == '/' && m_root[m_root.size()-1] == '/') { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
103 dir.append(path.substr(1)); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
104 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
105 else { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
106 dir.append(path); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
107 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
108 |
421
293e812316c0
Fixed a bug where the editor would exit because of a boost exception when browsing to a directory that the user does not have access to. The vfs now catches the boost exception and throws a FIFE exception. Updated the filebrowser to catch the exception and display a warning to the user. fixes[t:413]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
390
diff
changeset
|
109 try { |
293e812316c0
Fixed a bug where the editor would exit because of a boost exception when browsing to a directory that the user does not have access to. The vfs now catches the boost exception and throws a FIFE exception. Updated the filebrowser to catch the exception and display a warning to the user. fixes[t:413]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
390
diff
changeset
|
110 bfs::path boost_path(dir); |
293e812316c0
Fixed a bug where the editor would exit because of a boost exception when browsing to a directory that the user does not have access to. The vfs now catches the boost exception and throws a FIFE exception. Updated the filebrowser to catch the exception and display a warning to the user. fixes[t:413]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
390
diff
changeset
|
111 if (!bfs::exists(boost_path) || !bfs::is_directory(boost_path)) |
293e812316c0
Fixed a bug where the editor would exit because of a boost exception when browsing to a directory that the user does not have access to. The vfs now catches the boost exception and throws a FIFE exception. Updated the filebrowser to catch the exception and display a warning to the user. fixes[t:413]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
390
diff
changeset
|
112 return list; |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
113 |
421
293e812316c0
Fixed a bug where the editor would exit because of a boost exception when browsing to a directory that the user does not have access to. The vfs now catches the boost exception and throws a FIFE exception. Updated the filebrowser to catch the exception and display a warning to the user. fixes[t:413]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
390
diff
changeset
|
114 bfs::directory_iterator end; |
293e812316c0
Fixed a bug where the editor would exit because of a boost exception when browsing to a directory that the user does not have access to. The vfs now catches the boost exception and throws a FIFE exception. Updated the filebrowser to catch the exception and display a warning to the user. fixes[t:413]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
390
diff
changeset
|
115 for (bfs::directory_iterator i(boost_path); i != end; ++i) { |
293e812316c0
Fixed a bug where the editor would exit because of a boost exception when browsing to a directory that the user does not have access to. The vfs now catches the boost exception and throws a FIFE exception. Updated the filebrowser to catch the exception and display a warning to the user. fixes[t:413]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
390
diff
changeset
|
116 if (bfs::is_directory(*i) != directorys) |
293e812316c0
Fixed a bug where the editor would exit because of a boost exception when browsing to a directory that the user does not have access to. The vfs now catches the boost exception and throws a FIFE exception. Updated the filebrowser to catch the exception and display a warning to the user. fixes[t:413]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
390
diff
changeset
|
117 continue; |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
118 |
689
f67e9f47526d
Fixed the VFSDirectory so that it is compatible with the different versions of boost::filesystem. It chooses the correct functions based on the boost version being used.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
421
diff
changeset
|
119 #if defined(USE_BOOST_FILESYSTEM_V3) |
f67e9f47526d
Fixed the VFSDirectory so that it is compatible with the different versions of boost::filesystem. It chooses the correct functions based on the boost version being used.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
421
diff
changeset
|
120 // boost version 1.46 and above uses |
f67e9f47526d
Fixed the VFSDirectory so that it is compatible with the different versions of boost::filesystem. It chooses the correct functions based on the boost version being used.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
421
diff
changeset
|
121 // boost filesystem version 3 as the default |
f67e9f47526d
Fixed the VFSDirectory so that it is compatible with the different versions of boost::filesystem. It chooses the correct functions based on the boost version being used.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
421
diff
changeset
|
122 // which has yet a different way of getting |
f67e9f47526d
Fixed the VFSDirectory so that it is compatible with the different versions of boost::filesystem. It chooses the correct functions based on the boost version being used.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
421
diff
changeset
|
123 // a filename string |
f67e9f47526d
Fixed the VFSDirectory so that it is compatible with the different versions of boost::filesystem. It chooses the correct functions based on the boost version being used.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
421
diff
changeset
|
124 bfs::path filenamePath = i->path().filename(); |
f67e9f47526d
Fixed the VFSDirectory so that it is compatible with the different versions of boost::filesystem. It chooses the correct functions based on the boost version being used.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
421
diff
changeset
|
125 list.insert(filenamePath.string()); |
f67e9f47526d
Fixed the VFSDirectory so that it is compatible with the different versions of boost::filesystem. It chooses the correct functions based on the boost version being used.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
421
diff
changeset
|
126 #elif defined(USE_NON_DEPRECATED_BOOST_FILESYSTEM_V2) |
f67e9f47526d
Fixed the VFSDirectory so that it is compatible with the different versions of boost::filesystem. It chooses the correct functions based on the boost version being used.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
421
diff
changeset
|
127 // the new way in boost filesystem version 2 |
f67e9f47526d
Fixed the VFSDirectory so that it is compatible with the different versions of boost::filesystem. It chooses the correct functions based on the boost version being used.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
421
diff
changeset
|
128 // to get a filename string |
f67e9f47526d
Fixed the VFSDirectory so that it is compatible with the different versions of boost::filesystem. It chooses the correct functions based on the boost version being used.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
421
diff
changeset
|
129 //(this is for boost version 1.36 and above) |
f67e9f47526d
Fixed the VFSDirectory so that it is compatible with the different versions of boost::filesystem. It chooses the correct functions based on the boost version being used.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
421
diff
changeset
|
130 list.insert(i->path().filename()); |
f67e9f47526d
Fixed the VFSDirectory so that it is compatible with the different versions of boost::filesystem. It chooses the correct functions based on the boost version being used.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
421
diff
changeset
|
131 #else |
f67e9f47526d
Fixed the VFSDirectory so that it is compatible with the different versions of boost::filesystem. It chooses the correct functions based on the boost version being used.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
421
diff
changeset
|
132 // the old way in boost filesystem version 2 |
f67e9f47526d
Fixed the VFSDirectory so that it is compatible with the different versions of boost::filesystem. It chooses the correct functions based on the boost version being used.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
421
diff
changeset
|
133 // to get a filename string |
f67e9f47526d
Fixed the VFSDirectory so that it is compatible with the different versions of boost::filesystem. It chooses the correct functions based on the boost version being used.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
421
diff
changeset
|
134 //(this is for boost version 1.35 and below) |
f67e9f47526d
Fixed the VFSDirectory so that it is compatible with the different versions of boost::filesystem. It chooses the correct functions based on the boost version being used.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
421
diff
changeset
|
135 list.insert(i->leaf()); |
f67e9f47526d
Fixed the VFSDirectory so that it is compatible with the different versions of boost::filesystem. It chooses the correct functions based on the boost version being used.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
421
diff
changeset
|
136 #endif |
421
293e812316c0
Fixed a bug where the editor would exit because of a boost exception when browsing to a directory that the user does not have access to. The vfs now catches the boost exception and throws a FIFE exception. Updated the filebrowser to catch the exception and display a warning to the user. fixes[t:413]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
390
diff
changeset
|
137 } |
293e812316c0
Fixed a bug where the editor would exit because of a boost exception when browsing to a directory that the user does not have access to. The vfs now catches the boost exception and throws a FIFE exception. Updated the filebrowser to catch the exception and display a warning to the user. fixes[t:413]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
390
diff
changeset
|
138 } |
293e812316c0
Fixed a bug where the editor would exit because of a boost exception when browsing to a directory that the user does not have access to. The vfs now catches the boost exception and throws a FIFE exception. Updated the filebrowser to catch the exception and display a warning to the user. fixes[t:413]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
390
diff
changeset
|
139 catch (const bfs::filesystem_error& ex) { |
293e812316c0
Fixed a bug where the editor would exit because of a boost exception when browsing to a directory that the user does not have access to. The vfs now catches the boost exception and throws a FIFE exception. Updated the filebrowser to catch the exception and display a warning to the user. fixes[t:413]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
390
diff
changeset
|
140 throw Exception(ex.what()); |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
141 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
142 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
143 return list; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
144 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
145 } |