Skip to content
Browse files

PFile ~> File merge

- ozCore
  * streams: setPos() -> seek(), reset() -> rewind()
  * PFile merged into File
- NaCl fixes
  • Loading branch information...
1 parent cb35dd6 commit 3fb4f9353a5dfec15fa0096ab679868d5f8594e6 @ducakar committed Jan 22, 2013
Showing with 1,208 additions and 1,521 deletions.
  1. +3 −2 ChangeLog.md
  2. +2 −4 TODO.md
  3. +5 −5 build.sh
  4. +1 −1 doc/licences/COPYING.FreeType.txt
  5. +34 −15 doc/licences/COPYING.PhysFS.txt
  6. +4 −3 doc/licences/COPYING.SDL2.txt
  7. +17 −15 doc/licences/COPYING.SDL_ttf.txt
  8. +2 −2 ports.sh
  9. +2 −2 run.sh
  10. +16 −16 src/builder/BSP.cc
  11. +47 −44 src/builder/Builder.cc
  12. +1 −1 src/builder/Caelum.cc
  13. +1 −1 src/builder/Class.cc
  14. +12 −12 src/builder/Context.cc
  15. +1 −1 src/builder/FragPool.cc
  16. +12 −12 src/builder/Lingua.cc
  17. +7 −7 src/builder/MD2.cc
  18. +14 −14 src/builder/MD3.cc
  19. +3 −3 src/builder/OBJ.cc
  20. +6 −6 src/builder/Terra.cc
  21. +7 −7 src/builder/UI.cc
  22. +1 −1 src/client/BSP.cc
  23. +1 −1 src/client/Caelum.cc
  24. +1 −1 src/client/CinematicProxy.cc
  25. +23 −18 src/client/Client.cc
  26. +3 −3 src/client/Context.cc
  27. +4 −4 src/client/GameStage.cc
  28. +2 −2 src/client/Input.cc
  29. +4 −4 src/client/Lua.cc
  30. +1 −1 src/client/MD2.cc
  31. +1 −1 src/client/MD3.cc
  32. +2 −2 src/client/MenuStage.cc
  33. +1 −1 src/client/NaClDownloader.cc
  34. +6 −6 src/client/NaClUpdater.cc
  35. +1 −1 src/client/Profile.cc
  36. +1 −1 src/client/SMM.cc
  37. +5 −5 src/client/Shader.cc
  38. +1 −1 src/client/Sound.cc
  39. +1 −1 src/client/Terra.cc
  40. +2 −2 src/client/ui/CreditsMenu.cc
  41. +1 −1 src/client/ui/Font.cc
  42. +1 −1 src/client/ui/GalileoFrame.cc
  43. +2 −2 src/client/ui/MainMenu.cc
  44. +4 −4 src/client/ui/MissionMenu.cc
  45. +1 −1 src/client/ui/Mouse.cc
  46. +1 −2 src/client/ui/Style.cc
  47. +7 −7 src/common/Lingua.cc
  48. +2 −2 src/matrix/BSP.cc
  49. +110 −110 src/matrix/Liber.cc
  50. +2 −2 src/matrix/Liber.hh
  51. +2 −2 src/matrix/Lua.cc
  52. +1 −1 src/matrix/NamePool.cc
  53. +1 −1 src/matrix/Terra.cc
  54. +2 −2 src/nirvana/Lua.cc
  55. +2 −2 src/ozCore/BufferStream.hh
  56. +0 −2 src/ozCore/CMakeLists.txt
  57. +698 −484 src/ozCore/File.cc
  58. +77 −29 src/ozCore/File.hh
  59. +2 −2 src/ozCore/InputStream.hh
  60. +1 −27 src/ozCore/JSON.cc
  61. +1 −20 src/ozCore/JSON.hh
  62. +4 −0 src/ozCore/Math.hh
  63. +2 −2 src/ozCore/OutputStream.hh
  64. +0 −333 src/ozCore/PFile.cc
  65. +0 −241 src/ozCore/PFile.hh
  66. +1 −1 src/ozCore/System.cc
  67. +16 −1 src/ozCore/Thread.cc
  68. +1 −1 src/ozCore/clearmacros.hh
  69. +0 −1 src/ozCore/ozCore.hh
  70. +1 −1 src/tests/test.cc
  71. +5 −5 src/tools/ozGettext.cc
  72. +2 −2 src/tools/ozManifest.cc
View
5 ChangeLog.md
@@ -8,13 +8,14 @@
+ STL-like begin() and end() members on containers
+ new Set template class: Map with arbitrary elements instead of key-value pairs
+ HashIndex and HashString merged into new HashMap template class with an arbitrary key type
- + new HashSet template class: hashtable of key-only elements instead of key-value pairs
- * String: constructing from numbers, number parsing functions
+ + new HashSet template class: hashtable of arbitrary elements instead of key-value pairs
+ * String: construction from numbers, number parsing functions
* new Mat33 class
* SIMD support for linear algebra classes
* new SpinLock class
* ALSA and OSS back-ends for System::bell()
* linear algebra classes added as primitives to streams, Log and JSON
+ * PFile class merged into File class
- ozDynamics
* collision
+ primitives: Box, Capsule, Mesh, Compound
View
6 TODO.md
@@ -1,11 +1,8 @@
CURRENT
- fix random splash event bug
-- keyboard control of UI
- TalkFrame
-- per-game data subdirs
- 6-direction-layered meshes
-- String: complete orthogonality for const char*
0.4
@@ -41,6 +38,7 @@ CURRENT
0.5
+- per-game data subdirs
- client
* networking
* video to texture
@@ -51,7 +49,7 @@ CURRENT
2.0
- ozCore
- * optional double precision
+ * optional double precision math
- ozDynamics
* finish ozDynamics
- matrix
View
10 build.sh
@@ -15,20 +15,20 @@
buildType=Debug
platforms=(
-# Linux-x86_64-Clang
-# Linux-x86_64-GCC
+ Linux-x86_64-Clang
+ Linux-x86_64-GCC
# Linux-i686-Clang
# Linux-i686-GCC
# FreeBSD-x86_64-Clang
# FreeBSD-x86_64-GCC
# FreeBSD-i686-Clang
# FreeBSD-i686-GCC
-# Windows-i686
-# NaCl-x86_64
+ Windows-i686
+ NaCl-x86_64
# NaCl-i686
# NaCl-ARM
# PNaCl
-# Android14-i686
+ Android14-i686
# Android14-ARM
# Android14-ARMv7a
# Android14-MIPS
View
2 doc/licences/COPYING.FreeType.txt
@@ -47,7 +47,7 @@ Introduction
credit/disclaimer to use in compliance with this license. We thus
encourage you to use the following text:
- """
+ """
Portions of this software are copyright � <year> The FreeType
Project (www.freetype.org). All rights reserved.
"""
View
49 doc/licences/COPYING.PhysFS.txt
@@ -1,21 +1,40 @@
-Copyright (c) 2001-2011 Ryan C. Gordon and others.
-This software is provided 'as-is', without any express or implied warranty.
-In no event will the authors be held liable for any damages arising from
-the use of this software.
+ Copyright (c) 2001-2011 Ryan C. Gordon and others.
-Permission is granted to anyone to use this software for any purpose,
-including commercial applications, and to alter it and redistribute it
-freely, subject to the following restrictions:
+ This software is provided 'as-is', without any express or implied warranty.
+ In no event will the authors be held liable for any damages arising from
+ the use of this software.
-1. The origin of this software must not be misrepresented; you must not
-claim that you wrote the original software. If you use this software in a
-product, an acknowledgment in the product documentation would be
-appreciated but is not required.
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
-2. Altered source versions must be plainly marked as such, and must not be
-misrepresented as being the original software.
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software in a
+ product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
-3. This notice may not be removed or altered from any source distribution.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+
+ 3. This notice may not be removed or altered from any source distribution.
+
+ Ryan C. Gordon <icculus@icculus.org>
+
+
+
+
+Notes, separate from the license. This is not legal advice.
+
+Versions of PhysicsFS prior to 0.1.9 are licensed under the GNU Lesser General
+ Public License, which restricts you significantly more. For your own safety,
+ please make sure you've got 0.1.9 or later if you plan to use physfs in a
+ commercial or closed-source project.
+
+Optional pieces of PhysicsFS may fall under other licenses, please consult
+your lawyer for legal advice, which this is not...
+
+ lzma: if you enable LZMA (7zip) support, PhysicsFS uses the lzma sdk.
+ It uses the LGPL license, with exceptions for closed-source programs.
+ Please see lzma/lzma.txt for details.
- Ryan C. Gordon <icculus@icculus.org>
View
7 doc/licences/COPYING.SDL2.txt
@@ -1,18 +1,19 @@
+
Simple DirectMedia Layer
Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
-
+
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
-
+
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
+ appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
View
32 doc/licences/COPYING.SDL_ttf.txt
@@ -1,18 +1,20 @@
-SDL_ttf: A companion library to SDL for working with TrueType (tm) fonts
-Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
+/*
+ SDL_ttf: A companion library to SDL for working with TrueType (tm) fonts
+ Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
-This software is provided 'as-is', without any express or implied
-warranty. In no event will the authors be held liable for any damages
-arising from the use of this software.
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
-Permission is granted to anyone to use this software for any purpose,
-including commercial applications, and to alter it and redistribute it
-freely, subject to the following restrictions:
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
-1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
-2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
-3. This notice may not be removed or altered from any source distribution.
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+*/
View
4 ports.sh
@@ -16,15 +16,15 @@
#
platforms=(
-# NaCl-x86_64
+ NaCl-x86_64
# NaCl-i686
# NaCl-ARM
# PNaCl
# Android14-i686
# Android14-ARM
# Android14-ARMv7a
# Android14-MIPS
- Emscripten
+# Emscripten
)
projectDir=`pwd`
View
4 run.sh
@@ -63,8 +63,8 @@ function run_nacl()
serverPID=$!
sleep 3
- chromium-browser --user-data-dir="$HOME/.config/chromium-test" \
- http://localhost:8000/openzone.sl.html || true
+ chromium --user-data-dir="$HOME/.config/chromium-test" \
+ http://localhost:8000/openzone.sl.html || true
kill $serverPID
}
View
32 src/builder/BSP.cc
@@ -44,8 +44,8 @@ const float BSP::GLASS_SPECULAR = 2.00f;
void BSP::load()
{
- PFile configFile( String::str( "baseq3/maps/%s.json", name.cstr() ) );
- PFile bspFile( String::str( "baseq3/maps/%s.bsp", name.cstr() ) );
+ File configFile( File::VIRTUAL, String::str( "baseq3/maps/%s.json", name.cstr() ) );
+ File bspFile( File::VIRTUAL, String::str( "baseq3/maps/%s.bsp", name.cstr() ) );
JSON config;
if( !config.load( configFile ) ) {
@@ -110,7 +110,7 @@ void BSP::load()
textures.resize( lumps[QBSPLump::TEXTURES].length / int( sizeof( QBSPTexture ) ) );
- is.reset();
+ is.rewind();
is.forward( lumps[QBSPLump::TEXTURES].offset );
for( int i = 0; i < textures.length(); ++i ) {
@@ -140,7 +140,7 @@ void BSP::load()
planes.resize( lumps[QBSPLump::PLANES].length / int( sizeof( QBSPPlane ) ) );
- is.reset();
+ is.rewind();
is.forward( lumps[QBSPLump::PLANES].offset );
for( int i = 0; i < planes.length(); ++i ) {
@@ -152,7 +152,7 @@ void BSP::load()
nodes.resize( lumps[QBSPLump::NODES].length / int( sizeof( QBSPNode ) ) );
- is.reset();
+ is.rewind();
is.forward( lumps[QBSPLump::NODES].offset );
for( int i = 0; i < nodes.length(); ++i ) {
@@ -171,7 +171,7 @@ void BSP::load()
leaves.resize( lumps[QBSPLump::LEAFS].length / int( sizeof( QBSPLeaf ) ) );
- is.reset();
+ is.rewind();
is.forward( lumps[QBSPLump::LEAFS].offset );
for( int i = 0; i < leaves.length(); ++i ) {
@@ -197,7 +197,7 @@ void BSP::load()
leafBrushes.resize( lumps[QBSPLump::LEAFBRUSHES].length / int( sizeof( int ) ) );
- is.reset();
+ is.rewind();
is.forward( lumps[QBSPLump::LEAFBRUSHES].offset );
for( int i = 0; i < leafBrushes.length(); ++i ) {
@@ -209,7 +209,7 @@ void BSP::load()
models.resize( nModels - 1 );
modelFaces.resize( nModels );
- is.reset();
+ is.rewind();
is.forward( lumps[QBSPLump::MODELS].offset );
const JSON& modelsConfig = config["entities"];
@@ -303,7 +303,7 @@ void BSP::load()
}
}
- is.reset();
+ is.rewind();
is.forward( lumps[QBSPLump::MODELS].offset );
for( int i = 0; i < models.length() + 1; ++i ) {
@@ -326,7 +326,7 @@ void BSP::load()
brushSides.resize( lumps[QBSPLump::BRUSHSIDES].length / int( sizeof( QBSPBrushSide ) ) );
- is.reset();
+ is.rewind();
is.forward( lumps[QBSPLump::BRUSHSIDES].offset );
for( int i = 0; i < brushSides.length(); ++i ) {
@@ -342,7 +342,7 @@ void BSP::load()
OZ_ERROR( "Too many brushes %d, maximum is %d", brushes.length(), matrix::BSP::MAX_BRUSHES );
}
- is.reset();
+ is.rewind();
is.forward( lumps[QBSPLump::BRUSHES].offset );
for( int i = 0; i < brushes.length(); ++i ) {
@@ -380,7 +380,7 @@ void BSP::load()
vertices.resize( lumps[QBSPLump::VERTICES].length / int( sizeof( QBSPVertex ) ) );
- is.reset();
+ is.rewind();
is.forward( lumps[QBSPLump::VERTICES].offset );
for( int i = 0; i < vertices.length(); ++i ) {
@@ -408,7 +408,7 @@ void BSP::load()
indices.resize( lumps[QBSPLump::INDICES].length / int( sizeof( int ) ) );
- is.reset();
+ is.rewind();
is.forward( lumps[QBSPLump::INDICES].offset );
for( int i = 0; i < indices.length(); ++i ) {
@@ -417,7 +417,7 @@ void BSP::load()
faces.resize( lumps[QBSPLump::FACES].length / int( sizeof( QBSPFace ) ) );
- is.reset();
+ is.rewind();
is.forward( lumps[QBSPLump::FACES].offset );
for( int i = 0; i < faces.length(); ++i ) {
@@ -987,7 +987,7 @@ void BSP::check() const
void BSP::saveMatrix()
{
- File destFile( "bsp/" + name + ".ozBSP" );
+ File destFile( File::NATIVE, "bsp/" + name + ".ozBSP" );
Log::print( "Dumping BSP structure to '%s' ...", destFile.path().cstr() );
@@ -1127,7 +1127,7 @@ void BSP::saveMatrix()
void BSP::saveClient()
{
- File destFile( "bsp/" + name + ".ozcBSP" );
+ File destFile( File::NATIVE, "bsp/" + name + ".ozcBSP" );
compiler.beginMesh();
View
91 src/builder/Builder.cc
@@ -84,8 +84,8 @@ void Builder::copyFiles( const char* srcDir, const char* destDir, const char* ex
{
String sSrcDir = srcDir;
String sDestDir = destDir;
- PFile dir( sSrcDir );
- DArray<PFile> dirList = dir.ls();
+ File dir( File::VIRTUAL, sSrcDir );
+ DArray<File> dirList = dir.ls();
if( dirList.isEmpty() ) {
return;
@@ -116,7 +116,7 @@ void Builder::copyFiles( const char* srcDir, const char* destDir, const char* ex
{
Log::print( "Copying '%s' ...", fileName.cstr() );
- File destFile( sDestDir + fileName );
+ File destFile( File::NATIVE, sDestDir + fileName );
if( !destFile.write( file->read() ) ) {
OZ_ERROR( "Failed to write '%s'", file->path().cstr() );
}
@@ -136,8 +136,8 @@ void Builder::buildCaela()
Log::indent();
String srcDir = "caelum";
- PFile dir( srcDir );
- DArray<PFile> dirList = dir.ls();
+ File dir( File::VIRTUAL, srcDir );
+ DArray<File> dirList = dir.ls();
srcDir = srcDir + "/";
@@ -162,8 +162,8 @@ void Builder::buildTerrae()
Log::indent();
String srcDir = "terra";
- PFile dir( srcDir );
- DArray<PFile> dirList = dir.ls();
+ File dir( File::VIRTUAL, srcDir );
+ DArray<File> dirList = dir.ls();
srcDir = srcDir + "/";
@@ -187,8 +187,8 @@ void Builder::buildBSPs()
String srcDir = "baseq3/maps";
String destDir = "bsp";
- PFile dir( srcDir );
- DArray<PFile> dirList = dir.ls();
+ File dir( File::VIRTUAL, srcDir );
+ DArray<File> dirList = dir.ls();
srcDir = srcDir + "/";
destDir = destDir + "/";
@@ -217,15 +217,15 @@ void Builder::buildBSPTextures()
Set<String> usedDirs;
- PFile dir( "baseq3/textures" );
- DArray<PFile> dirList = dir.ls();
+ File dir( File::VIRTUAL, "baseq3/textures" );
+ DArray<File> dirList = dir.ls();
foreach( subDir, dirList.iter() ) {
if( subDir->type() != File::DIRECTORY ) {
continue;
}
- DArray<PFile> texList = subDir->ls();
+ DArray<File> texList = subDir->ls();
foreach( file, texList.citer() ) {
String name = file->name();
@@ -260,7 +260,7 @@ void Builder::buildBSPTextures()
File::mkdir( "tex" );
File::mkdir( "tex/" + subDir->name() );
- File destFile( String::str( "tex/%s.ozcTex", name.cstr() ) );
+ File destFile( File::NATIVE, String::str( "tex/%s.ozcTex", name.cstr() ) );
Context::Texture diffuseTex, masksTex, normalsTex;
context.loadTextures( &diffuseTex, &masksTex, &normalsTex, path );
@@ -299,9 +299,9 @@ void Builder::buildBSPTextures()
}
foreach( subDirPath, usedDirs.citer() ) {
- PFile subDir( *subDirPath );
+ File subDir( File::VIRTUAL, *subDirPath );
- DArray<PFile> texList = subDir.ls();
+ DArray<File> texList = subDir.ls();
foreach( file, texList.iter() ) {
if( file->type() != File::REGULAR ) {
@@ -317,7 +317,7 @@ void Builder::buildBSPTextures()
File::mkdir( "tex" );
File::mkdir( "tex/" + subDir.name() );
- File destFile( String::str( "tex/%s/%s", subDir.name().cstr(), name.cstr() ) );
+ File destFile( File::NATIVE, String::str( "tex/%s/%s", subDir.name().cstr(), name.cstr() ) );
if( !destFile.write( file->read() ) ) {
OZ_ERROR( "Failed to write '%s'", destFile.path().cstr() );
}
@@ -338,8 +338,8 @@ void Builder::buildClasses( const String& pkgName )
Log::indent();
String dirName = "class";
- PFile dir( dirName );
- DArray<PFile> dirList = dir.ls();
+ File dir( File::VIRTUAL, dirName );
+ DArray<File> dirList = dir.ls();
BufferStream os;
@@ -389,7 +389,7 @@ void Builder::buildClasses( const String& pkgName )
headerStream.deallocate();
File::mkdir( "class" );
- File outFile( "class/" + pkgName + ".ozClasses" );
+ File outFile( File::NATIVE, "class/" + pkgName + ".ozClasses" );
Log::print( "Writing to '%s' ...", outFile.path().cstr() );
@@ -412,8 +412,8 @@ void Builder::buildFragPools( const String& pkgName )
Log::indent();
String dirName = "frag";
- PFile dir( dirName );
- DArray<PFile> dirList = dir.ls();
+ File dir( File::VIRTUAL, dirName );
+ DArray<File> dirList = dir.ls();
BufferStream os;
@@ -433,7 +433,7 @@ void Builder::buildFragPools( const String& pkgName )
if( os.length() != 0 ) {
File::mkdir( "frag" );
- File outFile( "frag/" + pkgName + ".ozFragPools" );
+ File outFile( File::NATIVE, "frag/" + pkgName + ".ozFragPools" );
Log::print( "Writing to '%s' ...", outFile.path().cstr() );
@@ -459,17 +459,17 @@ void Builder::buildModels()
Log::println( "Building used models {" );
Log::indent();
- PFile mdlDir( "mdl" );
+ File mdlDir( File::VIRTUAL, "mdl" );
File::mkdir( mdlDir.path() );
- DArray<PFile> dirList = mdlDir.ls();
+ DArray<File> dirList = mdlDir.ls();
foreach( dir, dirList.iter() ) {
if( !context.usedModels.contains( dir->name() ) ) {
continue;
}
File::mkdir( dir->path() );
- DArray<PFile> fileList = dir->ls();
+ DArray<File> fileList = dir->ls();
foreach( file, fileList.iter() ) {
if( file->type() != File::REGULAR ) {
@@ -482,7 +482,7 @@ void Builder::buildModels()
if( name.beginsWith( "COPYING" ) || name.beginsWith( "README" ) ) {
Log::print( "Copying '%s' ...", path.cstr() );
- File destFile( path );
+ File destFile( File::NATIVE, path );
if( !destFile.write( file->read() ) ) {
OZ_ERROR( "Failed to write '%s'", destFile.path().cstr() );
}
@@ -492,10 +492,10 @@ void Builder::buildModels()
}
}
- if( PFile( dir->path() + "/data.obj" ).type() != File::MISSING ) {
+ if( File( File::VIRTUAL, dir->path() + "/data.obj" ).type() != File::MISSING ) {
obj.build( dir->path() );
}
- else if( PFile( dir->path() + "/tris.md2" ).type() != File::MISSING ) {
+ else if( File( File::VIRTUAL, dir->path() + "/tris.md2" ).type() != File::MISSING ) {
md2.build( dir->path() );
}
else {
@@ -518,15 +518,15 @@ void Builder::copySounds()
Set<String> usedDirs;
- PFile dir( "snd" );
- DArray<PFile> dirList = dir.ls();
+ File dir( File::VIRTUAL, "snd" );
+ DArray<File> dirList = dir.ls();
foreach( subDir, dirList.iter() ) {
if( subDir->type() != File::DIRECTORY ) {
continue;
}
- DArray<PFile> sndList = subDir->ls();
+ DArray<File> sndList = subDir->ls();
foreach( file, sndList.iter() ) {
if( file->type() != File::REGULAR ) {
@@ -558,7 +558,7 @@ void Builder::copySounds()
File::mkdir( "snd" );
File::mkdir( "snd/" + subDir->name() );
- File destFile( file->path() );
+ File destFile( File::NATIVE, file->path() );
if( !destFile.write( file->read() ) ) {
OZ_ERROR( "Failed to write '%s'", destFile.path().cstr() );
}
@@ -568,8 +568,8 @@ void Builder::copySounds()
}
foreach( subDirPath, usedDirs.citer() ) {
- PFile subDir( *subDirPath );
- DArray<PFile> texList = subDir.ls();
+ File subDir( File::VIRTUAL, *subDirPath );
+ DArray<File> texList = subDir.ls();
foreach( file, texList.iter() ) {
if( file->type() != File::REGULAR ) {
@@ -585,7 +585,7 @@ void Builder::copySounds()
File::mkdir( "snd" );
File::mkdir( "snd/" + subDir.name() );
- File destFile( path );
+ File destFile( File::NATIVE, path );
if( !destFile.write( file->read() ) ) {
OZ_ERROR( "Failed to write '%s'", destFile.path().cstr() );
}
@@ -615,8 +615,8 @@ void Builder::checkLua( const char* path )
Log::indent();
String srcDir = String::str( "%s/", path );
- PFile dir( path );
- DArray<PFile> dirList = dir.ls();
+ File dir( File::VIRTUAL, path );
+ DArray<File> dirList = dir.ls();
String sources;
@@ -642,15 +642,15 @@ void Builder::buildMissions()
Log::println( "Building missions {" );
Log::indent();
- DArray<PFile> missions = PFile( "mission" ).ls();
+ DArray<File> missions = File( File::VIRTUAL, "mission" ).ls();
foreach( mission, missions.citer() ) {
checkLua( mission->path() );
copyFiles( mission->path(), mission->path(), "lua", false );
copyFiles( mission->path(), mission->path(), "json", false );
- PFile srcFile( mission->path() + "/description.png" );
- File outFile( mission->path() + "/description.ozImage" );
+ File srcFile( File::VIRTUAL, mission->path() + "/description.png" );
+ File outFile( File::NATIVE, mission->path() + "/description.ozImage" );
if( srcFile.type() == File::MISSING ) {
continue;
@@ -683,7 +683,7 @@ void Builder::packArchive( const char* name, bool useCompression, bool use7zip )
Log::println( "Packing archive {" );
Log::indent();
- File archive( String::str( "../%s.%s", name, use7zip ? "7z" : "zip" ) );
+ File archive( File::NATIVE, String::str( "../%s.%s", name, use7zip ? "7z" : "zip" ) );
String cmdLine = use7zip ? String::str( "7z u -ms=off -mx=9 '%s' *", archive.path().cstr() ) :
String::str( "zip -ur %s '%s' *",
@@ -696,6 +696,9 @@ void Builder::packArchive( const char* name, bool useCompression, bool use7zip )
OZ_ERROR( use7zip ? "Packing 7zip archive failed" : "Packing ZIP archive failed" );
}
+ // Re-stat file since it changed on disk.
+ archive.stat();
+
int size = archive.size();
if( size >= 0 ) {
Log::println();
@@ -871,7 +874,7 @@ int Builder::main( int argc, char** argv )
outDir = File::cwd() + "/" + outDir + "/" + pkgName;
}
- PFile::init();
+ File::init( File::VIRTUAL );
FreeImage_Initialise();
File::mkdir( outDir );
@@ -882,7 +885,7 @@ int Builder::main( int argc, char** argv )
}
Log::println( "Adding source directory '%s' to search path", srcDir.cstr() );
- if( !PFile::mount( srcDir, nullptr, true ) ) {
+ if( !File::mount( srcDir, nullptr, true ) ) {
OZ_ERROR( "Failed to add directory '%s' to search path", srcDir.cstr() );
}
@@ -976,7 +979,7 @@ int Builder::main( int argc, char** argv )
config.clear();
FreeImage_DeInitialise();
- PFile::destroy();
+ File::destroy( File::VIRTUAL );
return EXIT_SUCCESS;
}
View
2 src/builder/Caelum.cc
@@ -40,7 +40,7 @@ void Caelum::build( const char* name )
Log::println( "Prebuilding Caelum '%s' {", name );
Log::indent();
- File destFile( String::str( "caelum/%s.ozcCaelum", name ) );
+ File destFile( File::NATIVE, String::str( "caelum/%s.ozcCaelum", name ) );
BufferStream os;
View
2 src/builder/Class.cc
@@ -765,7 +765,7 @@ void Class::writeVehicle( BufferStream* os )
void Class::build( BufferStream* os, const char* className )
{
- PFile configFile( String::str( "class/%s.json", className ) );
+ File configFile( File::VIRTUAL, String::str( "class/%s.json", className ) );
if( !config.load( configFile ) ) {
OZ_ERROR( "Failed to load '%s'", configFile.path().cstr() );
View
24 src/builder/Context.cc
@@ -309,7 +309,7 @@ Context::Image Context::loadImage( const char* path, int forceFormat )
{
Log::print( "Loading image '%s' ...", path );
- PFile file( path );
+ File file( File::VIRTUAL, path );
String realPath = file.realDir() + "/" + file.path();
if( file.type() == File::MISSING ) {
@@ -437,42 +437,42 @@ void Context::loadTextures( Texture* diffuseTex, Texture* masksTex, Texture* nor
String normals2BasePath = basePath + "_normal";
String normals3BasePath = basePath + "_local";
- PFile diffuse, masks, specular, emission, normals;
+ File diffuse, masks, specular, emission, normals;
for( int i = 0; i < aLength( IMAGE_EXTENSIONS ); ++i ) {
if( diffuse.path().isEmpty() || diffuse.type() == File::MISSING ) {
- diffuse = PFile( diffuseBasePath + IMAGE_EXTENSIONS[i] );
+ diffuse = File( File::VIRTUAL, diffuseBasePath + IMAGE_EXTENSIONS[i] );
}
if( diffuse.type() == File::MISSING ) {
- diffuse = PFile( diffuse1BasePath + IMAGE_EXTENSIONS[i] );
+ diffuse = File( File::VIRTUAL, diffuse1BasePath + IMAGE_EXTENSIONS[i] );
}
if( masks.path().isEmpty() || masks.type() == File::MISSING ) {
- masks = PFile( masksBasePath + IMAGE_EXTENSIONS[i] );
+ masks = File( File::VIRTUAL, masksBasePath + IMAGE_EXTENSIONS[i] );
}
if( specular.path().isEmpty() || specular.type() == File::MISSING ) {
- specular = PFile( specularBasePath + IMAGE_EXTENSIONS[i] );
+ specular = File( File::VIRTUAL, specularBasePath + IMAGE_EXTENSIONS[i] );
}
if( specular.type() == File::MISSING ) {
- specular = PFile( specular1BasePath + IMAGE_EXTENSIONS[i] );
+ specular = File( File::VIRTUAL, specular1BasePath + IMAGE_EXTENSIONS[i] );
}
if( emission.path().isEmpty() || emission.type() == File::MISSING ) {
- emission = PFile( emissionBasePath + IMAGE_EXTENSIONS[i] );
+ emission = File( File::VIRTUAL, emissionBasePath + IMAGE_EXTENSIONS[i] );
}
if( normals.path().isEmpty() || normals.type() == File::MISSING ) {
- normals = PFile( normalsBasePath + IMAGE_EXTENSIONS[i] );
+ normals = File( File::VIRTUAL, normalsBasePath + IMAGE_EXTENSIONS[i] );
}
if( normals.type() == File::MISSING ) {
- normals = PFile( normals1BasePath + IMAGE_EXTENSIONS[i] );
+ normals = File( File::VIRTUAL, normals1BasePath + IMAGE_EXTENSIONS[i] );
}
if( normals.type() == File::MISSING ) {
- normals = PFile( normals2BasePath + IMAGE_EXTENSIONS[i] );
+ normals = File( File::VIRTUAL, normals2BasePath + IMAGE_EXTENSIONS[i] );
}
if( normals.type() == File::MISSING ) {
- normals = PFile( normals3BasePath + IMAGE_EXTENSIONS[i] );
+ normals = File( File::VIRTUAL, normals3BasePath + IMAGE_EXTENSIONS[i] );
}
}
View
2 src/builder/FragPool.cc
@@ -38,7 +38,7 @@ namespace builder
void FragPool::build( BufferStream* os, const char* className )
{
- PFile configFile( String::str( "frag/%s.json", className ) );
+ File configFile( File::VIRTUAL, String::str( "frag/%s.json", className ) );
JSON config;
if( !config.load( configFile ) ) {
View
24 src/builder/Lingua.cc
@@ -31,8 +31,8 @@ void Lingua::buildCatalogue( const char* directory, const char* catalogue )
File::mkdir( directory );
- PFile srcFile( String::str( "%s/%s.po", directory, catalogue ) );
- File outFile( String::str( "%s/%s.ozCat", directory, catalogue ) );
+ File srcFile( File::VIRTUAL, String::str( "%s/%s.po", directory, catalogue ) );
+ File outFile( File::NATIVE, String::str( "%s/%s.ozCat", directory, catalogue ) );
if( srcFile.type() != File::REGULAR ) {
OZ_ERROR( "Cannot read catalogue source file '%s'", srcFile.path().cstr() );
@@ -161,8 +161,8 @@ void Lingua::build()
Log::println( "Building package localisations {" );
Log::indent();
- PFile linguaDir( "lingua" );
- DArray<PFile> languages = linguaDir.ls();
+ File linguaDir( File::VIRTUAL, "lingua" );
+ DArray<File> languages = linguaDir.ls();
if( !languages.isEmpty() ) {
File::mkdir( linguaDir.path() );
@@ -173,7 +173,7 @@ void Lingua::build()
continue;
}
- DArray<PFile> catalogues = langDir->ls();
+ DArray<File> catalogues = langDir->ls();
if( !catalogues.isEmpty() ) {
File::mkdir( langDir->path() );
@@ -188,11 +188,11 @@ void Lingua::build()
}
}
- PFile missionsDir( "mission" );
- DArray<PFile> missions = missionsDir.ls();
+ File missionsDir( File::VIRTUAL, "mission" );
+ DArray<File> missions = missionsDir.ls();
foreach( mission, missions.citer() ) {
- linguaDir = PFile( mission->path() + "/lingua" );
+ linguaDir = File( File::VIRTUAL, mission->path() + "/lingua" );
languages = linguaDir.ls();
foreach( catalogue, languages.citer() ) {
@@ -217,12 +217,12 @@ void Lingua::buildMissions()
Log::println( "Building mission localisations {" );
Log::indent();
- PFile missionsDir( "mission" );
- DArray<PFile> missions = missionsDir.ls();
+ File missionsDir( File::VIRTUAL, "mission" );
+ DArray<File> missions = missionsDir.ls();
foreach( mission, missions.citer() ) {
- PFile linguaDir( mission->path() + "/lingua" );
- DArray<PFile> languages = linguaDir.ls();
+ File linguaDir( File::VIRTUAL, mission->path() + "/lingua" );
+ DArray<File> languages = linguaDir.ls();
foreach( catalogue, languages.citer() ) {
if( !catalogue->hasExtension( "po" ) ) {
View
14 src/builder/MD2.cc
@@ -204,8 +204,8 @@ void MD2::build( const char* path )
{
String sPath = path;
- PFile modelFile( sPath + "/tris.md2" );
- PFile configFile( sPath + "/config.json" );
+ File modelFile( File::VIRTUAL, sPath + "/tris.md2" );
+ File configFile( File::VIRTUAL, sPath + "/config.json" );
String skinPath = sPath + "/skin";
Log::println( "Prebuilding MD2 model '%s' {", path );
@@ -289,7 +289,7 @@ void MD2::build( const char* path )
DArray<Vec3> normals( header.nFrames * header.nFramePositions );
DArray<Point> positions( header.nFrames * header.nFramePositions );
- is.reset();
+ is.rewind();
is.forward( header.offFrames );
const char* frameData = is.forward( header.nFrames * header.frameSize );
@@ -319,15 +319,15 @@ void MD2::build( const char* path )
}
}
- is.reset();
+ is.rewind();
is.forward( header.offTexCoords );
for( int i = 0; i < texCoords.length(); ++i ) {
texCoords[i].u = float( is.readShort() ) / float( header.skinWidth );
texCoords[i].v = float( header.skinHeight - is.readShort() ) / float( header.skinHeight );
}
- is.reset();
+ is.rewind();
is.forward( header.offTriangles );
for( int i = 0; i < triangles.length(); ++i ) {
@@ -389,7 +389,7 @@ void MD2::build( const char* path )
File::mkdir( sPath );
if( header.nFrames != 1 ) {
- File destFile( sPath + "/data.ozcMD2" );
+ File destFile( File::NATIVE, sPath + "/data.ozcMD2" );
Log::print( "Writing to '%s' ...", destFile.path().cstr() );
@@ -400,7 +400,7 @@ void MD2::build( const char* path )
Log::printEnd( " OK" );
}
else {
- File destFile( sPath + "/data.ozcSMM" );
+ File destFile( File::NATIVE, sPath + "/data.ozcSMM" );
Log::print( "Writing to '%s' ...", destFile.path().cstr() );
View
28 src/builder/MD3.cc
@@ -35,7 +35,7 @@ namespace builder
void MD3::readAnimData()
{
- PFile animFile( sPath + "/animation.cfg" );
+ File animFile( File::VIRTUAL, sPath + "/animation.cfg" );
String realPath = animFile.realDir() + "/" + animFile.path();
@@ -57,7 +57,7 @@ void MD3::buildMesh( const char* name, int frame )
{
Log::print( "Mesh '%s' ...", name );
- PFile file( String::str( "%s/%s.md3", sPath.cstr(), name ) );
+ File file( File::VIRTUAL, String::str( "%s/%s.md3", sPath.cstr(), name ) );
if( file.type() != File::REGULAR ) {
OZ_ERROR( "Cannot read MD3 model part file '%s'", file.path().cstr() );
@@ -103,7 +103,7 @@ void MD3::buildMesh( const char* name, int frame )
}
if( header.nTags != 0 ) {
- is.reset();
+ is.rewind();
is.forward( header.offTags );
for( int i = 0; i < header.nTags; ++i ) {
@@ -151,7 +151,7 @@ void MD3::buildMesh( const char* name, int frame )
// FIXME indexBase unused
int indexBase = 0;
- is.reset();
+ is.rewind();
is.forward( header.offSurfaces );
for( int i = 0; i < header.nSurfaces; ++i ) {
@@ -193,7 +193,7 @@ void MD3::buildMesh( const char* name, int frame )
DArray<Vec3> normals( surfaceVertices.length() );
DArray<Point> vertices( surfaceVertices.length() );
- is.reset();
+ is.rewind();
is.forward( surfaceStart + surface.offTriangles );
for( int j = 0; j < surfaceTriangles.length(); ++j ) {
@@ -202,7 +202,7 @@ void MD3::buildMesh( const char* name, int frame )
surfaceTriangles[j].vertices[2] = is.readInt();
}
- is.reset();
+ is.rewind();
is.forward( surfaceStart + surface.offShaders );
for( int i = 0; i < surfaceShaders.length(); ++i ) {
@@ -211,23 +211,23 @@ void MD3::buildMesh( const char* name, int frame )
}
if( skin.isEmpty() ) {
- PFile skinFile( String::replace( surfaceShaders[0].name, '\\', '/' ) );
+ File skinFile( File::VIRTUAL, String::replace( surfaceShaders[0].name, '\\', '/' ) );
texture = skinFile.baseName();
}
else {
- PFile skinFile( skin );
+ File skinFile( File::VIRTUAL, skin );
texture = skinFile.baseName();
}
- is.reset();
+ is.rewind();
is.forward( surfaceStart + surface.offTexCoords );
for( int j = 0; j < surfaceTexCoords.length(); ++j ) {
surfaceTexCoords[j].u = is.readFloat();
surfaceTexCoords[j].v = 1.0f - is.readFloat();
}
- is.reset();
+ is.rewind();
is.forward( surfaceStart + surface.offVertices );
for( int j = 0; j < surfaceVertices.length(); ++j ) {
@@ -244,7 +244,7 @@ void MD3::buildMesh( const char* name, int frame )
normals[j].z = +Math::cos( v );
}
- is.reset();
+ is.rewind();
is.forward( surfaceStart + surface.offEnd );
compiler.texture( sPath + "/" + texture );
@@ -272,7 +272,7 @@ void MD3::buildMesh( const char* name, int frame )
void MD3::load()
{
- PFile configFile( sPath + "/config.json" );
+ File configFile( File::VIRTUAL, sPath + "/config.json" );
JSON config( configFile );
@@ -363,7 +363,7 @@ void MD3::save()
File::mkdir( sPath );
if( frame < 0 ) {
- File destFile( sPath + "/data.ozcMD3" );
+ File destFile( File::NATIVE, sPath + "/data.ozcMD3" );
Log::print( "Writing to '%s' ...", destFile.path().cstr() );
@@ -374,7 +374,7 @@ void MD3::save()
Log::printEnd( " OK" );
}
else {
- File destFile( sPath + "/data.ozcSMM" );
+ File destFile( File::NATIVE, sPath + "/data.ozcSMM" );
Log::print( "Writing to '%s' ...", destFile.path().cstr() );
View
6 src/builder/OBJ.cc
@@ -274,8 +274,8 @@ void OBJ::load()
{
Log::print( "Loading OBJ model '%s' ...", path.cstr() );
- PFile modelFile( path + "/data.obj" );
- PFile configFile( path + "/config.json" );
+ File modelFile( File::VIRTUAL, path + "/data.obj" );
+ File configFile( File::VIRTUAL, path + "/config.json" );
int currentMaterial = 0;
@@ -357,7 +357,7 @@ void OBJ::load()
void OBJ::save()
{
File::mkdir( path );
- File destFile( path + "/data.ozcSMM" );
+ File destFile( File::NATIVE, path + "/data.ozcSMM" );
compiler.beginMesh();
compiler.enable( Compiler::UNIQUE );
View
12 src/builder/Terra.cc
@@ -36,8 +36,8 @@ namespace builder
void Terra::load()
{
- PFile configFile( "terra/" + name + ".json" );
- PFile imageFile( "terra/" + name + ".png" );
+ File configFile( File::VIRTUAL, "terra/" + name + ".json" );
+ File imageFile( File::VIRTUAL, "terra/" + name + ".png" );
JSON config;
if( !config.load( configFile ) ) {
@@ -152,7 +152,7 @@ void Terra::load()
void Terra::saveMatrix()
{
- File destFile( "terra/" + name + ".ozTerra" );
+ File destFile( File::NATIVE, "terra/" + name + ".ozTerra" );
Log::print( "Dumping terrain structure to '%s' ...", destFile.path().cstr() );
@@ -177,8 +177,8 @@ void Terra::saveMatrix()
void Terra::saveClient()
{
- File destFile( "terra/" + name + ".ozcTerra" );
- File minimapFile( "terra/" + name + ".ozcTex" );
+ File destFile( File::NATIVE, "terra/" + name + ".ozcTerra" );
+ File minimapFile( File::NATIVE, "terra/" + name + ".ozcTex" );
Log::println( "Compiling terrain model to '%s' {", destFile.path().cstr() );
Log::indent();
@@ -276,7 +276,7 @@ void Terra::saveClient()
Log::print( "Writing minimap texture '%s' ...", minimapFile.path().cstr() );
- os.reset();
+ os.rewind();
mapTex.write( &os );
if( !minimapFile.write( os.begin(), os.length() ) ) {
View
14 src/builder/UI.cc
@@ -54,7 +54,7 @@ const char* const UI::ICON_NAMES[] = {
void UI::buildCursors()
{
- if( PFile( "ui/cur" ).type() == File::MISSING ) {
+ if( File( File::VIRTUAL, "ui/cur" ).type() == File::DIRECTORY ) {
return;
}
@@ -68,8 +68,8 @@ void UI::buildCursors()
File::mkdir( "ui/cur" );
for( int i = 0; i < ui::Mouse::CURSORS_MAX; ++i ) {
- PFile inFile( String::str( "ui/cur/%s.in", ui::Mouse::NAMES[i] ) );
- File destFile( String::str( "ui/cur/%s.ozCur", ui::Mouse::NAMES[i] ) );
+ File inFile( File::VIRTUAL, String::str( "ui/cur/%s.in", ui::Mouse::NAMES[i] ) );
+ File destFile( File::NATIVE, String::str( "ui/cur/%s.ozCur", ui::Mouse::NAMES[i] ) );
String realPath = inFile.realDir() + "/" + inFile.path();
@@ -109,7 +109,7 @@ void UI::buildCursors()
void UI::buildIcons()
{
- if( PFile( "ui/icon" ).type() == File::MISSING ) {
+ if( File( File::VIRTUAL, "ui/icon" ).type() == File::DIRECTORY ) {
return;
}
@@ -134,7 +134,7 @@ void UI::buildIcons()
Log::println( "Compiling '%s'", destPath.cstr() );
tex.write( &os );
- if( !File( destPath ).write( os.begin(), os.length() ) ) {
+ if( !File( File::NATIVE, destPath ).write( os.begin(), os.length() ) ) {
OZ_ERROR( "Texture writing failed" );
}
}
@@ -147,8 +147,8 @@ void UI::buildIcons()
void UI::copyScheme()
{
- PFile srcFile( "ui/style.json" );
- File outFile( "ui/style.json" );
+ File srcFile( File::VIRTUAL, "ui/style.json" );
+ File outFile( File::NATIVE, "ui/style.json" );
if( srcFile.type() == File::REGULAR ) {
Log::print( "Copying UI colour scheme '%s' ...", srcFile.path().cstr() );
View
2 src/client/BSP.cc
@@ -54,7 +54,7 @@ BSP::~BSP()
void BSP::preload()
{
- PFile file( "bsp/" + bsp->name + ".ozcBSP" );
+ File file( File::VIRTUAL, "bsp/" + bsp->name + ".ozcBSP" );
buffer = file.read();
if( buffer.isEmpty() ) {
View
2 src/client/Caelum.cc
@@ -167,7 +167,7 @@ void Caelum::load()
Math::sin( orbis.caelum.heading ),
0.0f );
- Buffer buffer = PFile( path ).read();
+ Buffer buffer = File( File::VIRTUAL, path ).read();
if( buffer.isEmpty() ) {
OZ_ERROR( "Caelum file '%s' read failed", path.cstr() );
}
View
2 src/client/CinematicProxy.cc
@@ -53,7 +53,7 @@ void CinematicProxy::addTransform( const Quat& rot, const Point& p, const Mat44&
void CinematicProxy::executeSequence( const char* path, const Lingua* missionLingua )
{
JSON sequence;
- PFile file( path );
+ File file( File::VIRTUAL, path );
if( !sequence.load( file ) ) {
OZ_ERROR( "Failed to load sequence from '%s'", file.path().cstr() );
View
41 src/client/Client.cc
@@ -61,7 +61,6 @@ namespace client
void Client::printUsage( const char* invocationName )
{
-
Log::printRaw(
"Usage:\n"
" %s [-v] [-l | -i <mission>] [-t <num>] [-L <lang>] [-p <prefix>]\n"
@@ -136,7 +135,7 @@ int Client::init( int argc, char** argv )
#if defined( __native_client__ )
- File::init( File::TEMPORARY, 64*1024*1024 );
+ File::init( File::NATIVE, File::TEMPORARY, 64*1024*1024 );
String configDir = "/config/openzone";
String localDir = "/local/share/openzone";
@@ -225,7 +224,7 @@ int Client::init( int argc, char** argv )
Log::println( "}" );
Log::verboseMode = false;
- PFile::init( File::TEMPORARY, 32*1024*1024 );
+ File::init( File::VIRTUAL, File::TEMPORARY, 32*1024*1024 );
initFlags |= INIT_PHYSFS;
OZ_MAIN_CALL( this, {
@@ -245,7 +244,7 @@ int Client::init( int argc, char** argv )
// Clean up after previous versions.
File::rm( configDir + "/client.rc" );
- File configFile( configDir + "/client.json" );
+ File configFile( File::NATIVE, configDir + "/client.json" );
if( config.load( configFile ) ) {
Log::printEnd( "Configuration read from '%s'", configFile.path().cstr() );
@@ -307,9 +306,9 @@ int Client::init( int argc, char** argv )
#ifdef __native_client__
foreach( pkg, packages.citer() ) {
- File pkgFile( localDir + "/" + *pkg );
+ File pkgFile( File::NATIVE, localDir + "/" + *pkg );
- if( PFile::mount( pkgFile.path(), nullptr, true ) ) {
+ if( File::mount( pkgFile.path(), nullptr, true ) ) {
Log::println( "%s", pkgFile.path().cstr() );
}
else {
@@ -324,18 +323,18 @@ int Client::init( int argc, char** argv )
const char* userMusicPath = config.include( "dir.music", musicDir ).asString();
- if( PFile::mount( userMusicPath, "/userMusic", true ) ) {
+ if( File::mount( userMusicPath, "/userMusic", true ) ) {
Log::println( "%s [mounted on /userMusic]", userMusicPath );
}
- if( PFile::mount( localDir, nullptr, true ) ) {
+ if( File::mount( localDir, nullptr, true ) ) {
Log::println( "%s", localDir.cstr() );
- DArray<File> list = File( localDir ).ls();
+ DArray<File> list = File( File::NATIVE, localDir ).ls();
foreach( file, list.citer() ) {
if( file->hasExtension( "7z" ) || file->hasExtension( "zip" ) ) {
- if( !PFile::mount( file->path(), nullptr, true ) ) {
+ if( !File::mount( file->path(), nullptr, true ) ) {
OZ_ERROR( "Failed to mount '%s' on / in PhysicsFS: %s",
file->path().cstr(), PHYSFS_getLastError() );
}
@@ -344,14 +343,14 @@ int Client::init( int argc, char** argv )
}
}
- if( PFile::mount( dataDir, nullptr, true ) ) {
+ if( File::mount( dataDir, nullptr, true ) ) {
Log::println( "%s", dataDir.cstr() );
- DArray<File> list = File( dataDir ).ls();
+ DArray<File> list = File( File::NATIVE, dataDir ).ls();
foreach( file, list.citer() ) {
if( file->hasExtension( "7z" ) || file->hasExtension( "zip" ) ) {
- if( !PFile::mount( file->path(), nullptr, true ) ) {
+ if( !File::mount( file->path(), nullptr, true ) ) {
OZ_ERROR( "Failed to mount '%s' on / in PhysicsFS", file->path().cstr() );
}
Log::println( "%s", file->path().cstr() );
@@ -517,9 +516,8 @@ void Client::shutdown()
if( initFlags & INIT_WINDOW ) {
window.destroy();
}
-
if( ( initFlags & ( INIT_CONFIG | INIT_MAIN_LOOP ) ) == INIT_MAIN_LOOP ) {
- File configFile( config["dir.config"].asString() + "/client.json" );
+ File configFile( File::NATIVE, config["dir.config"].asString() + "/client.json" );
config.exclude( "dir.config" );
config.exclude( "dir.local" );
@@ -536,15 +534,22 @@ void Client::shutdown()
if( initFlags & INIT_SDL_TTF ) {
TTF_Quit();
}
-#ifndef __native_client__
+
+#ifdef __native_client__
+
+ File::destroy( File::NATIVE );
+
+#else
+
if( initFlags & INIT_SDL ) {
SDL_Quit();
}
-#endif
if( initFlags & INIT_PHYSFS ) {
- PFile::destroy();
+ File::destroy( File::VIRTUAL );
}
+#endif
+
if( initFlags & INIT_MAIN_LOOP ) {
Alloc::printSummary();
View
6 src/client/Context.cc
@@ -317,7 +317,7 @@ uint Context::readTextureLayer( InputStream* istream )
uint Context::loadTextureLayer( const char* path )
{
- PFile file( path );
+ File file( File::VIRTUAL, path );
Buffer buffer = file.read();
if( buffer.isEmpty() ) {
@@ -344,7 +344,7 @@ Texture Context::readTexture( InputStream* istream )
Texture Context::loadTexture( const char* path )
{
- PFile file( path );
+ File file( File::VIRTUAL, path );
Buffer buffer = file.read();
if( buffer.isEmpty() ) {
@@ -402,7 +402,7 @@ uint Context::requestSound( int id )
const String& name = liber.sounds[id].name;
const String& path = liber.sounds[id].path;
- PFile file( path );
+ File file( File::VIRTUAL, path );
Buffer buffer = file.read();
if( buffer.isEmpty() ) {
View
8 src/client/GameStage.cc
@@ -62,7 +62,7 @@ bool GameStage::read( const char* path )
{
Log::print( "Loading state from '%s' ...", path );
- File file( path );
+ File file( File::NATIVE, path );
if( !file.map() ) {
Log::printEnd( " Failed" );
return false;
@@ -111,7 +111,7 @@ void GameStage::write( const char* path ) const
Log::print( "Saving state to %s ...", path );
- if( !File( path ).write( ostream.begin(), ostream.length() ) ) {
+ if( !File( File::NATIVE, path ).write( ostream.begin(), ostream.length() ) ) {
Log::printEnd( " Failed" );
}
else {
@@ -262,15 +262,15 @@ bool GameStage::update()
write( QUICKSAVE_FILE );
}
if( input.keys[Input::KEY_QUICKLOAD] && !input.oldKeys[Input::KEY_QUICKLOAD] ) {
- File quicksaveFile( QUICKSAVE_FILE );
+ File quicksaveFile( File::NATIVE, QUICKSAVE_FILE );
if( quicksaveFile.type() == File::REGULAR ) {
stateFile = QUICKSAVE_FILE;
reload();
}
}
if( input.keys[Input::KEY_AUTOLOAD] && !input.oldKeys[Input::KEY_AUTOLOAD] ) {
- File autosaveFile( AUTOSAVE_FILE );
+ File autosaveFile( File::NATIVE, AUTOSAVE_FILE );
if( autosaveFile.type() == File::REGULAR ) {
stateFile = AUTOSAVE_FILE;
View
4 src/client/Input.cc
@@ -542,7 +542,7 @@ void Input::update()
void Input::init()
{
- File configFile( config["dir.config"].asString() + "/input.json" );
+ File configFile( File::NATIVE, config["dir.config"].asString() + "/input.json" );
Log::print( "Initialising Input from '%s' ...", configFile.path().cstr() );
@@ -635,7 +635,7 @@ void Input::destroy()
return;
}
- File configFile( config["dir.config"].asString() + "/input.json" );
+ File configFile( File::NATIVE, config["dir.config"].asString() + "/input.json" );
Log::print( "Writing Input configuration to '%s' ...", configFile.path().cstr() );
View
8 src/client/Lua.cc
@@ -74,8 +74,8 @@ void Lua::create( const char* mission_ )
Log::println( "Executing scripts for mission %s {", cs.mission.cstr() );
Log::indent();
- PFile missionDir( "mission/" + cs.mission );
- DArray<PFile> files = missionDir.ls();
+ File missionDir( File::VIRTUAL, "mission/" + cs.mission );
+ DArray<File> files = missionDir.ls();
if( missionDir.type() != File::DIRECTORY ) {
OZ_ERROR( "Mission directory '%s' does not exist", missionDir.path().cstr() );
@@ -118,8 +118,8 @@ void Lua::read( InputStream* istream )
Log::print( "Deserialising scripts for mission %s ...", cs.mission.cstr() );
- PFile missionDir( "mission/" + cs.mission );
- DArray<PFile> files = missionDir.ls();
+ File missionDir( File::VIRTUAL, "mission/" + cs.mission );
+ DArray<File> files = missionDir.ls();
if( missionDir.type() != File::DIRECTORY ) {
OZ_ERROR( "Mission directory '%s' does not exist", missionDir.path().cstr() );
View
2 src/client/MD2.cc
@@ -227,7 +227,7 @@ MD2::MD2( int id_ ) :
void MD2::preload()
{
- PFile file( liber.models[id].path );
+ File file( File::VIRTUAL, liber.models[id].path );
buffer = file.read();
if( buffer.isEmpty() ) {
View
2 src/client/MD3.cc
@@ -38,7 +38,7 @@ MD3::MD3( int id_ ) :
void MD3::preload()
{
- PFile file( liber.models[id].path );
+ File file( File::VIRTUAL, liber.models[id].path );
buffer = file.read();
if( buffer.isEmpty() ) {
View
4 src/client/MenuStage.cc
@@ -63,8 +63,8 @@ void MenuStage::wait( uint micros )
void MenuStage::load()
{
- File autosaveFile( GameStage::AUTOSAVE_FILE );
- File quicksaveFile( GameStage::QUICKSAVE_FILE );
+ File autosaveFile( File::NATIVE, GameStage::AUTOSAVE_FILE );
+ File quicksaveFile( File::NATIVE, GameStage::QUICKSAVE_FILE );
if( autosaveFile.type() == File::REGULAR ) {
showAutosaved = true;
View
2 src/client/NaClDownloader.cc
@@ -47,7 +47,7 @@ void NaClDownloader::readCallback( void* data, int result )
else {
int length = downloader->buffer.length() - 4096 + result;
- downloader->buffer.reset();
+ downloader->buffer.rewind();
downloader->buffer.forward( length );
if( result != 0 ) {
View
12 src/client/NaClUpdater.cc
@@ -80,7 +80,7 @@ void NaClUpdater::writeLocalManifest() const
bs.writeLong64( pkg->time );
}
- File localManifest( LOCAL_MANIFEST );
+ File localManifest( File::NATIVE, LOCAL_MANIFEST );
if( !localManifest.write( bs.begin(), bs.length() ) ) {
OZ_ERROR( "Failed to write local manifest" );
@@ -96,7 +96,7 @@ bool NaClUpdater::checkUpdates()
localPackages.clear();
remotePackages.clear();
- File localManifest( LOCAL_MANIFEST );
+ File localManifest( File::NATIVE, LOCAL_MANIFEST );
if( localManifest.map() ) {
InputStream is = localManifest.inputStream();
@@ -115,7 +115,7 @@ bool NaClUpdater::checkUpdates()
BufferStream bs = downloader.take();
InputStream is = bs.inputStream();
- is.reset();
+ is.rewind();
remotePackages = readManifest( &is );
@@ -136,9 +136,9 @@ void NaClUpdater::downloadUpdates()
int packageNum = 1;
foreach( pkg, remotePackages.citer() ) {
- File pkgFile( "/local/share/openzone/" + pkg->name );
+ File pkgFile( File::NATIVE, "/local/share/openzone/" + pkg->name );
- if( pkgFile.stat() ) {
+ if( pkgFile.type() == File::REGULAR ) {
long64 localTime = 0;
foreach( localPkg, localPackages.citer() ) {
@@ -212,7 +212,7 @@ void NaClUpdater::downloadUpdates()
}
if( isOrphan ) {
- File pkgFile( "/local/share/openzone/" + localPkg->name );
+ File pkgFile( File::NATIVE, "/local/share/openzone/" + localPkg->name );
Log::print( "Deleting obsolete package '%s' ...", pkgFile.path().cstr() );
if( File::rm( pkgFile.path() ) ) {
View
2 src/client/Profile.cc
@@ -39,7 +39,7 @@ namespace client
void Profile::init()
{
- File profileFile( config["dir.config"].asString() + "/profile.json" );
+ File profileFile( File::NATIVE, config["dir.config"].asString() + "/profile.json" );
JSON profileConfig;
bool configExists = profileConfig.load( profileFile );
View
2 src/client/SMM.cc
@@ -42,7 +42,7 @@ SMM::SMM( int id_ ) :
void SMM::preload()
{
- PFile file( liber.models[id].path );
+ File file( File::VIRTUAL, liber.models[id].path );
buffer = file.read();
if( buffer.isEmpty() ) {
View
10 src/client/Shader.cc
@@ -123,7 +123,7 @@ Shader::Light::Light( const Point& pos_, const Vec4& diffuse_ ) :
void Shader::compileShader( uint id, const char* path, const char** sources, int* lengths ) const
{
- PFile file( path );
+ File file( File::VIRTUAL, path );
Buffer buffer = file.read();
if( buffer.isEmpty() ) {
@@ -165,7 +165,7 @@ void Shader::loadProgram( int id )
{
const String& name = liber.shaders[id].name;
- PFile configFile( "glsl/" + name + ".json" );
+ File configFile( File::VIRTUAL, "glsl/" + name + ".json" );
JSON programConfig;
if( !programConfig.load( configFile ) ) {
@@ -376,7 +376,7 @@ void Shader::init()
sources[0] = defines;
lengths[0] = defines.length();
- PFile file( "glsl/header.glsl" );
+ File file( File::VIRTUAL, "glsl/header.glsl" );
Buffer buffer = file.read();
if( buffer.isEmpty() ) {
@@ -386,8 +386,8 @@ void Shader::init()
sources[1] = buffer.begin();
lengths[1] = buffer.length();
- PFile dir( "glsl" );
- DArray<PFile> shaderFiles = dir.ls();
+ File dir( File::VIRTUAL, "glsl" );
+ DArray<File> shaderFiles = dir.ls();
foreach( file, shaderFiles.citer() ) {
if( file->hasExtension( "vert" ) ) {
View
2 src/client/Sound.cc
@@ -98,7 +98,7 @@ void Sound::soundMain( void* )
void Sound::musicOpen( const char* path )
{
- PFile file( path );
+ File file( File::VIRTUAL, path );
if( file.hasExtension( "oga" ) || file.hasExtension( "ogg" ) ) {
musicStreamType = OGG;
View
2 src/client/Terra.cc
@@ -161,7 +161,7 @@ void Terra::load()
const String& name = liber.terrae[id].name;
- PFile file( "terra/" + name + ".ozcTerra" );
+ File file( File::VIRTUAL, "terra/" + name + ".ozcTerra" );
Buffer buffer = file.read();
if( buffer.isEmpty() ) {
View
4 src/client/ui/CreditsMenu.cc
@@ -148,8 +148,8 @@ CreditsMenu::CreditsMenu() :
Button* backButton = new Button( OZ_GETTEXT( "Back" ), back, 200, 30 );
add( backButton, -20, 20 );
- PFile creditsDir( "credits" );
- DArray<PFile> creditsFiles = creditsDir.ls();
+ File creditsDir( File::VIRTUAL, "credits" );
+ DArray<File> creditsFiles = creditsDir.ls();
lines.add( "OpenZone " OZ_VERSION );
lines.add( "" );
View
2 src/client/ui/Font.cc
@@ -70,7 +70,7 @@ void Font::init( const char* name, int height_ )
{
height = height_;
- PFile file( String::str( "ui/font/%s.ttf", name ) );
+ File file( File::VIRTUAL, String::str( "ui/font/%s.ttf", name ) );
buffer = file.read();
if( buffer.isEmpty() ) {
View
2 src/client/ui/GalileoFrame.cc
@@ -41,7 +41,7 @@ namespace ui
uint GalileoFrame::loadTexture( const char* path ) const
{
- PFile file( path );
+ File file( File::VIRTUAL, path );
Buffer buffer = file.read();
if( buffer.isEmpty() ) {
View
4 src/client/ui/MainMenu.cc
@@ -135,8 +135,8 @@ void MainMenu::onReposition()
void MainMenu::onUpdate()
{
- File autosaveFile( GameStage::AUTOSAVE_FILE );
- File quicksaveFile( GameStage::QUICKSAVE_FILE );
+ File autosaveFile( File::NATIVE, GameStage::AUTOSAVE_FILE );
+ File quicksaveFile( File::NATIVE, GameStage::QUICKSAVE_FILE );
if( autosaveFile.type() == File::REGULAR ) {
OZ_MAIN_CALL( this, {
View
8 src/client/ui/MissionMenu.cc
@@ -190,11 +190,11 @@ MissionMenu::MissionMenu() :
Button* backButton = new Button( OZ_GETTEXT( "Back" ), back, 200, 30 );
add( backButton, -20, 20 );
- PFile missionRootDir( "mission" );
- DArray<PFile> missionDirs = missionRootDir.ls();
+ File missionRootDir( File::VIRTUAL, "mission" );
+ DArray<File> missionDirs = missionRootDir.ls();
foreach( missionDir, missionDirs.citer() ) {
- PFile descriptionFile( missionDir->path() + "/description.json" );
+ File descriptionFile( File::VIRTUAL, missionDir->path() + "/description.json" );
JSON descriptionConfig;
if( !descriptionConfig.load( descriptionFile ) ) {
@@ -209,7 +209,7 @@ MissionMenu::MissionMenu() :
const char* title = lingua.get( descriptionConfig["title"].get( missionName ) );
const char* description = lingua.get( descriptionConfig["description"].get( "" ) );
- PFile image( missionDir->path() + "/description.ozImage" );
+ File image( File::VIRTUAL, missionDir->path() + "/description.ozImage" );
uint imageId = 0;
if( image.type() != File::MISSING ) {
View
2 src/client/ui/Mouse.cc
@@ -109,7 +109,7 @@ void Mouse::init()
doShow = false;
for( int i = 0; i < CURSORS_MAX; ++i ) {
- PFile file( String::str( "ui/cur/%s.ozCur", NAMES[i] ) );
+ File file( File::VIRTUAL, String