Răsfoiți Sursa

Removed old file access wrappers, files are now accessed through the core via abstract file providers

Ivan Safrin 10 ani în urmă
părinte
comite
2fb37bfd6b

+ 27 - 10
build/osx/PolycodeCore/PolycodeCore.xcodeproj/project.pbxproj

@@ -79,13 +79,11 @@
 		8A86527A1B72865C009F94DD /* PolyVector2.h in Headers */ = {isa = PBXBuildFile; fileRef = 8A86522F1B72865C009F94DD /* PolyVector2.h */; };
 		8A86527B1B72865C009F94DD /* PolyVector3.h in Headers */ = {isa = PBXBuildFile; fileRef = 8A8652301B72865C009F94DD /* PolyVector3.h */; };
 		8A86527C1B72865C009F94DD /* PolyVector4.h in Headers */ = {isa = PBXBuildFile; fileRef = 8A8652311B72865C009F94DD /* PolyVector4.h */; };
-		8A8652841B72866C009F94DD /* osbasics.h in Headers */ = {isa = PBXBuildFile; fileRef = 8A86527E1B72866C009F94DD /* osbasics.h */; };
 		8A8652851B72866C009F94DD /* Polycode.h in Headers */ = {isa = PBXBuildFile; fileRef = 8A86527F1B72866C009F94DD /* Polycode.h */; };
 		8A8652861B72866C009F94DD /* rgbe.h in Headers */ = {isa = PBXBuildFile; fileRef = 8A8652801B72866C009F94DD /* rgbe.h */; };
 		8A8652871B72866C009F94DD /* stb_image.h in Headers */ = {isa = PBXBuildFile; fileRef = 8A8652811B72866C009F94DD /* stb_image.h */; };
 		8A8652881B72866C009F94DD /* tinystr.h in Headers */ = {isa = PBXBuildFile; fileRef = 8A8652821B72866C009F94DD /* tinystr.h */; };
 		8A8652891B72866C009F94DD /* tinyxml.h in Headers */ = {isa = PBXBuildFile; fileRef = 8A8652831B72866C009F94DD /* tinyxml.h */; };
-		8A8652D51B72867F009F94DD /* OSBasics.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8A86528A1B72867E009F94DD /* OSBasics.cpp */; };
 		8A8652D61B72867F009F94DD /* PolyBezierCurve.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8A86528B1B72867E009F94DD /* PolyBezierCurve.cpp */; };
 		8A8652D71B72867F009F94DD /* PolyBone.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8A86528C1B72867E009F94DD /* PolyBone.cpp */; };
 		8A8652D81B72867F009F94DD /* PolyCamera.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8A86528D1B72867E009F94DD /* PolyCamera.cpp */; };
@@ -160,10 +158,15 @@
 		8A86531D1B72867F009F94DD /* tinyxml.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8A8652D21B72867F009F94DD /* tinyxml.cpp */; };
 		8A86531E1B72867F009F94DD /* tinyxmlerror.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8A8652D31B72867F009F94DD /* tinyxmlerror.cpp */; };
 		8A86531F1B72867F009F94DD /* tinyxmlparser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8A8652D41B72867F009F94DD /* tinyxmlparser.cpp */; };
+		8A86538B1B742DBC009F94DD /* PolyBasicFileProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 8A8653891B742DBC009F94DD /* PolyBasicFileProvider.h */; };
+		8A86538C1B742DBC009F94DD /* PolyPhysFSFileProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 8A86538A1B742DBC009F94DD /* PolyPhysFSFileProvider.h */; };
+		8A86538F1B742DCD009F94DD /* PolyBasicFileProvider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8A86538D1B742DCD009F94DD /* PolyBasicFileProvider.cpp */; };
+		8A8653901B742DCD009F94DD /* PolyPhysFSFileProvider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8A86538E1B742DCD009F94DD /* PolyPhysFSFileProvider.cpp */; };
+		8A8653921B7434D8009F94DD /* PolyCoreFileProvider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8A8653911B7434D8009F94DD /* PolyCoreFileProvider.cpp */; };
+		8A8653941B7434EB009F94DD /* PolyCoreFileProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 8A8653931B7434EB009F94DD /* PolyCoreFileProvider.h */; };
 /* End PBXBuildFile section */
 
 /* Begin PBXFileReference section */
-		8A8651DF1B72860B009F94DD /* libPolycore.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; name = libPolycore.a; path = /Users/isafrin/Desktop/Workshop/PolycodeNoCmake/build/osx/PolycodeCore/build/Debug/libPolycore.a; sourceTree = "<absolute>"; };
 		8A8651E81B72865C009F94DD /* PolyBezierCurve.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PolyBezierCurve.h; path = ../../../include/polycode/core/PolyBezierCurve.h; sourceTree = "<group>"; };
 		8A8651E91B72865C009F94DD /* PolyBone.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PolyBone.h; path = ../../../include/polycode/core/PolyBone.h; sourceTree = "<group>"; };
 		8A8651EA1B72865C009F94DD /* PolyCamera.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PolyCamera.h; path = ../../../include/polycode/core/PolyCamera.h; sourceTree = "<group>"; };
@@ -236,13 +239,11 @@
 		8A86522F1B72865C009F94DD /* PolyVector2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PolyVector2.h; path = ../../../include/polycode/core/PolyVector2.h; sourceTree = "<group>"; };
 		8A8652301B72865C009F94DD /* PolyVector3.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PolyVector3.h; path = ../../../include/polycode/core/PolyVector3.h; sourceTree = "<group>"; };
 		8A8652311B72865C009F94DD /* PolyVector4.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PolyVector4.h; path = ../../../include/polycode/core/PolyVector4.h; sourceTree = "<group>"; };
-		8A86527E1B72866C009F94DD /* osbasics.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = osbasics.h; path = ../../../include/osbasics.h; sourceTree = "<group>"; };
 		8A86527F1B72866C009F94DD /* Polycode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Polycode.h; path = ../../../include/Polycode.h; sourceTree = "<group>"; };
 		8A8652801B72866C009F94DD /* rgbe.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = rgbe.h; path = ../../../include/rgbe.h; sourceTree = "<group>"; };
 		8A8652811B72866C009F94DD /* stb_image.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = stb_image.h; path = ../../../include/stb_image.h; sourceTree = "<group>"; };
 		8A8652821B72866C009F94DD /* tinystr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = tinystr.h; path = ../../../include/tinystr.h; sourceTree = "<group>"; };
 		8A8652831B72866C009F94DD /* tinyxml.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = tinyxml.h; path = ../../../include/tinyxml.h; sourceTree = "<group>"; };
-		8A86528A1B72867E009F94DD /* OSBasics.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = OSBasics.cpp; path = ../../../src/core/OSBasics.cpp; sourceTree = "<group>"; };
 		8A86528B1B72867E009F94DD /* PolyBezierCurve.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PolyBezierCurve.cpp; path = ../../../src/core/PolyBezierCurve.cpp; sourceTree = "<group>"; };
 		8A86528C1B72867E009F94DD /* PolyBone.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PolyBone.cpp; path = ../../../src/core/PolyBone.cpp; sourceTree = "<group>"; };
 		8A86528D1B72867E009F94DD /* PolyCamera.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PolyCamera.cpp; path = ../../../src/core/PolyCamera.cpp; sourceTree = "<group>"; };
@@ -317,6 +318,13 @@
 		8A8652D21B72867F009F94DD /* tinyxml.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = tinyxml.cpp; path = ../../../src/core/tinyxml.cpp; sourceTree = "<group>"; };
 		8A8652D31B72867F009F94DD /* tinyxmlerror.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = tinyxmlerror.cpp; path = ../../../src/core/tinyxmlerror.cpp; sourceTree = "<group>"; };
 		8A8652D41B72867F009F94DD /* tinyxmlparser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = tinyxmlparser.cpp; path = ../../../src/core/tinyxmlparser.cpp; sourceTree = "<group>"; };
+		8A8653881B740963009F94DD /* libPolycore.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPolycore.a; sourceTree = BUILT_PRODUCTS_DIR; };
+		8A8653891B742DBC009F94DD /* PolyBasicFileProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PolyBasicFileProvider.h; path = ../../../include/polycode/core/PolyBasicFileProvider.h; sourceTree = "<group>"; };
+		8A86538A1B742DBC009F94DD /* PolyPhysFSFileProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PolyPhysFSFileProvider.h; path = ../../../include/polycode/core/PolyPhysFSFileProvider.h; sourceTree = "<group>"; };
+		8A86538D1B742DCD009F94DD /* PolyBasicFileProvider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PolyBasicFileProvider.cpp; path = ../../../src/core/PolyBasicFileProvider.cpp; sourceTree = "<group>"; };
+		8A86538E1B742DCD009F94DD /* PolyPhysFSFileProvider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PolyPhysFSFileProvider.cpp; path = ../../../src/core/PolyPhysFSFileProvider.cpp; sourceTree = "<group>"; };
+		8A8653911B7434D8009F94DD /* PolyCoreFileProvider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PolyCoreFileProvider.cpp; path = ../../../src/core/PolyCoreFileProvider.cpp; sourceTree = "<group>"; };
+		8A8653931B7434EB009F94DD /* PolyCoreFileProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PolyCoreFileProvider.h; path = ../../../include/polycode/core/PolyCoreFileProvider.h; sourceTree = "<group>"; };
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
@@ -335,13 +343,16 @@
 			children = (
 				8A8651E71B72863F009F94DD /* include */,
 				8A8651E61B728638009F94DD /* src */,
+				8A8653881B740963009F94DD /* libPolycore.a */,
 			);
 			sourceTree = "<group>";
 		};
 		8A8651E61B728638009F94DD /* src */ = {
 			isa = PBXGroup;
 			children = (
-				8A86528A1B72867E009F94DD /* OSBasics.cpp */,
+				8A8653911B7434D8009F94DD /* PolyCoreFileProvider.cpp */,
+				8A86538D1B742DCD009F94DD /* PolyBasicFileProvider.cpp */,
+				8A86538E1B742DCD009F94DD /* PolyPhysFSFileProvider.cpp */,
 				8A86528B1B72867E009F94DD /* PolyBezierCurve.cpp */,
 				8A86528C1B72867E009F94DD /* PolyBone.cpp */,
 				8A86528D1B72867E009F94DD /* PolyCamera.cpp */,
@@ -423,7 +434,9 @@
 		8A8651E71B72863F009F94DD /* include */ = {
 			isa = PBXGroup;
 			children = (
-				8A86527E1B72866C009F94DD /* osbasics.h */,
+				8A8653891B742DBC009F94DD /* PolyBasicFileProvider.h */,
+				8A86538A1B742DBC009F94DD /* PolyPhysFSFileProvider.h */,
+				8A8653931B7434EB009F94DD /* PolyCoreFileProvider.h */,
 				8A86527F1B72866C009F94DD /* Polycode.h */,
 				8A8652801B72866C009F94DD /* rgbe.h */,
 				8A8652811B72866C009F94DD /* stb_image.h */,
@@ -519,10 +532,10 @@
 				8A86526D1B72865C009F94DD /* PolyServerWorld.h in Headers */,
 				8A86524F1B72865C009F94DD /* PolyMaterialManager.h in Headers */,
 				8A8652461B72865C009F94DD /* PolyFontManager.h in Headers */,
-				8A8652841B72866C009F94DD /* osbasics.h in Headers */,
 				8A8652891B72866C009F94DD /* tinyxml.h in Headers */,
 				8A8652351B72865C009F94DD /* PolyCamera.h in Headers */,
 				8A86524E1B72865C009F94DD /* PolyMaterial.h in Headers */,
+				8A86538B1B742DBC009F94DD /* PolyBasicFileProvider.h in Headers */,
 				8A8652361B72865C009F94DD /* PolyClient.h in Headers */,
 				8A8652701B72865C009F94DD /* PolySocket.h in Headers */,
 				8A86525A1B72865C009F94DD /* PolyRectangle.h in Headers */,
@@ -530,6 +543,7 @@
 				8A8652341B72865C009F94DD /* PolyBone.h in Headers */,
 				8A8652561B72865C009F94DD /* PolyPerlin.h in Headers */,
 				8A8652331B72865C009F94DD /* PolyBezierCurve.h in Headers */,
+				8A86538C1B742DBC009F94DD /* PolyPhysFSFileProvider.h in Headers */,
 				8A86524B1B72865C009F94DD /* PolyInputKeys.h in Headers */,
 				8A8652721B72865C009F94DD /* PolySoundManager.h in Headers */,
 				8A8652401B72865C009F94DD /* PolyEntity.h in Headers */,
@@ -579,6 +593,7 @@
 				8A8652511B72865C009F94DD /* PolyMesh.h in Headers */,
 				8A8652621B72865C009F94DD /* PolySceneLabel.h in Headers */,
 				8A8652531B72865C009F94DD /* PolyOpenGLGraphicsInterface.h in Headers */,
+				8A8653941B7434EB009F94DD /* PolyCoreFileProvider.h in Headers */,
 				8A8652521B72865C009F94DD /* PolyObject.h in Headers */,
 				8A8652541B72865C009F94DD /* PolyParticleEmitter.h in Headers */,
 				8A8652651B72865C009F94DD /* PolySceneManager.h in Headers */,
@@ -611,7 +626,7 @@
 			);
 			name = PolycodeCore;
 			productName = PolycodeCore;
-			productReference = 8A8651DF1B72860B009F94DD /* libPolycore.a */;
+			productReference = 8A8653881B740963009F94DD /* libPolycore.a */;
 			productType = "com.apple.product-type.library.static";
 		};
 /* End PBXNativeTarget section */
@@ -711,7 +726,9 @@
 				8A86530D1B72867F009F94DD /* PolySkeleton.cpp in Sources */,
 				8A86530E1B72867F009F94DD /* PolySocket.cpp in Sources */,
 				8A86531B1B72867F009F94DD /* rgbe.cpp in Sources */,
+				8A86538F1B742DCD009F94DD /* PolyBasicFileProvider.cpp in Sources */,
 				8A8653171B72867F009F94DD /* PolyTweenManager.cpp in Sources */,
+				8A8653901B742DCD009F94DD /* PolyPhysFSFileProvider.cpp in Sources */,
 				8A8652D81B72867F009F94DD /* PolyCamera.cpp in Sources */,
 				8A86530C1B72867F009F94DD /* PolyShader.cpp in Sources */,
 				8A8652E61B72867F009F94DD /* PolyFont.cpp in Sources */,
@@ -732,9 +749,9 @@
 				8A8652D71B72867F009F94DD /* PolyBone.cpp in Sources */,
 				8A86530F1B72867F009F94DD /* PolySound.cpp in Sources */,
 				8A8652F61B72867F009F94DD /* PolyPerlin.cpp in Sources */,
-				8A8652D51B72867F009F94DD /* OSBasics.cpp in Sources */,
 				8A8653101B72867F009F94DD /* PolySoundManager.cpp in Sources */,
 				8A8652EF1B72867F009F94DD /* PolyMaterialManager.cpp in Sources */,
+				8A8653921B7434D8009F94DD /* PolyCoreFileProvider.cpp in Sources */,
 				8A8653061B72867F009F94DD /* PolySceneMesh.cpp in Sources */,
 				8A8653051B72867F009F94DD /* PolySceneManager.cpp in Sources */,
 				8A8652FD1B72867F009F94DD /* PolyResource.cpp in Sources */,

+ 0 - 83
include/osbasics.h

@@ -1,83 +0,0 @@
-/*
- Copyright (C) 2011 by Ivan Safrin
- 
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated documentation files (the "Software"), to deal
- in the Software without restriction, including without limitation the rights
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the Software is
- furnished to do so, subject to the following conditions:
- 
- The above copyright notice and this permission notice shall be included in
- all copies or substantial portions of the Software.
- 
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- THE SOFTWARE.
- */
-
-#pragma once
-
-#include "polycode/core/PolyGlobals.h"
-#include "polycode/core/PolyString.h"
-
-struct PHYSFS_File;
-
-class _PolyExport OSFileEntry : public PolyBase {
-
-	public:
-		OSFileEntry() {};
-		OSFileEntry(const Polycode::String& fullPath, int type);
-		OSFileEntry(const Polycode::String& path, const Polycode::String& name, int type);
-		
-		void init(const Polycode::String& path, const Polycode::String& name, int type);
-		
-		Polycode::String name;
-		Polycode::String extension;
-		Polycode::String nameWithoutExtension;
-		Polycode::String basePath;
-		Polycode::String fullPath;
-		int type;
-		
-		static const int TYPE_FILE = 0;
-		static const int TYPE_FOLDER = 1;
-};
-
-class _PolyExport OSFILE : public PolyBase {
-public:
-	OSFILE(){}
-	
-	void debugDump();
-	
-	int fileType;
-	FILE *file;	
-	PHYSFS_File *physFSFile;
-	static const int TYPE_FILE = 0;
-	static const int TYPE_ARCHIVE_FILE = 1;	
-};
-
-class _PolyExport OSBasics : public PolyBase {
-	public:
-	
-		static OSFILE *open(const Polycode::String& filename, const Polycode::String& opts);
-		static int close(OSFILE *file);
-		static size_t read( void * ptr, size_t size, size_t count, OSFILE * stream );	
-		static size_t write( const void * ptr, size_t size, size_t count, OSFILE * stream );
-		static int seek(OSFILE * stream, long int offset, int origin );
-		static long tell(OSFILE * stream);
-	
-		static std::vector<OSFileEntry> parsePhysFSFolder(const Polycode::String& pathString, bool showHidden);
-		static std::vector<OSFileEntry> parseFolder(const Polycode::String& pathString, bool showHidden);
-		static bool fileExists(const Polycode::String& pathString);
-		static bool isFolder(const Polycode::String& pathString);
-		static void createFolder(const Polycode::String& pathString);
-		static void removeItem(const Polycode::String& pathString);
-		static time_t getFileTime(const Polycode::String& pathString);
-		
-	private:
-	
-};

+ 47 - 0
include/polycode/core/PolyBasicFileProvider.h

@@ -0,0 +1,47 @@
+/*
+ Copyright (C) 2015 by Ivan Safrin
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+ */
+
+#pragma once
+
+#include "polycode/core/PolyCoreFileProvider.h"
+
+namespace Polycode {
+    
+    class _PolyExport BasicFile : public CoreFile {
+    public:
+        
+        long read( void * ptr, size_t size, size_t count);
+        long write( const void * ptr, size_t size, size_t count);
+        int seek(long int offset, int origin);
+        long tell();
+        
+        FILE *file;
+    };
+    
+    class _PolyExport BasicFileProvider : public CoreFileProvider {
+        public:    
+            Polycode::CoreFile *openFile(const String &fileName, const String &opts);
+            void closeFile(Polycode::CoreFile *file);
+        
+    };
+    
+}

+ 1 - 0
include/polycode/core/PolyCocoaCore.h

@@ -131,6 +131,7 @@ namespace Polycode {
 		
         void setVideoMode(int xRes, int yRes, bool fullScreen, bool vSync, int aaLevel, int anisotropyLevel, bool retinaSupport=true);
 
+        bool systemParseFolder(const Polycode::String& pathString, bool showHidden, std::vector<OSFileEntry> &targetVector);
         
 		void launchApplicationWithFile(String application, String file);
 		void openFileWithApplication(String file, String application);

+ 12 - 1
include/polycode/core/PolyCore.h

@@ -29,13 +29,14 @@ THE SOFTWARE.
 #include "polycode/core/PolyCoreInput.h"
 #include "polycode/core/PolyCoreServices.h"
 #include "polycode/core/PolyThreaded.h"
+#include "polycode/core/PolyCoreFileProvider.h"
 
 long getThreadID();
 
 namespace Polycode {
 
 	class Renderer;
-
+          
 	class _PolyExport CoreMutex : public PolyBase {
 	public:
 		int mutexID;
@@ -296,6 +297,14 @@ namespace Polycode {
         virtual void handleVideoModeChange(VideoModeChangeInfo *modeInfo) = 0;
         virtual void flushRenderContext() = 0;
         
+        CoreFile *openFile(const Polycode::String& fileName, const Polycode::String& opts);
+        void closeFile(CoreFile *file);
+        
+        std::vector<OSFileEntry> parseFolder(const Polycode::String& pathString, bool showHidden);
+
+        virtual bool systemParseFolder(const Polycode::String& pathString, bool showHidden, std::vector<OSFileEntry> &targetVector) = 0;
+        
+        
 		/**
 		* Sets a new video mode.
 		* @param xRes New horizontal resolution of the renderer.
@@ -411,6 +420,8 @@ namespace Polycode {
 	
 		virtual bool checkSpecialKeyEvents(PolyKEY key) { return false; }
         
+        std::vector<CoreFileProvider*> fileProviders;
+        
 		void loseFocus();
 		void gainFocus();
 		

+ 75 - 0
include/polycode/core/PolyCoreFileProvider.h

@@ -0,0 +1,75 @@
+/*
+ Copyright (C) 2015 by Ivan Safrin
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+ */
+
+#pragma once
+
+#include "PolyGlobals.h"
+#include "PolyString.h"
+
+namespace Polycode {
+    
+    class _PolyExport OSFileEntry : public PolyBase {
+        
+    public:
+        OSFileEntry() {};
+        OSFileEntry(const Polycode::String& fullPath, int type);
+        OSFileEntry(const Polycode::String& path, const Polycode::String& name, int type);
+        void init(const Polycode::String& path, const Polycode::String& name, int type);
+        
+        Polycode::String name;
+        Polycode::String extension;
+        Polycode::String nameWithoutExtension;
+        Polycode::String basePath;
+        Polycode::String fullPath;
+        int type;
+        
+        static const int TYPE_FILE = 0;
+        static const int TYPE_FOLDER = 1;
+    };
+    
+    class CoreFileProvider;
+    
+    class _PolyExport CoreFile : public PolyBase {
+    public:
+        CoreFile(){}
+        
+        virtual long read( void * ptr, size_t size, size_t count) = 0;
+        virtual long write( const void * ptr, size_t size, size_t count) = 0;
+        virtual int seek(long int offset, int origin) = 0;
+        virtual long tell() = 0;
+        
+        CoreFileProvider *provider;
+    };
+    
+    class _PolyExport CoreFileProvider {
+    public:
+        CoreFileProvider();
+        
+        virtual CoreFile *openFile(const String &fileName, const String &opts) = 0;
+        virtual void closeFile(CoreFile *file) = 0;
+        virtual bool parseFolder(const Polycode::String& pathString, bool showHidden, std::vector<OSFileEntry> &targetVector);
+        
+        bool canListFiles;
+    };
+
+    
+}

+ 1 - 1
include/polycode/core/PolyGlobals.h

@@ -77,7 +77,7 @@ typedef unsigned int PolyRendererIndexType;
 #define PLATFORM_MAC      2
 #define PLATFORM_UNIX     3
 
-#if defined(_WINDOWS) || (WINAPI_FAMILY == WINAPI_FAMILY_APP)
+#if defined(_WINDOWS) || defined(WINAPI_FAMILY_APP)
 	#define PLATFORM PLATFORM_WINDOWS
 #elif defined(__APPLE__) && defined(__MACH__)
 	#define PLATFORM PLATFORM_MAC

+ 8 - 7
include/polycode/core/PolyMesh.h

@@ -26,9 +26,10 @@ THE SOFTWARE.
 #include "polycode/core/PolyColor.h"
 #include "polycode/core/PolyVector3.h"
 #include "polycode/core/PolyVector2.h"
+#include "polycode/core/PolyCore.h"
 #include <vector>
 
-class OSFILE;
+class CoreFile;
 
 namespace Polycode {
 	
@@ -98,10 +99,10 @@ namespace Polycode {
 			*/			
 			void saveToFile(const String& fileName, bool writeNormals = true, bool writeTangents = true, bool writeColors = true, bool writeBoneWeights = true, bool writeUVs = true, bool writeSecondaryUVs = false);
 
-			void loadFromFile(OSFILE *inFile);
+			void loadFromFile(CoreFile *inFile);
 
         
-			void saveToFile(OSFILE *outFile, bool writeNormals = true, bool writeTangents = true, bool writeColors = true, bool writeBoneWeights = true, bool writeUVs = true, bool writeSecondaryUVs = false);
+			void saveToFile(CoreFile *outFile, bool writeNormals = true, bool writeTangents = true, bool writeColors = true, bool writeBoneWeights = true, bool writeUVs = true, bool writeSecondaryUVs = false);
 			
 			
 			/**
@@ -369,11 +370,11 @@ namespace Polycode {
         
         protected:
         
-            void loadFromFileV2(OSFILE *inFile);
-            void loadFromFileLegacyV1(OSFILE *inFile);
+            void loadFromFileV2(Polycode::CoreFile *inFile);
+            void loadFromFileLegacyV1(Polycode::CoreFile *inFile);
 
-            void writeVertexBlock(VertexDataArray *array, OSFILE *outFile);
-            void writeIndexBlock(IndexDataArray *array, OSFILE *outFile);
+            void writeVertexBlock(VertexDataArray *array, Polycode::CoreFile *outFile);
+            void writeIndexBlock(IndexDataArray *array, Polycode::CoreFile *outFile);
 
             bool meshHasVertexBuffer;
             int meshType;

+ 3 - 3
include/polycode/core/PolyObject.h

@@ -23,7 +23,7 @@
 #pragma once
 #include "polycode/core/PolyGlobals.h"
 #include "polycode/core/PolyString.h"
-#include "OSBasics.h"
+#include "polycode/core/PolyCoreFileProvider.h"
 
 class TiXmlElement;
 
@@ -368,7 +368,7 @@ namespace Polycode {
 			
 			bool readFile();
 					
-			OSFILE *inFile;		
+            Polycode::CoreFile *inFile;
 			std::vector<String> keys;
 			Object *object;		
 
@@ -388,7 +388,7 @@ namespace Polycode {
 			bool writeToFile(const String& fileName);			
 			
 		protected:
-			OSFILE *outFile;
+			Polycode::CoreFile *outFile;
 			int numEntriesWritten;
 			std::vector<String> keys;			
 			Object *object;

+ 51 - 0
include/polycode/core/PolyPhysFSFileProvider.h

@@ -0,0 +1,51 @@
+/*
+ Copyright (C) 2015 by Ivan Safrin
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+ */
+
+#pragma once
+
+#include "polycode/core/PolyCoreFileProvider.h"
+#include "physfs.h"
+
+namespace Polycode {
+
+    class _PolyExport PhysFSFile : public CoreFile {
+    public:
+        
+        long read( void * ptr, size_t size, size_t count);
+        long write( const void * ptr, size_t size, size_t count);
+        int seek(long int offset, int origin);
+        long tell();
+        
+        PHYSFS_File *physFSFile;
+    };
+
+    class _PolyExport PhysFSFileProvider : public CoreFileProvider {
+        public:
+            PhysFSFileProvider();
+        
+            Polycode::CoreFile *openFile(const String &fileName, const String &opts);
+            void closeFile(Polycode::CoreFile *file);
+        
+            bool parseFolder(const Polycode::String& pathString, bool showHidden, std::vector<OSFileEntry> &targetVector);
+    };
+    
+}

+ 1 - 1
include/polycode/core/PolyScene.h

@@ -31,7 +31,7 @@ THE SOFTWARE.
 
 #include <vector>
 
-class OSFILE;
+class CoreFile;
 
 namespace Polycode {
 		

+ 5 - 4
include/tinyxml.h

@@ -53,6 +53,7 @@ distribution.
 	#define TIXML_STRING		TiXmlString
 #endif
 
+#include "polycode/core/PolyCore.h"
 #include "polycode/core/PolyLogger.h"
 
 // Deprecated library function hell. Compilers want to use the
@@ -82,9 +83,7 @@ distribution.
 	#else
 		#define TIXML_SSCANF   sscanf
 	#endif
-#endif	
-
-#include "OSBasics.h"
+#endif
 
 class TiXmlDocument;
 class TiXmlElement;
@@ -95,6 +94,8 @@ class TiXmlText;
 class TiXmlDeclaration;
 class TiXmlParsingData;
 
+class CoreFile;
+
 const int TIXML_MAJOR_VERSION = 2;
 const int TIXML_MINOR_VERSION = 5;
 const int TIXML_PATCH_VERSION = 3;
@@ -1420,7 +1421,7 @@ public:
 		will be interpreted as an XML file. TinyXML doesn't stream in XML from the current
 		file location. Streaming may be added in the future.
 	*/
-	bool LoadFile( OSFILE*, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
+    bool LoadFile( Polycode::CoreFile*, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
 	/// Save a file using the given FILE*. Returns true if successful.
 	bool SaveFile( FILE* ) const;
 

BIN
lib/osx/libPolycore.a


+ 0 - 436
src/core/OSBasics.cpp

@@ -1,436 +0,0 @@
-/*
- Copyright (C) 2011 by Ivan Safrin
- 
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated documentation files (the "Software"), to deal
- in the Software without restriction, including without limitation the rights
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the Software is
- furnished to do so, subject to the following conditions:
- 
- The above copyright notice and this permission notice shall be included in
- all copies or substantial portions of the Software.
- 
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- THE SOFTWARE.
-*/
-
-#include "OSBasics.h"
-#ifdef _WINDOWS
-	#include <windows.h>
-	#include <shellapi.h>
-#else
-	#include <dirent.h>
-	#include <sys/types.h>
-	#include <sys/stat.h>
-	#include <unistd.h>
-#endif
-
-#include <vector>
-#include <string>
-#include "physfs.h"
-
-using namespace std;
-using namespace Polycode;
-
-
-#ifdef _WINDOWS
-
-void wtoc(char* Dest, const WCHAR* Source)
-{
-	int i = 0;
-	while(Source[i] != '\0') {
-		Dest[i] = (char)Source[i];
-		++i;
-	}
-	Dest[i] = 0;
-}
-void ctow(WCHAR* Dest, const char* Source)
-{
-	int i = 0;
-	while(Source[i] != '\0') {
-		Dest[i] = (WCHAR)Source[i];
-		++i;
-	}
-	Dest[i] = 0;
-}
-
-#endif
-
-OSFileEntry::OSFileEntry(const Polycode::String& fullPath, int type) {
-	std::vector<String> parts = fullPath.split("/");
-	
-	if(parts.size() > 1) {
-		String path = parts[0];
-
-		if(parts.size() > 1) {		
-			for(int i=1; i < parts.size()-1; i++) {
-				path += "/" + parts[i];
-			}
-			init(path, parts[parts.size()-1], type);
-		}
-	} else {
-		init("", fullPath, type);
-	}
-	
-}
-
-OSFileEntry::OSFileEntry(const String& path, const String& name, int type) {
-	init(path, name, type);
-}
-
-void OSFileEntry::init(const Polycode::String& path, const Polycode::String& name, int type) {
-	this->basePath = path;
-
-    if(path == "") {
-        this->fullPath = name;
-	} else if(path == "/") {
-		this->fullPath = "/" + name;
-	} else {
-		this->fullPath = path + "/" + name;
-	}
-	this->name = name;
-	this->type = type;
-
-	size_t found;
-	found=this->name.rfind(".");
-	if (found!=string::npos) {
-		extension = this->name.substr(found+1);
-		nameWithoutExtension = this->name.substr(0, found);
-	} else {
-		extension = "";
-		nameWithoutExtension = name;
-	}
-
-}
-
-
-void OSFILE::debugDump() {
-	long tellval = OSBasics::tell(this);
-	OSBasics::seek(this, 0, SEEK_SET);
-	
-	char buffer;
-	while(OSBasics::read(&buffer, 1, 1, this)) {
-		printf("%c", buffer);
-	}
-	
-	OSBasics::seek(this, tellval, SEEK_SET);
-}
-
-OSFILE *OSBasics::open(const String& filename, const String& opts) {
-	OSFILE *retFile = NULL;
-	if(PHYSFS_exists(filename.c_str())) {
-		if(!PHYSFS_isDirectory(filename.c_str())) {
-			retFile = new OSFILE;
-			retFile->fileType = OSFILE::TYPE_ARCHIVE_FILE;
-			if(opts.find("a") !=string::npos) {
-				retFile->physFSFile = PHYSFS_openAppend(filename.c_str());				
-				if(!retFile->physFSFile){
-					printf("Error opening file from archive (%s)\n", filename.c_str());
-					return NULL;		
-				}
-			} else if(opts.find("w") !=string::npos) {
-				retFile->physFSFile = PHYSFS_openWrite(filename.c_str());				
-				if(!retFile->physFSFile){
-					printf("Error opening file from archive (%s)\n", filename.c_str());
-					return NULL;		
-				}
-			} else {
-				retFile->physFSFile = PHYSFS_openRead(filename.c_str());				
-				if(!retFile->physFSFile){
-					printf("Error opening file from archive (%s)\n", filename.c_str());
-					return NULL;		
-				}
-			}
-			return retFile;
-		}
-	} else {
-//		Logger::log("File doesn't exist in archive (%s)\n", filename.c_str());
-	}
-	
-	FILE *file = fopen(filename.c_str(), opts.c_str());
-	if(file) {
-		retFile = new OSFILE;
-		retFile->fileType = OSFILE::TYPE_FILE;
-		retFile->file = file;		
-		return retFile;
-	}
-	
-	return NULL;
-}
-
-int OSBasics::close(OSFILE *file) {
-	int result = 0;
-	switch(file->fileType) {
-		case OSFILE::TYPE_FILE:
-			result = fclose(file->file);
-			break;
-		case OSFILE::TYPE_ARCHIVE_FILE:
-			result = PHYSFS_close(file->physFSFile);
-			break;			
-	}
-	delete file;
-	return result;
-}
-
-long OSBasics::tell(OSFILE * stream) {
-	switch(stream->fileType) {
-		case OSFILE::TYPE_FILE:
-			return ftell(stream->file);
-			break;
-		case OSFILE::TYPE_ARCHIVE_FILE:
-			return PHYSFS_tell(stream->physFSFile);
-			break;			
-	}
-	return 0;
-}
-
-size_t OSBasics::read( void * ptr, size_t size, size_t count, OSFILE * stream ) {
-	switch(stream->fileType) {
-		case OSFILE::TYPE_FILE:
-			return fread(ptr, size, count, stream->file);
-		break;
-		case OSFILE::TYPE_ARCHIVE_FILE:
-			return PHYSFS_read(stream->physFSFile, ptr, size, count);
-		break;			
-	}
-	return 0;
-}
-
-size_t OSBasics::write( const void * ptr, size_t size, size_t count, OSFILE * stream ) {
-	switch(stream->fileType) {
-		case OSFILE::TYPE_FILE:
-			fwrite(ptr, size, count, stream->file);
-			break;
-		case OSFILE::TYPE_ARCHIVE_FILE:
-			PHYSFS_write(stream->physFSFile, ptr, size, count);
-		break;			
-	}
-	return 0;
-}
-
-int OSBasics::seek(OSFILE * stream, long int offset, int origin ) {
-	switch(stream->fileType) {
-		case OSFILE::TYPE_FILE:
-			return fseek(stream->file, offset, origin);
-			break;
-		case OSFILE::TYPE_ARCHIVE_FILE:
-			switch(origin) {
-				case SEEK_SET:
-					return PHYSFS_seek(stream->physFSFile, offset);
-				break;
-				case SEEK_CUR: {
-					PHYSFS_sint64 curoffset = PHYSFS_tell(stream->physFSFile);					
-					return PHYSFS_seek(stream->physFSFile, curoffset+offset);				
-				}
-				break;
-				case SEEK_END: {
-					PHYSFS_sint64 fileLength =  PHYSFS_fileLength(stream->physFSFile);
-					return PHYSFS_seek(stream->physFSFile, fileLength-offset);
-				}
-				break;
-			}
-			break;			
-	}
-	return 0;	
-}
-
-vector<OSFileEntry> OSBasics::parsePhysFSFolder(const String& pathString, bool showHidden) {
-	vector<OSFileEntry> returnVector;
-	
-	char **rc = PHYSFS_enumerateFiles(pathString.c_str());
-	char **i;
-	
-	String fullPath;
-	String fname;
-	for (i = rc; *i != NULL; i++) {
-		fname = string(*i);
-		fullPath = pathString + "/" + fname;
-		if((fname.c_str()[0] != '.' || (fname.c_str()[0] == '.'  && showHidden)) && fname != "..") {
-			if(PHYSFS_isDirectory(fullPath.c_str())) {
-				returnVector.push_back(OSFileEntry(pathString, fname, OSFileEntry::TYPE_FOLDER));
-			} else { 
-				returnVector.push_back(OSFileEntry(pathString, fname, OSFileEntry::TYPE_FILE));		
-			}
-		}
-	}
-	PHYSFS_freeList(rc);	
-	return returnVector;
-}
-
-bool OSBasics::fileExists(const Polycode::String& pathString) {
-	if(PHYSFS_exists(pathString.c_str())) {
-		return true;
-	}
-
-#ifdef _WINDOWS
-	WCHAR tmp[4096];
-	memset(tmp, 0, sizeof(WCHAR)*4096);
-	ctow(tmp, pathString.c_str());
-
-	DWORD dwAttrib = GetFileAttributes(tmp);
-    return (dwAttrib != 0xFFFFFFFF);
-#else
-	return (access(pathString.c_str(), F_OK) != -1);
-#endif
-}
-
-vector<OSFileEntry> OSBasics::parseFolder(const String& pathString, bool showHidden) {
-	vector<OSFileEntry> returnVector;
-	
-	if(pathString != "/") {
-	if(pathString.size() < 128) {
-		if(PHYSFS_exists(pathString.c_str())) {
-			if(PHYSFS_isDirectory(pathString.c_str())) {
-				return parsePhysFSFolder(pathString, showHidden);
-			}
-		}
-	}
-	}
-	
-#ifdef _WINDOWS
-
-	WIN32_FIND_DATA findFileData;
-
-	WCHAR curDir[4096];
-	GetCurrentDirectory(4096, curDir);
-
-	WCHAR tmp[4096];
-	memset(tmp, 0, sizeof(WCHAR)*4096);
-	ctow(tmp, pathString.c_str());
-
-
-	DWORD dwAttrib = GetFileAttributes(tmp);
-  if(! (dwAttrib != INVALID_FILE_ATTRIBUTES && 
-         (dwAttrib & FILE_ATTRIBUTE_DIRECTORY))) {
-		return returnVector;
-  }
-
-
-	SetCurrentDirectory(tmp);
-
-
-	HANDLE hFind = FindFirstFile(L"*", &findFileData);
-	if(hFind  == INVALID_HANDLE_VALUE) {
-		SetCurrentDirectory(curDir);
-		return returnVector;
-	}
-
-	do {		
-		String fname(findFileData.cFileName);
-		
-		if((fname.c_str()[0] != '.' || (fname.c_str()[0] == '.'  && showHidden)) && fname != "..") {
-			if( findFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) {
-				returnVector.push_back(OSFileEntry(pathString, fname, OSFileEntry::TYPE_FOLDER));
-			} else {
-				returnVector.push_back(OSFileEntry(pathString, fname, OSFileEntry::TYPE_FILE));
-			}
-		}
-    } while(FindNextFile(hFind, &findFileData));	
-	FindClose(hFind);
-	SetCurrentDirectory(curDir);
-#else
-	DIR           *d;
-	struct dirent *dir;
-	
-	d = opendir(pathString.c_str());
-	if(d) {
-		while ((dir = readdir(d)) != NULL) {
-			if(dir->d_name[0] != '.' || (dir->d_name[0] == '.'  && showHidden)) {
-				if(dir->d_type == DT_DIR) {
-					returnVector.push_back(OSFileEntry(pathString, dir->d_name, OSFileEntry::TYPE_FOLDER));
-				} else {
-					returnVector.push_back(OSFileEntry(pathString, dir->d_name, OSFileEntry::TYPE_FILE));
-				}
-			}
-		}
-		closedir(d);
-	}
-	
-#endif
-		
-	return returnVector;
-}
-
-time_t OSBasics::getFileTime(const Polycode::String& pathString) {
-
-	String realString;
-	if(PHYSFS_exists(pathString.c_str())) {
-		realString = String(PHYSFS_getRealDir(pathString.c_str())) + "/" + pathString;
-	} else {
-		realString = pathString;
-	}
-
-#ifdef _WINDOWS
-	WCHAR tmp[4096];
-	memset(tmp, 0, sizeof(WCHAR)*4096);
-	ctow(tmp, pathString.c_str());
-	HANDLE hFile = CreateFile(tmp, GENERIC_READ, FILE_SHARE_WRITE | FILE_SHARE_READ | FILE_SHARE_DELETE,
-								NULL, OPEN_EXISTING, 0, NULL);
-								
-	if(hFile == INVALID_HANDLE_VALUE) {
-		return 0;
-	}
-
-	FILETIME lastModifyTime;
-	BOOL result = GetFileTime(hFile, NULL, NULL, &lastModifyTime);
-	if(!result) {
-		return 0;
-	} else {
-		ULARGE_INTEGER ull;
-		ull.LowPart = lastModifyTime.dwLowDateTime;
-		ull.HighPart = lastModifyTime.dwHighDateTime;
-		return ull.QuadPart / 10000000ULL - 11644473600ULL;
-	}
-#else
-	struct stat statbuf;
-	int retVal = stat(realString.c_str(), &statbuf);
-	if (retVal == 0) {
-		return statbuf.st_mtime;
-	} else {
-		return 0;
-	}
-#endif
-}
-
-void OSBasics::removeItem(const String& pathString) {
-#ifdef _WINDOWS
-	 String _tmp = pathString.replace("/", "\\");
-	 DeleteFile(_tmp.getWDataWithEncoding(String::ENCODING_UTF8));
-#else
-	remove(pathString.c_str());
-#endif	
-}
-
-void OSBasics::createFolder(const String& pathString) {
-#ifdef _WINDOWS
-	String path = pathString;
-	CreateDirectory(path.getWDataWithEncoding(String::ENCODING_UTF8), NULL);		
-#else
-	mkdir(pathString.c_str(),  S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
-#endif
-}
-
-bool OSBasics::isFolder(const String& pathString) {
-	bool retVal = false;
-#ifdef _WINDOWS
-	String path = pathString;
-	DWORD dwAttrib = GetFileAttributes(path.getWDataWithEncoding(String::ENCODING_UTF8));
-  return (dwAttrib != INVALID_FILE_ATTRIBUTES && 
-         (dwAttrib & FILE_ATTRIBUTE_DIRECTORY));
-#else
-	DIR           *d;
-	
-	d = opendir(pathString.c_str());
-	if(d) {
-		retVal = true;
-		closedir(d);
-	}
-#endif
-	return retVal;
-}

+ 38 - 0
src/core/PolyBasicFileProvider.cpp

@@ -0,0 +1,38 @@
+
+#include "polycode/core/PolyBasicFileProvider.h"
+
+using namespace Polycode;
+
+Polycode::CoreFile *BasicFileProvider::openFile(const String &fileName, const String &opts) {
+    FILE *file = fopen(fileName.c_str(), opts.c_str());
+    if(file) {
+        BasicFile *retFile = NULL;
+        retFile = new BasicFile();
+        retFile->file = file;
+        return retFile;
+    }
+    
+    return NULL;
+}
+
+void BasicFileProvider::closeFile(Polycode::CoreFile *file) {
+    BasicFile *basicFile = (BasicFile*) file;
+    fclose(basicFile->file);
+    delete basicFile;
+}
+
+long BasicFile::read( void * ptr, size_t size, size_t count) {
+    return fread(ptr, size, count, file);
+}
+
+long BasicFile::write( const void * ptr, size_t size, size_t count) {
+    return fwrite(ptr, size, count, file);
+}
+
+int BasicFile::seek(long int offset, int origin) {
+    return fseek(file, offset, origin);
+}
+
+long BasicFile::tell() {
+    return ftell(file);
+}

+ 33 - 0
src/core/PolyCocoaCore.mm

@@ -26,6 +26,14 @@
 #include <limits.h>
 #import <Cocoa/Cocoa.h>
 
+#include <dirent.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+#include "polycode/core/PolyBasicFileProvider.h"
+#include "polycode/core/PolyPhysFSFileProvider.h"
+
 #include <ApplicationServices/ApplicationServices.h>
 
 
@@ -85,6 +93,9 @@ void Core::getScreenInfo(int *width, int *height, int *hz) {
 
 CocoaCore::CocoaCore(PolycodeView *view, int _xRes, int _yRes, bool fullScreen, bool vSync, int aaLevel, int anisotropyLevel, int frameRate, int monitorIndex, bool retinaSupport) : Core(_xRes, _yRes, fullScreen, vSync, aaLevel, anisotropyLevel, frameRate, monitorIndex) {
 
+    fileProviders.push_back(new PhysFSFileProvider());
+    fileProviders.push_back(new BasicFileProvider());
+    
     this->retinaSupport = retinaSupport;
     
 	hidManager = NULL;
@@ -775,6 +786,28 @@ static void onDeviceValueChanged(void * context, IOReturn result, void * sender,
 	}
 }
 
+bool CocoaCore::systemParseFolder(const Polycode::String& pathString, bool showHidden, std::vector<OSFileEntry> &targetVector) {
+
+
+    DIR           *d;
+    struct dirent *dir;
+    
+    d = opendir(pathString.c_str());
+    if(d) {
+        while ((dir = readdir(d)) != NULL) {
+            if(dir->d_name[0] != '.' || (dir->d_name[0] == '.'  && showHidden)) {
+                if(dir->d_type == DT_DIR) {
+                    targetVector.push_back(OSFileEntry(pathString, dir->d_name, OSFileEntry::TYPE_FOLDER));
+                } else {
+                    targetVector.push_back(OSFileEntry(pathString, dir->d_name, OSFileEntry::TYPE_FILE));
+                }
+            }
+        }
+        closedir(d);
+    }
+    return true;
+}
+
 static void onDeviceMatched(void * context, IOReturn result, void * sender, IOHIDDeviceRef device) {
 	CocoaCore *core = (CocoaCore*) context;
 

+ 39 - 2
src/core/PolyCore.cpp

@@ -35,7 +35,7 @@
 #include <time.h>
 
 namespace Polycode {
-	
+
 	TimeInfo::TimeInfo() {
 		time_t rawtime;
 		struct tm * timeinfo;
@@ -55,7 +55,7 @@ namespace Polycode {
 	
 	Core::Core(int _xRes, int _yRes, bool fullScreen, bool vSync, int aaLevel, int anisotropyLevel, int frameRate, int monitorIndex) : EventDispatcher() {
 	
-		int _hz;
+        int _hz;
 		getScreenInfo(&defaultScreenWidth, &defaultScreenHeight, &_hz);
 	
         coreResized = false;
@@ -324,5 +324,42 @@ namespace Polycode {
 	CoreServices *Core::getServices() {
 		return services;
 	}
+    
+    CoreFile *Core::openFile(const Polycode::String& fileName, const Polycode::String& opts) {
+        for(int i=0; i < fileProviders.size(); i++) {
+            CoreFile *file = fileProviders[i]->openFile(fileName, opts);
+            if(file) {
+                file->provider = fileProviders[i];
+                return file;
+            }
+        }
+        return NULL;
+    }
+    
+    void Core::closeFile(CoreFile *file) {
+        for(int i=0; i < fileProviders.size(); i++) {
+            if(file->provider == fileProviders[i]) {
+                fileProviders[i]->closeFile(file);
+                return;
+            }
+        }
+        assert(false); // CLOSING A FILE FOR A NON-EXISTING PROVIDER
+    }
+    
+    std::vector<OSFileEntry> Core::parseFolder(const Polycode::String& pathString, bool showHidden) {
+        std::vector<OSFileEntry> retVec;
+        
+        for(int i=0; i < fileProviders.size(); i++) {
+            if(fileProviders[i]->canListFiles) {
+                if(fileProviders[i]->parseFolder(pathString, showHidden, retVec)) {
+                    return retVec;
+                }
+            }
+        }
+        
+        systemParseFolder(pathString, showHidden, retVec);        
+        return retVec;
+    }
+    
 	
 }

+ 58 - 0
src/core/PolyCoreFileProvider.cpp

@@ -0,0 +1,58 @@
+
+#include "polycode/core/PolyCoreFileProvider.h"
+
+using namespace Polycode;
+
+CoreFileProvider::CoreFileProvider() {
+    canListFiles = false;
+}
+
+OSFileEntry::OSFileEntry(const Polycode::String& fullPath, int type) {
+    std::vector<String> parts = fullPath.split("/");
+    
+    if(parts.size() > 1) {
+        String path = parts[0];
+        
+        if(parts.size() > 1) {
+            for(int i=1; i < parts.size()-1; i++) {
+                path += "/" + parts[i];
+            }
+            init(path, parts[parts.size()-1], type);
+        }
+    } else {
+        init("", fullPath, type);
+    }
+    
+}
+
+OSFileEntry::OSFileEntry(const String& path, const String& name, int type) {
+    init(path, name, type);
+}
+
+void OSFileEntry::init(const Polycode::String& path, const Polycode::String& name, int type) {
+    this->basePath = path;
+    
+    if(path == "") {
+        this->fullPath = name;
+    } else if(path == "/") {
+        this->fullPath = "/" + name;
+    } else {
+        this->fullPath = path + "/" + name;
+    }
+    this->name = name;
+    this->type = type;
+    
+    size_t found;
+    found=this->name.rfind(".");
+    if (found != -1) {
+        extension = this->name.substr(found+1);
+        nameWithoutExtension = this->name.substr(0, found);
+    } else {
+        extension = "";
+        nameWithoutExtension = name;
+    }
+}
+
+bool CoreFileProvider::parseFolder(const Polycode::String& pathString, bool showHidden, std::vector<OSFileEntry> &targetVector) {
+    return false;
+}

+ 13 - 12
src/core/PolyData.cpp

@@ -21,7 +21,8 @@
 */
 
 #include "polycode/core/PolyData.h"
-#include "OSBasics.h"
+#include "polycode/core/PolyCore.h"
+#include "polycode/core/PolyCoreServices.h"
 #include <string.h>
 #include <stdlib.h>
 
@@ -48,39 +49,39 @@ void Data::setFromString(const String& str, int encoding) {
 
 bool Data::saveToFile(const String& fileName) const {
 	
-	OSFILE *file = OSBasics::open(fileName, "wb");
+    Polycode::CoreFile *file = Services()->getCore()->openFile(fileName, "wb");
 	
 	if(!file) {
-		OSBasics::close(file);		
+		Services()->getCore()->closeFile(file);
 		return false;
 	}
 	
-	OSBasics::write(data, sizeof(char), dataSize, file);	
-	OSBasics::close(file);	
+	file->write(data, sizeof(char), dataSize);
+	Services()->getCore()->closeFile(file);
 	
 	return true;
 }
 
 bool Data::loadFromFile(const String& fileName) {
-	OSFILE *file = OSBasics::open(fileName, "rb");
+	CoreFile *file = Services()->getCore()->openFile(fileName, "rb");
 	if(!file)
 		return false;
 	
-	OSBasics::seek(file, 0L, SEEK_END);
-	dataSize = OSBasics::tell(file);
-	OSBasics::seek(file, 0L, SEEK_SET);
+	file->seek(0L, SEEK_END);
+	dataSize = file->tell();
+	file->seek(0L, SEEK_SET);
 	
 	if(data)
 		free(data);
 	
 	data = (char*)malloc(dataSize);
 	if(!data) {
-		OSBasics::close(file);		
+		Services()->getCore()->closeFile(file);
 		return false;
 	}
 	
-	OSBasics::read(data, sizeof(char), dataSize, file);	
-	OSBasics::close(file);
+	file->read(data, sizeof(char), dataSize);
+	Services()->getCore()->closeFile(file);
 
 	return true;
 }

+ 9 - 7
src/core/PolyFont.cpp

@@ -21,8 +21,9 @@
 */
 
 #include "polycode/core/PolyFont.h"
-#include "OSBasics.h"
 #include "polycode/core/PolyLogger.h"
+#include "polycode/core/PolyCore.h"
+#include "polycode/core/PolyCoreServices.h"
 
 using namespace Polycode;
 
@@ -32,15 +33,16 @@ Font::Font(const String& fileName, FT_Library FTLibrary) {
 	
 	loaded = false;
 	buffer = NULL;
-	OSFILE *file = OSBasics::open(fileName, "rb");
+	CoreFile *file = Services()->getCore()->openFile(fileName, "rb");
 	if(file) {
-		OSBasics::seek(file, 0, SEEK_END);	
-		long progsize = OSBasics::tell(file);
-		OSBasics::seek(file, 0, SEEK_SET);
+		file->seek(0, SEEK_END);
+		long progsize = file->tell();
+		file->seek(0, SEEK_SET);
 		buffer = (unsigned char*)malloc(progsize);
 		memset(buffer, 0, progsize);
-		OSBasics::read(buffer, progsize, 1, file);
-		OSBasics::close(file);
+		file->read(buffer, progsize, 1);
+        
+		Services()->getCore()->closeFile(file);
 		valid = true;
 		if(FT_New_Memory_Face(FTLibrary, buffer, progsize, 0, &ftFace) != 0) {
 			Logger::log("Error loading font %s\n", fileName.c_str());

+ 0 - 1
src/core/PolyFontGlyphSheet.cpp

@@ -22,7 +22,6 @@
 
 #include "polycode/core/PolyFont.h"
 #include "polycode/core/PolyFontGlyphSheet.h"
-#include "OSBasics.h"
 #include "polycode/core/PolyLogger.h"
 #include "polycode/core/PolyImage.h"
 #include "polycode/core/PolyTexture.h"

+ 24 - 23
src/core/PolyImage.cpp

@@ -25,8 +25,9 @@
 #include "polycode/core/PolyImage.h"
 #include "polycode/core/PolyString.h"
 #include "polycode/core/PolyLogger.h"
-#include "OSBasics.h"
 #include "polycode/core/PolyPerlin.h"
+#include "polycode/core/PolyCore.h"
+#include "polycode/core/PolyCoreServices.h"
 #include <algorithm>
 #include <stdlib.h>
 #include "rgbe.h"
@@ -36,8 +37,8 @@
 using namespace Polycode;
 
 void user_read_data(png_structp png_ptr, png_bytep data, png_size_t length) {
-	OSFILE *file = (OSFILE*)png_get_io_ptr(png_ptr);
-	OSBasics::read(data, length, 1, file);
+    Polycode::CoreFile *file = (Polycode::CoreFile*)png_get_io_ptr(png_ptr);
+	file->read(data, length, 1);
 }
 
 Image::Image(const String& fileName) : imageData(NULL) {
@@ -612,19 +613,19 @@ void Image::freeTokens(TokenArray tokens) {
 
 bool Image::loadSTB(const String &fileName) {
     
-    OSFILE *infile = OSBasics::open(fileName.c_str(), "rb");
+    CoreFile *infile = Services()->getCore()->openFile(fileName.c_str(), "rb");
     
     if(!infile) {
         Logger::log("Error opening image file: %s\n", fileName.c_str());
         return false;
     }
     
-    OSBasics::seek(infile, 0, SEEK_END);
-    long bufferLen = OSBasics::tell(infile);
-    OSBasics::seek(infile, 0, SEEK_SET);
+    infile->seek(0, SEEK_END);
+    long bufferLen = infile->tell();
+    infile->seek(0, SEEK_SET);
     
     char *buffer = (char*) malloc(bufferLen);
-    OSBasics::read(buffer, bufferLen, 1, infile);
+    infile->read(buffer, bufferLen, 1);
     
     int x,y,n;
     stbi_uc *data = stbi_load_from_memory((const stbi_uc*)buffer, bufferLen, &x, &y, &n, 4);
@@ -643,7 +644,7 @@ bool Image::loadSTB(const String &fileName) {
     
     imageData = (char*)data;
     
-    OSBasics::close(infile);
+    Services()->getCore()->closeFile(infile);
 
     return true;
 }
@@ -652,19 +653,19 @@ bool Image::loadHDR(const String &fileName) {
     
     imageType = Image::IMAGE_FP16;
     
-    OSFILE *infile = OSBasics::open(fileName.c_str(), "rb");
+    CoreFile *infile = Services()->getCore()->openFile(fileName.c_str(), "rb");
     
     if(!infile) {
         Logger::log("Error opening HDR %s\n", fileName.c_str());
         return false;
     }
     
-    OSBasics::seek(infile, 0, SEEK_END);
-    long bufferLen = OSBasics::tell(infile);
-    OSBasics::seek(infile, 0, SEEK_SET);
+    infile->seek(0, SEEK_END);
+    long bufferLen = infile->tell();
+    infile->seek(0, SEEK_SET);
     
     char *buffer = (char*) malloc(bufferLen);
-    OSBasics::read(buffer, bufferLen, 1, infile);
+    infile->read(buffer, bufferLen, 1);
     
     int x,y,n;
     float *data = stbi_loadf_from_memory((const stbi_uc*)buffer, bufferLen, &x, &y, &n, 0);
@@ -681,14 +682,14 @@ bool Image::loadHDR(const String &fileName) {
     
     imageData = (char*)data;
     
-    OSBasics::close(infile);
+    Services()->getCore()->closeFile(infile);
     
     
     return true;
 }
 
 bool Image::loadPNG(const String& fileName) {
-	OSFILE         *infile;
+	CoreFile         *infile;
 	
 	png_structp   png_ptr;
 	png_infop     info_ptr;
@@ -703,24 +704,24 @@ bool Image::loadPNG(const String& fileName) {
 	int i;
 	png_bytepp row_pointers = NULL;
 	
-	infile = OSBasics::open(fileName.c_str(), "rb");
+	infile = Services()->getCore()->openFile(fileName.c_str(), "rb");
 	if (!infile) {
 		Logger::log("Error opening png file (\"%s\")\n", fileName.c_str());
 		return false;
 	}
 	
-	OSBasics::read(sig, 1, 8, infile);
+	infile->read(sig, 1, 8);
 	
 	if (!png_check_sig((unsigned char *) sig, 8)) {
 		Logger::log("Error reading png signature (\"%s\")\n", fileName.c_str());
-		OSBasics::close(infile);
+		Services()->getCore()->closeFile(infile);
 		return false;
 	}
 
 	png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
 	if (!png_ptr) {
 		Logger::log("Error creating png struct (\"%s\")\n", fileName.c_str());
-		OSBasics::close(infile);
+		Services()->getCore()->closeFile(infile);
 		return false;    /* out of memory */
 	}
 	
@@ -728,14 +729,14 @@ bool Image::loadPNG(const String& fileName) {
 	if (!info_ptr) {
 		Logger::log("Error creating info struct (\"%s\")\n", fileName.c_str());
 		png_destroy_read_struct(&png_ptr, (png_infopp) NULL, (png_infopp) NULL);
-		OSBasics::close(infile);
+		Services()->getCore()->closeFile(infile);
 		return false;    /* out of memory */
 	}
 	
 	if (setjmp(png_jmpbuf(png_ptr))) {
 		Logger::log("Error setting jump thingie (\"%s\")\n", fileName.c_str());
 		png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
-		OSBasics::close(infile);
+		Services()->getCore()->closeFile(infile);
 		return false;
 	}
 
@@ -797,7 +798,7 @@ bool Image::loadPNG(const String& fileName) {
 	
 	free(row_pointers);
 	png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
-	OSBasics::close(infile);
+	Services()->getCore()->closeFile(infile);
 	
 	imageData = image_data;
 	return true;

+ 46 - 46
src/core/PolyMesh.cpp

@@ -24,7 +24,7 @@ THE SOFTWARE.
 
 #include "polycode/core/PolyMesh.h"
 #include "polycode/core/PolyLogger.h"
-#include "OSBasics.h"
+#include "polycode/core/PolyCore.h"
 
 using std::min;
 using std::max;
@@ -105,7 +105,7 @@ Number Mesh::getRadius() {
     return hRad;
 }
 
-void Mesh::writeVertexBlock(VertexDataArray *array, OSFILE *outFile) {
+void Mesh::writeVertexBlock(VertexDataArray *array, Polycode::CoreFile *outFile) {
     
     if(array->getDataSize() == 0) {
         return;
@@ -114,13 +114,13 @@ void Mesh::writeVertexBlock(VertexDataArray *array, OSFILE *outFile) {
     unsigned char blockType = array->type;
     unsigned int blockCount = array->getDataSize();
 
-    OSBasics::write(&blockType, sizeof(unsigned char), 1, outFile);
-    OSBasics::write(&blockCount, sizeof(unsigned int), 1, outFile);
+    outFile->write(&blockType, sizeof(unsigned char), 1);
+    outFile->write(&blockCount, sizeof(unsigned int), 1);
     
-    OSBasics::write(array->getArrayData(), sizeof(PolyRendererVertexType), array->getDataSize(), outFile);
+    outFile->write(array->getArrayData(), sizeof(PolyRendererVertexType), array->getDataSize());
 }
 
-void Mesh::writeIndexBlock(IndexDataArray *array, OSFILE *outFile) {
+void Mesh::writeIndexBlock(IndexDataArray *array, CoreFile *outFile) {
     
     if(array->getDataSize() == 0) {
         return;
@@ -129,19 +129,19 @@ void Mesh::writeIndexBlock(IndexDataArray *array, OSFILE *outFile) {
     unsigned char blockType = array->type;
     unsigned int blockCount = array->getDataSize();
     
-    OSBasics::write(&blockType, sizeof(unsigned char), 1, outFile);
-    OSBasics::write(&blockCount, sizeof(unsigned int), 1, outFile);
+    outFile->write(&blockType, sizeof(unsigned char), 1);
+    outFile->write(&blockCount, sizeof(unsigned int), 1);
     
-    OSBasics::write(array->getArrayData(), sizeof(PolyRendererIndexType), array->getDataSize(), outFile);
+    outFile->write(array->getArrayData(), sizeof(PolyRendererIndexType), array->getDataSize());
 }
 
-void Mesh::saveToFile(OSFILE *outFile, bool writeNormals, bool writeTangents, bool writeColors, bool writeBoneWeights, bool writeUVs, bool writeSecondaryUVs) {
+void Mesh::saveToFile(CoreFile *outFile, bool writeNormals, bool writeTangents, bool writeColors, bool writeBoneWeights, bool writeUVs, bool writeSecondaryUVs) {
 
     // new mesh format
     // IMPORTANT: PolyRendererVertexType type defines mesh format internal type. Consider making floats always. Don't want to cast for now.
     
     const char headerTag[] = "MSH2";
-    OSBasics::write(headerTag, 1, 4, outFile);
+    outFile->write(headerTag, 1, 4);
     
     unsigned char meshFlags = 0;
     
@@ -149,7 +149,7 @@ void Mesh::saveToFile(OSFILE *outFile, bool writeNormals, bool writeTangents, bo
         meshFlags |= 1 << 0;
     }
     
-    OSBasics::write(&meshFlags, sizeof(unsigned char), 1, outFile);
+    outFile->write(&meshFlags, sizeof(unsigned char), 1);
     
     writeVertexBlock(&vertexPositionArray, outFile);
     
@@ -183,64 +183,64 @@ void Mesh::saveToFile(OSFILE *outFile, bool writeNormals, bool writeTangents, bo
     }
 }
 
-void Mesh::loadFromFile(OSFILE *inFile) {
+void Mesh::loadFromFile(CoreFile *inFile) {
     clearMesh();
     
     char tag[4];
-    OSBasics::read(tag, 1, 4, inFile);
+    inFile->read(tag, 1, 4);
     
     if(tag[0] == 'M' && tag[1] == 'S' && tag[2] == 'H' && tag[3] == '2') {
         loadFromFileV2(inFile);
     } else {
-        OSBasics::seek(inFile, 0, SEEK_SET);
+        inFile->seek(0, SEEK_SET);
         loadFromFileLegacyV1(inFile);
     }
 }
 
-void Mesh::loadFromFileV2(OSFILE *inFile) {
+void Mesh::loadFromFileV2(CoreFile *inFile) {
     
     unsigned char meshFlags;
-    OSBasics::read(&meshFlags, sizeof(unsigned char), 1, inFile);
+    inFile->read(&meshFlags, sizeof(unsigned char), 1);
     
     indexedMesh = meshFlags & (1 << 0);
     
     char blockType;
     unsigned int blockSize;
-    while(OSBasics::read(&blockType, sizeof(unsigned char), 1, inFile)) {
-        OSBasics::read(&blockSize, sizeof(unsigned int), 1, inFile);
+    while(inFile->read(&blockType, sizeof(unsigned char), 1)) {
+        inFile->read(&blockSize, sizeof(unsigned int), 1);
         
         switch(blockType) {
             case RenderDataArray::VERTEX_DATA_ARRAY:
                 vertexPositionArray.data.resize(blockSize);
-                OSBasics::read(&vertexPositionArray.data[0], sizeof(PolyRendererVertexType), blockSize, inFile);
+                inFile->read(&vertexPositionArray.data[0], sizeof(PolyRendererVertexType), blockSize);
             break;
             case RenderDataArray::TEXCOORD_DATA_ARRAY:
                 vertexTexCoordArray.data.resize(blockSize);
-                OSBasics::read(&vertexTexCoordArray.data[0], sizeof(PolyRendererVertexType), blockSize, inFile);
+                inFile->read(&vertexTexCoordArray.data[0], sizeof(PolyRendererVertexType), blockSize);
             break;
             case RenderDataArray::NORMAL_DATA_ARRAY:
                 vertexNormalArray.data.resize(blockSize);
-                OSBasics::read(&vertexNormalArray.data[0], sizeof(PolyRendererVertexType), blockSize, inFile);
+                inFile->read(&vertexNormalArray.data[0], sizeof(PolyRendererVertexType), blockSize);
             break;
             case RenderDataArray::COLOR_DATA_ARRAY:
                 vertexColorArray.data.resize(blockSize);
-                OSBasics::read(&vertexColorArray.data[0], sizeof(PolyRendererVertexType), blockSize, inFile);
+                inFile->read(&vertexColorArray.data[0], sizeof(PolyRendererVertexType), blockSize);
             break;
             case RenderDataArray::TANGENT_DATA_ARRAY:
                 vertexTangentArray.data.resize(blockSize);
-                OSBasics::read(&vertexTangentArray.data[0], sizeof(PolyRendererVertexType), blockSize, inFile);
+                inFile->read(&vertexTangentArray.data[0], sizeof(PolyRendererVertexType), blockSize);
             break;
             case RenderDataArray::BONE_WEIGHT_DATA_ARRAY:
                 vertexBoneWeightArray.data.resize(blockSize);
-                OSBasics::read(&vertexBoneWeightArray.data[0], sizeof(PolyRendererVertexType), blockSize, inFile);
+                inFile->read(&vertexBoneWeightArray.data[0], sizeof(PolyRendererVertexType), blockSize);
             break;
             case RenderDataArray::INDEX_DATA_ARRAY:
                 indexArray.data.resize(blockSize);
-                OSBasics::read(&indexArray.data[0], sizeof(PolyRendererIndexType), blockSize, inFile);
+                inFile->read(&indexArray.data[0], sizeof(PolyRendererIndexType), blockSize);
             break;
             case RenderDataArray::BONE_INDEX_DATA_ARRAY:
                 vertexBoneIndexArray.data.resize(blockSize);
-                OSBasics::read(&vertexBoneIndexArray.data[0], sizeof(PolyRendererVertexType), blockSize, inFile);
+                inFile->read(&vertexBoneIndexArray.data[0], sizeof(PolyRendererVertexType), blockSize);
             break;
         }
     }
@@ -264,10 +264,10 @@ void Mesh::normalizeBoneWeights() {
     }
 }
 
-void Mesh::loadFromFileLegacyV1(OSFILE *inFile) {
+void Mesh::loadFromFileLegacyV1(CoreFile *inFile) {
     
     unsigned char meshFlags;
-    OSBasics::read(&meshFlags, sizeof(unsigned char), 1, inFile);
+    inFile->read(&meshFlags, sizeof(unsigned char), 1);
     
     indexedMesh = meshFlags & (1 << 0);
     bool hasNormals = meshFlags & (1 << 1);
@@ -278,11 +278,11 @@ void Mesh::loadFromFileLegacyV1(OSFILE *inFile) {
     bool hasBoneWeights = meshFlags & (1 << 6);
     
     unsigned int meshType;		
-    OSBasics::read(&meshType, sizeof(unsigned int), 1, inFile);
+    inFile->read(&meshType, sizeof(unsigned int), 1);
     setMeshType(meshType);
     
     unsigned int numVertices;
-    OSBasics::read(&numVertices, sizeof(unsigned int), 1, inFile);
+    inFile->read(&numVertices, sizeof(unsigned int), 1);
     
     Vector3_struct pos;
     Vector3_struct nor;
@@ -291,14 +291,14 @@ void Mesh::loadFromFileLegacyV1(OSFILE *inFile) {
     Vector2_struct tex;
     
     for(int i=0; i < numVertices; i++) {
-        OSBasics::read(&pos, sizeof(Vector3_struct), 1, inFile);
+        inFile->read(&pos, sizeof(Vector3_struct), 1);
 
         vertexPositionArray.data.push_back(pos.x);
         vertexPositionArray.data.push_back(pos.y);
         vertexPositionArray.data.push_back(pos.z);
         
         if(hasNormals) {
-            OSBasics::read(&nor, sizeof(Vector3_struct), 1, inFile);
+            inFile->read(&nor, sizeof(Vector3_struct), 1);
 
             vertexNormalArray.data.push_back(nor.x);
             vertexNormalArray.data.push_back(nor.y);
@@ -307,7 +307,7 @@ void Mesh::loadFromFileLegacyV1(OSFILE *inFile) {
             
         }
         if(hasTangents) {
-            OSBasics::read(&tan, sizeof(Vector3_struct), 1, inFile);
+            inFile->read(&tan, sizeof(Vector3_struct), 1);
             
             vertexTangentArray.data.push_back(tan.x);
             vertexTangentArray.data.push_back(tan.y);
@@ -316,7 +316,7 @@ void Mesh::loadFromFileLegacyV1(OSFILE *inFile) {
         }
         
         if(hasColors) {
-            OSBasics::read(&col, sizeof(Vector4_struct), 1, inFile);
+            inFile->read(&col, sizeof(Vector4_struct), 1);
             
             vertexColorArray.data.push_back(col.x);
             vertexColorArray.data.push_back(col.y);
@@ -325,20 +325,20 @@ void Mesh::loadFromFileLegacyV1(OSFILE *inFile) {
         }
         
         if(hasUV) {
-            OSBasics::read(&tex, sizeof(Vector2_struct), 1, inFile);
+            inFile->read(&tex, sizeof(Vector2_struct), 1);
             vertexTexCoordArray.data.push_back(tex.x);
             vertexTexCoordArray.data.push_back(tex.y);
         }
         
         if(hasSecondaryUVs) {
-            OSBasics::read(&tex, sizeof(Vector2_struct), 1, inFile);
+            inFile->read(&tex, sizeof(Vector2_struct), 1);
             vertexTexCoord2Array.data.push_back(tex.x);
             vertexTexCoord2Array.data.push_back(tex.x);
         }
         
         if(hasBoneWeights) {
             unsigned int numBoneWeights;
-            OSBasics::read(&numBoneWeights, sizeof(unsigned int), 1, inFile);
+            inFile->read(&numBoneWeights, sizeof(unsigned int), 1);
             
             Number totalWeight = 0;
             int numPushed = 0;
@@ -346,8 +346,8 @@ void Mesh::loadFromFileLegacyV1(OSFILE *inFile) {
             for(int b=0; b < numBoneWeights; b++) {
                 float weight;
                 unsigned int boneID;
-                OSBasics::read(&boneID, sizeof(unsigned int), 1, inFile);
-                OSBasics::read(&weight, sizeof(float), 1, inFile);
+                inFile->read(&boneID, sizeof(unsigned int), 1);
+                inFile->read(&weight, sizeof(float), 1);
                 
                 if(b < 4) {
                     vertexBoneWeightArray.data.push_back(weight);
@@ -372,10 +372,10 @@ void Mesh::loadFromFileLegacyV1(OSFILE *inFile) {
     
     if(indexedMesh) {
         unsigned int numIndices;
-        OSBasics::read(&numIndices, sizeof(unsigned int), 1, inFile);
+        inFile->read(&numIndices, sizeof(unsigned int), 1);
         unsigned int val;
         for(int i=0; i < numIndices; i++) {
-            OSBasics::read(&val, sizeof(unsigned int), 1, inFile);
+            inFile->read(&val, sizeof(unsigned int), 1);
             indexArray.data.push_back(val);
         }
     }
@@ -481,24 +481,24 @@ void Mesh::addNormal(const Vector3 &n) {
 }
 
 void Mesh::saveToFile(const String& fileName, bool writeNormals, bool writeTangents, bool writeColors, bool writeBoneWeights, bool writeUVs, bool writeSecondaryUVs) {
-    OSFILE *outFile = OSBasics::open(fileName, "wb");
+    CoreFile *outFile = Services()->getCore()->openFile(fileName, "wb");
     if(!outFile) {
         Logger::log("Error opening mesh file for saving: %s\n", fileName.c_str());
         return;
     }
     saveToFile(outFile, writeNormals, writeTangents, writeColors, writeBoneWeights, writeUVs, writeSecondaryUVs);
-    OSBasics::close(outFile);	
+    Services()->getCore()->closeFile(outFile);
 
 }
 
 void Mesh::loadMesh(const String& fileName) {
-    OSFILE *inFile = OSBasics::open(fileName, "rb");
+    CoreFile *inFile = Services()->getCore()->openFile(fileName, "rb");
     if(!inFile) {
         Logger::log("Error opening mesh file %s\n", fileName.c_str());
         return;
     }
     loadFromFile(inFile);
-    OSBasics::close(inFile);	
+    Services()->getCore()->closeFile(inFile);
 }
 
 void Mesh::createCircle(Number w, Number h, unsigned int numSegments, Number tilingValue) {

+ 37 - 35
src/core/PolyObject.cpp

@@ -25,6 +25,8 @@
 #include <sstream>
 #include <stdio.h>
 #include <string.h>
+#include "polycode/core/PolyCoreServices.h"
+#include "polycode/core/PolyCore.h"
 
 using namespace Polycode;
 
@@ -315,10 +317,10 @@ bool Object::loadFromBinary(const String& fileName) {
 BinaryObjectReader::BinaryObjectReader(const String& fileName, Object *object) {
 	this->object = object;
 	success = false;
-	inFile = OSBasics::open(fileName, "rb");
+	inFile = Services()->getCore()->openFile(fileName, "rb");
 	if(inFile) {
 		success = readFile();
-		OSBasics::close(inFile);
+		Services()->getCore()->closeFile(inFile);
 	}
 }
 
@@ -332,11 +334,11 @@ String BinaryObjectReader::getKeyByIndex(unsigned int index) {
 
 bool BinaryObjectReader::parseEntryFromFile(ObjectEntry *entry) {	
 	uint16_t keyIndex;
-	OSBasics::read(&keyIndex, sizeof(uint16_t), 1, inFile);	
+	inFile->read(&keyIndex, sizeof(uint16_t), 1);	
 	entry->name = getKeyByIndex(keyIndex);
 	
 	uint8_t type;
-	OSBasics::read(&type, sizeof(uint8_t), 1, inFile);
+	inFile->read(&type, sizeof(uint8_t), 1);
 	entry->type = type;
 
 //	printf("Loading %s of type %u\n", entry->name.c_str(), entry->type);
@@ -345,9 +347,9 @@ bool BinaryObjectReader::parseEntryFromFile(ObjectEntry *entry) {
 	switch(entry->type) {
 		case ObjectEntry::STRING_ENTRY:
 		{
-			OSBasics::read(&data32, sizeof(uint32_t), 1, inFile);
+			inFile->read(&data32, sizeof(uint32_t), 1);
 			char *buffer = (char*) malloc(data32 + 1);
-			OSBasics::read(buffer, 1, data32, inFile);
+			inFile->read(buffer, 1, data32);
 			buffer[data32] = '\0';
 			entry->stringVal = String(buffer);
 			free(buffer);			
@@ -356,7 +358,7 @@ bool BinaryObjectReader::parseEntryFromFile(ObjectEntry *entry) {
 		case ObjectEntry::FLOAT_ENTRY:
 		{
 			float val;
-			OSBasics::read(&val, sizeof(uint32_t), 1, inFile);
+			inFile->read(&val, sizeof(uint32_t), 1);
 			entry->intVal = val;
 			entry->NumberVal = val;			
 		}
@@ -364,14 +366,14 @@ bool BinaryObjectReader::parseEntryFromFile(ObjectEntry *entry) {
 		case ObjectEntry::INT_ENTRY:
 		{
 			int32_t intval;
-			OSBasics::read(&intval, sizeof(int32_t), 1, inFile);
+			inFile->read(&intval, sizeof(int32_t), 1);
 			entry->intVal = intval;
 			entry->NumberVal = intval;
 		}
 		break;
 		case ObjectEntry::BOOL_ENTRY:
 		{
-			OSBasics::read(&data32, sizeof(uint32_t), 1, inFile);		
+			inFile->read(&data32, sizeof(uint32_t), 1);		
 			if(data32 == 0) {
 				entry->boolVal = false;
 				entry->intVal = data32;
@@ -383,11 +385,11 @@ bool BinaryObjectReader::parseEntryFromFile(ObjectEntry *entry) {
 		}
 		break;
 		default:
-			OSBasics::read(&data32, sizeof(uint32_t), 1, inFile);			
+			inFile->read(&data32, sizeof(uint32_t), 1);			
 		break;
 	}	
 
-	OSBasics::read(&data32, sizeof(uint32_t), 1, inFile);
+	inFile->read(&data32, sizeof(uint32_t), 1);
 	
 	bool retVal = true;
 	
@@ -405,7 +407,7 @@ bool BinaryObjectReader::parseEntryFromFile(ObjectEntry *entry) {
 			
 bool BinaryObjectReader::readFile() {
 	char header[5];
-	OSBasics::read(header, 1, 4, inFile);
+	inFile->read(header, 1, 4);
 	header[4] = '\0';
 //	printf("HEADER: [%s]\n", header);
 	if(String(header) != "PBOF") {
@@ -413,19 +415,19 @@ bool BinaryObjectReader::readFile() {
 	}
 	
 	uint32_t data32;
-	OSBasics::read(&data32, sizeof(uint32_t), 1, inFile);
+	inFile->read(&data32, sizeof(uint32_t), 1);
 	
 	for(int i=0; i < data32; i++) {
 		uint16_t data16;
-		OSBasics::read(&data16, sizeof(uint16_t), 1, inFile);
+		inFile->read(&data16, sizeof(uint16_t), 1);
 		char *buffer = (char*)malloc(data16+1);
-		OSBasics::read(buffer, 1, data16, inFile);
+		inFile->read(buffer, 1, data16);
 		buffer[data16] = '\0';
 		keys.push_back(String(buffer));
 		free(buffer);
 	}
 	
-	OSBasics::read(&data32, sizeof(uint32_t), 1, inFile);	
+	inFile->read(&data32, sizeof(uint32_t), 1);	
 	
 	return parseEntryFromFile(&object->root);
 	
@@ -477,29 +479,29 @@ BinaryObjectWriter::~BinaryObjectWriter() {
 void BinaryObjectWriter::writeEntryToFile(ObjectEntry *entry) {
 
 	uint16_t keyIndex = getKeyIndex(entry->name);
-	OSBasics::write(&keyIndex, sizeof(uint16_t), 1, outFile);
+	outFile->write(&keyIndex, sizeof(uint16_t), 1);
 
 	uint8_t type = (uint8_t)entry->type;
-	OSBasics::write(&type, sizeof(uint8_t), 1, outFile);
+	outFile->write(&type, sizeof(uint8_t), 1);
 	
 	uint32_t data32;
 	
 	switch(entry->type) {
 		case ObjectEntry::STRING_ENTRY:
 			data32 = entry->stringVal.length();
-			OSBasics::write(&data32, sizeof(uint32_t), 1, outFile);
-			OSBasics::write(entry->stringVal.c_str(), 1, data32, outFile);
+			outFile->write(&data32, sizeof(uint32_t), 1);
+			outFile->write(entry->stringVal.c_str(), 1, data32);
 		break;
 		case ObjectEntry::FLOAT_ENTRY:
 		{
 			float val = (float)entry->NumberVal;
-			OSBasics::write(&val, sizeof(uint32_t), 1, outFile);		
+			outFile->write(&val, sizeof(uint32_t), 1);		
 		}
 		break;
 		case ObjectEntry::INT_ENTRY:
 		{
 			int32_t intval = (int32_t)entry->intVal;
-			OSBasics::write(&intval, sizeof(int32_t), 1, outFile);		
+			outFile->write(&intval, sizeof(int32_t), 1);		
 		}
 		break;
 		case ObjectEntry::BOOL_ENTRY:
@@ -508,16 +510,16 @@ void BinaryObjectWriter::writeEntryToFile(ObjectEntry *entry) {
 			} else {
 				data32 = 0;			
 			}
-			OSBasics::write(&data32, sizeof(uint32_t), 1, outFile);		
+			outFile->write(&data32, sizeof(uint32_t), 1);		
 		break;
 		default:
 			data32 = 0;
-			OSBasics::write(&data32, sizeof(uint32_t), 1, outFile);			
+			outFile->write(&data32, sizeof(uint32_t), 1);			
 		break;
 	}
 	
 	data32 = entry->children.size();
-	OSBasics::write(&data32, sizeof(uint32_t), 1, outFile);
+	outFile->write(&data32, sizeof(uint32_t), 1);
 	
 	for(int i=0; i < entry->children.size(); i++) {
 		writeEntryToFile(entry->children[i]);
@@ -527,33 +529,33 @@ void BinaryObjectWriter::writeEntryToFile(ObjectEntry *entry) {
 }
 			
 bool BinaryObjectWriter::writeToFile(const String& fileName) {
-	outFile = OSBasics::open(fileName, "wb");
+	outFile = Services()->getCore()->openFile(fileName, "wb");
 	
-	OSBasics::write("PBOF", 1, 4, outFile);
+	outFile->write("PBOF", 1, 4);
 
 	uint32_t data32 = keys.size();
-	OSBasics::write(&data32, sizeof(uint32_t), 1, outFile);
+	outFile->write(&data32, sizeof(uint32_t), 1);
 
 	for(int i=0; i < keys.size(); i++) {
 		uint16_t data16 = keys[i].length();
-		OSBasics::write(&data16, sizeof(uint16_t), 1, outFile);
-		OSBasics::write(keys[i].c_str(), 1, data16, outFile);
+		outFile->write(&data16, sizeof(uint16_t), 1);
+		outFile->write(keys[i].c_str(), 1, data16);
 	}
 	
-	size_t offset = OSBasics::tell(outFile);
+	size_t offset = outFile->tell();
 
 	numEntriesWritten = 0;
 	
 	data32 = 0;
-	OSBasics::write(&data32, sizeof(uint32_t), 1, outFile);
+	outFile->write(&data32, sizeof(uint32_t), 1);
 	
 	writeEntryToFile(&object->root);
 	
-	OSBasics::seek(outFile,  offset, SEEK_SET);
+	outFile->seek(offset, SEEK_SET);
 	data32 = numEntriesWritten;
-	OSBasics::write(&data32, sizeof(uint32_t), 1, outFile);	
+	outFile->write(&data32, sizeof(uint32_t), 1);	
 	
-	OSBasics::close(outFile);
+	Services()->getCore()->closeFile(outFile);
 	return true;
 }
 

+ 7 - 7
src/core/PolyOpenGLGraphicsInterface.cpp

@@ -22,7 +22,6 @@
  */
 
 #include "polycode/core/PolyOpenGLGraphicsInterface.h"
-#include "OSBasics.h"
 #include "polycode/core/PolyLogger.h"
 #include "polycode/core/PolyCoreServices.h"
 
@@ -357,20 +356,21 @@ void OpenGLGraphicsInterface::createProgram(ShaderProgram *program) {
         glDeleteShader(programID);
     }
     
-    OSFILE *file = OSBasics::open(program->getResourcePath(), "rb");
+    CoreFile *file = Services()->getCore()->openFile(program->getResourcePath(), "rb");
     if (!file) {
         Logger::log("Error: shader file %s not found\n", program->getResourcePath().c_str());
         *((GLuint*)program->platformData) = -1;
         return;
     }
     
-    OSBasics::seek(file, 0, SEEK_END);
-    long progsize = OSBasics::tell(file);
-    OSBasics::seek(file, 0, SEEK_SET);
+    file->seek(0, SEEK_END);
+    long progsize = file->tell();
+    file->seek(0, SEEK_SET);
     char *buffer = (char*)malloc(progsize+1);
     memset(buffer, 0, progsize+1);
-    OSBasics::read(buffer, progsize, 1, file);
-    OSBasics::close(file);
+    file->read(buffer, progsize, 1);
+    
+    Services()->getCore()->closeFile(file);
     
     if( program->type == ShaderProgram::TYPE_VERT) {
         programID = glCreateShader(GL_VERTEX_SHADER);

+ 98 - 0
src/core/PolyPhysFSFileProvider.cpp

@@ -0,0 +1,98 @@
+
+#include "polycode/core/PolyPhysFSFileProvider.h"
+
+using namespace Polycode;
+
+PhysFSFileProvider::PhysFSFileProvider() {
+    canListFiles = true;
+}
+
+bool PhysFSFileProvider::parseFolder(const Polycode::String& pathString, bool showHidden, std::vector<OSFileEntry> &targetVector) {
+    
+    if(pathString != "/") {
+        if(pathString.size() < 128) {
+            if(PHYSFS_exists(pathString.c_str())) {
+                if(PHYSFS_isDirectory(pathString.c_str())) {
+                    
+                    char **rc = PHYSFS_enumerateFiles(pathString.c_str());
+                    char **i;
+                    
+                    String fullPath;
+                    String fname;
+                    for (i = rc; *i != NULL; i++) {
+                        fname = std::string(*i);
+                        fullPath = pathString + "/" + fname;
+                        if((fname.c_str()[0] != '.' || (fname.c_str()[0] == '.'  && showHidden)) && fname != "..") {
+                            if(PHYSFS_isDirectory(fullPath.c_str())) {
+                                targetVector.push_back(OSFileEntry(pathString, fname, OSFileEntry::TYPE_FOLDER));
+                            } else {
+                                targetVector.push_back(OSFileEntry(pathString, fname, OSFileEntry::TYPE_FILE));
+                            }
+                        }
+                    }
+                    PHYSFS_freeList(rc);	
+                    return true;;
+                    
+                }
+            }
+        }
+    }
+    return false;
+}
+
+Polycode::CoreFile *PhysFSFileProvider::openFile(const String &fileName, const String &opts) {
+    
+    PhysFSFile *retFile = NULL;
+    if(PHYSFS_exists(fileName.c_str())) {
+        if(!PHYSFS_isDirectory(fileName.c_str())) {
+            retFile = new PhysFSFile();
+            
+            if(opts.find("a") != -1) {
+                retFile->physFSFile = PHYSFS_openAppend(fileName.c_str());
+            } else if(opts.find("w") != -1) {
+                retFile->physFSFile = PHYSFS_openWrite(fileName.c_str());
+            } else {
+                retFile->physFSFile = PHYSFS_openRead(fileName.c_str());
+            }
+            return retFile;
+        }
+    }
+    return NULL;
+}
+
+void PhysFSFileProvider::closeFile(Polycode::CoreFile *file) {
+    PhysFSFile *physFSFile = (PhysFSFile*) file;
+    PHYSFS_close(physFSFile->physFSFile);
+    delete physFSFile;
+}
+
+long PhysFSFile::read( void * ptr, size_t size, size_t count) {
+    return PHYSFS_read(physFSFile, ptr, size, count);
+}
+
+long PhysFSFile::write( const void * ptr, size_t size, size_t count) {
+    return PHYSFS_write(physFSFile, ptr, size, count);
+}
+
+int PhysFSFile::seek(long int offset, int origin) {
+    switch(origin) {
+        case SEEK_SET:
+            return PHYSFS_seek(physFSFile, offset);
+            break;
+        case SEEK_CUR: {
+            PHYSFS_sint64 curoffset = PHYSFS_tell(physFSFile);
+            return PHYSFS_seek(physFSFile, curoffset+offset);
+        }
+            break;
+        case SEEK_END: {
+            PHYSFS_sint64 fileLength =  PHYSFS_fileLength(physFSFile);
+            return PHYSFS_seek(physFSFile, fileLength-offset);
+        }
+            break;
+    }
+    return 0;
+}
+
+long PhysFSFile::tell() {
+    return PHYSFS_tell(physFSFile);   
+}

+ 12 - 9
src/core/PolyResourceManager.cpp

@@ -29,7 +29,6 @@
 #include "polycode/core/PolyMaterial.h"
 #include "polycode/core/PolyShader.h"
 #include "polycode/core/PolyTexture.h"
-#include "OSBasics.h"
 
 #include "physfs.h"
 #include "tinyxml.h"
@@ -104,7 +103,9 @@ bool ResourcePool::hasResource(Resource *resource) {
 void ResourcePool::addResource(Resource *resource) {
     resource->addEventListener(this, Event::RESOURCE_CHANGE_EVENT);
     resources.push_back(resource);
-    resource->resourceFileTime = OSBasics::getFileTime(resource->getResourcePath());
+    
+    // NOCMAKE_TODO: fix this!!
+    resource->resourceFileTime = 0; //OSBasics::getFileTime(resource->getResourcePath());
     if(dispatchChangeEvents) {
         dispatchEvent(new Event(), Event::CHANGE_EVENT);
     }
@@ -173,7 +174,9 @@ Resource *ResourcePool::getResource(int resourceType, const String& resourceName
 void ResourcePool::checkForChangedFiles() {
 	for(int i=0; i < resources.size(); i++) {
 		if(resources[i]->reloadOnFileModify == true) {
-			time_t newFileTime = OSBasics::getFileTime(resources[i]->getResourcePath());
+            
+            // NOCMAKE_TODO: fix this!
+            time_t newFileTime = 0; //OSBasics::getFileTime(resources[i]->getResourcePath());
             //			printf("%s\n%lld %lld\n", resources[i]->getResourcePath().c_str(), newFileTime, resources[i]->resourceFileTime);
 			if((newFileTime != resources[i]->resourceFileTime) && newFileTime != 0) {
 				resources[i]->reloadResource();
@@ -211,7 +214,7 @@ void ResourcePool::Update(int elapsed) {
 
 void ResourceManager::parseShadersIntoPool(ResourcePool *pool, const String& dirPath, bool recursive) {
 	vector<OSFileEntry> resourceDir;
-	resourceDir = OSBasics::parseFolder(dirPath, false);
+	resourceDir = Services()->getCore()->parseFolder(dirPath, false);
 	
 	for(int i=0; i < resourceDir.size(); i++) {	
 		if(resourceDir[i].type == OSFileEntry::TYPE_FILE) {
@@ -233,7 +236,7 @@ void ResourceManager::parseShadersIntoPool(ResourcePool *pool, const String& dir
 
 void ResourceManager::parseOtherIntoPool(ResourcePool *pool, const String& dirPath, bool recursive) {
     vector<OSFileEntry> resourceDir;
-    resourceDir = OSBasics::parseFolder(dirPath, false);
+    resourceDir = Services()->getCore()->parseFolder(dirPath, false);
     for(int i=0; i < resourceDir.size(); i++) {
         if(resourceDir[i].type == OSFileEntry::TYPE_FILE) {
             if(resourceDir[i].extension == "ttf") {
@@ -249,7 +252,7 @@ void ResourceManager::parseOtherIntoPool(ResourcePool *pool, const String& dirPa
 
 void ResourceManager::parseProgramsIntoPool(ResourcePool *pool, const String& dirPath, bool recursive) {
 	vector<OSFileEntry> resourceDir;
-	resourceDir = OSBasics::parseFolder(dirPath, false);
+	resourceDir = Services()->getCore()->parseFolder(dirPath, false);
 	for(int i=0; i < resourceDir.size(); i++) {	
 		if(resourceDir[i].type == OSFileEntry::TYPE_FILE) {
 			MaterialManager *materialManager = CoreServices::getInstance()->getMaterialManager();
@@ -271,7 +274,7 @@ void ResourceManager::parseProgramsIntoPool(ResourcePool *pool, const String& di
 
 void ResourceManager::parseMaterialsIntoPool(ResourcePool *pool, const String& dirPath, bool recursive) {
 	vector<OSFileEntry> resourceDir;
-	resourceDir = OSBasics::parseFolder(dirPath, false);
+	resourceDir = Services()->getCore()->parseFolder(dirPath, false);
 	
 	for(int i=0; i < resourceDir.size(); i++) {	
 		if(resourceDir[i].type == OSFileEntry::TYPE_FILE) {
@@ -294,7 +297,7 @@ void ResourceManager::parseMaterialsIntoPool(ResourcePool *pool, const String& d
 
 void ResourceManager::parseCubemapsIntoPool(ResourcePool *pool, const String& dirPath, bool recursive) {
 	vector<OSFileEntry> resourceDir;
-	resourceDir = OSBasics::parseFolder(dirPath, false);
+	resourceDir = Services()->getCore()->parseFolder(dirPath, false);
 	
 	for(int i=0; i < resourceDir.size(); i++) {	
 		if(resourceDir[i].type == OSFileEntry::TYPE_FILE) {
@@ -326,7 +329,7 @@ ResourcePool *ResourceManager::getGlobalPool() {
 void ResourceManager::parseTexturesIntoPool(ResourcePool *pool, const String& dirPath, bool recursive, const String& basePath) {
 	MaterialManager *materialManager = CoreServices::getInstance()->getMaterialManager();
 	vector<OSFileEntry> resourceDir;
-	resourceDir = OSBasics::parseFolder(dirPath, false);
+	resourceDir = Services()->getCore()->parseFolder(dirPath, false);
 	for(int i=0; i < resourceDir.size(); i++) {	
 		if(resourceDir[i].type == OSFileEntry::TYPE_FILE) {
 			if(resourceDir[i].extension == "png") {

+ 0 - 1
src/core/PolyScene.cpp

@@ -21,7 +21,6 @@
 */
 
 #include "polycode/core/PolyScene.h"
-#include "OSBasics.h"
 #include "polycode/core/PolyCamera.h"
 #include "polycode/core/PolyCoreServices.h"
 #include "polycode/core/PolyLogger.h"

+ 2 - 1
src/core/PolySceneEntityInstance.cpp

@@ -663,7 +663,8 @@ bool SceneEntityInstance::loadFromFile(const String& fileName) {
 
 	clearInstance();
 	
-	resourceEntry->resourceFileTime = OSBasics::getFileTime(fileName);
+    // NOCMAKE_TODO: fix this!
+    resourceEntry->resourceFileTime = 0; //OSBasics::getFileTime(fileName);
 
 	this->ownsChildren = true;
 	this->fileName = fileName;

+ 23 - 24
src/core/PolySkeleton.cpp

@@ -28,7 +28,6 @@
 #include "polycode/core/PolySceneLine.h"
 #include "polycode/core/PolyTween.h"
 #include "polycode/core/PolyTweenManager.h"
-#include "OSBasics.h"
 
 using namespace Polycode;
 
@@ -176,7 +175,7 @@ unsigned int Skeleton::getBoneIndexByBone(Bone *bone) {
 }
 
 void Skeleton::loadSkeleton(const String& fileName) {
-	OSFILE *inFile = OSBasics::open(fileName.c_str(), "rb");
+	CoreFile *inFile = Services()->getCore()->openFile(fileName.c_str(), "rb");
 	if(!inFile) {
 		return;
 	}
@@ -184,7 +183,7 @@ void Skeleton::loadSkeleton(const String& fileName) {
 	unsigned int numBones;
 	float t[3],rq[4],s[3];
 	
-	OSBasics::read(&numBones, sizeof(unsigned int), 1, inFile);
+	inFile->read(&numBones, sizeof(unsigned int), 1);
 	unsigned int namelen;
 	char buffer[1024];
 	
@@ -192,23 +191,23 @@ void Skeleton::loadSkeleton(const String& fileName) {
 	unsigned int hasParent, boneID;
 	for(int i=0; i < numBones; i++) {
 		
-		OSBasics::read(&namelen, sizeof(unsigned int), 1, inFile);
+		inFile->read(&namelen, sizeof(unsigned int), 1);
 		memset(buffer, 0, 1024);
-		OSBasics::read(buffer, 1, namelen, inFile);
+		inFile->read(buffer, 1, namelen);
 		
 		Bone *newBone = new Bone(String(buffer));
 		
-		OSBasics::read(&hasParent, sizeof(unsigned int), 1, inFile);
+		inFile->read(&hasParent, sizeof(unsigned int), 1);
 		if(hasParent == 1) {
-			OSBasics::read(&boneID, sizeof(unsigned int), 1, inFile);
+			inFile->read(&boneID, sizeof(unsigned int), 1);
 			newBone->parentBoneId = boneID;
 		} else {
 			newBone->parentBoneId = -1;
 		}
 
-		OSBasics::read(t, sizeof(float), 3, inFile);
-		OSBasics::read(s, sizeof(float), 3, inFile);
-		OSBasics::read(rq, sizeof(float), 4, inFile);
+		inFile->read(t, sizeof(float), 3);
+		inFile->read(s, sizeof(float), 3);
+		inFile->read(rq, sizeof(float), 4);
 		
 		bones.push_back(newBone);
 		
@@ -227,9 +226,9 @@ void Skeleton::loadSkeleton(const String& fileName) {
 		newBone->setBaseMatrix(newBone->getTransformMatrix());
 		newBone->setBoneMatrix(newBone->getTransformMatrix());
 
-		OSBasics::read(t, sizeof(float), 3, inFile);
-		OSBasics::read(s, sizeof(float), 3, inFile);
-		OSBasics::read(rq, sizeof(float), 4, inFile);
+		inFile->read(t, sizeof(float), 3);
+		inFile->read(s, sizeof(float), 3);
+		inFile->read(rq, sizeof(float), 4);
 		
 		Quaternion q;
 		q.set(rq[0], rq[1], rq[2], rq[3]);
@@ -252,7 +251,7 @@ void Skeleton::loadSkeleton(const String& fileName) {
 			bonesEntity->addChild(bones[i]);
 		}
 	}
-	OSBasics::close(inFile);
+	Services()->getCore()->closeFile(inFile);
 }
 
 SkeletonAnimation *Skeleton::getBaseAnimation() {
@@ -285,7 +284,7 @@ void Skeleton::stopAnimation(SkeletonAnimation *animation) {
 
 void Skeleton::addAnimation(const String& name, const String& fileName) {
 
-    OSFILE *inFile = OSBasics::open(fileName.c_str(), "rb");
+    CoreFile *inFile = Services()->getCore()->openFile(fileName.c_str(), "rb");
     
     if(!inFile) {
 		return;
@@ -293,18 +292,18 @@ void Skeleton::addAnimation(const String& name, const String& fileName) {
 	
     unsigned int activeBones,numPoints,numCurves, curveType;
     float length;
-    OSBasics::read(&length, 1, sizeof(float), inFile);
+    inFile->read(&length, 1, sizeof(float));
 
     SkeletonAnimation *newAnimation = new SkeletonAnimation(name, length);
-    OSBasics::read(&activeBones, sizeof(unsigned int), 1, inFile);
+    inFile->read(&activeBones, sizeof(unsigned int), 1);
     
     unsigned short boneNameLen;
     char boneNameBuffer[1024];
 
     for(int j=0; j < activeBones; j++) {
         
-        OSBasics::read(&boneNameLen, sizeof(unsigned short), 1, inFile);
-        OSBasics::read(boneNameBuffer, 1, boneNameLen, inFile);
+        inFile->read(&boneNameLen, sizeof(unsigned short), 1);
+        inFile->read(boneNameBuffer, 1, boneNameLen);
         boneNameBuffer[boneNameLen] = '\0';
         
         Bone *trackBone = getBoneByName(boneNameBuffer);
@@ -318,14 +317,14 @@ void Skeleton::addAnimation(const String& name, const String& fileName) {
         BezierCurve *curve;
         float vec1[2];
         
-        OSBasics::read(&numCurves, sizeof(unsigned int), 1, inFile);
+        inFile->read(&numCurves, sizeof(unsigned int), 1);
         for(int l=0; l < numCurves; l++) {
             curve = new BezierCurve();
-            OSBasics::read(&curveType, sizeof(unsigned int), 1, inFile);
-            OSBasics::read(&numPoints, sizeof(unsigned int), 1, inFile);
+            inFile->read(&curveType, sizeof(unsigned int), 1);
+            inFile->read(&numPoints, sizeof(unsigned int), 1);
             
             for(int k=0; k < numPoints; k++) {
-                OSBasics::read(vec1, sizeof(float), 2, inFile);					
+                inFile->read(vec1, sizeof(float), 2);					
                 curve->addControlPoint2d(vec1[1], vec1[0]);
             }
             switch(curveType) {
@@ -365,7 +364,7 @@ void Skeleton::addAnimation(const String& name, const String& fileName) {
     }
     
     animations.push_back(newAnimation);
-	OSBasics::close(inFile);	
+	Services()->getCore()->closeFile(inFile);
 }
 
 void Skeleton::bonesVisible(bool val) {

+ 31 - 30
src/core/PolySound.cpp

@@ -27,8 +27,8 @@
 #include "polycode/core/PolyString.h"
 #include "polycode/core/PolyLogger.h"
 #include "polycode/core/PolySoundManager.h"
-
-#include "OSBasics.h"
+#include "polycode/core/PolyCore.h"
+#include "polycode/core/PolyCoreServices.h"
 #include <string>
 #include <vector>
 #include <stdint.h>
@@ -66,23 +66,24 @@ unsigned int AudioStreamingSource::streamData(char *buffer, unsigned int size) {
 
 
 size_t custom_readfunc(void *ptr, size_t size, size_t nmemb, void *datasource) {
-	OSFILE *file = (OSFILE*) datasource;
-	return OSBasics::read(ptr, size, nmemb, file);
+    Polycode::CoreFile *file = (Polycode::CoreFile*) datasource;
+	return file->read(ptr, size, nmemb);
 }
 
 int custom_seekfunc(void *datasource, ogg_int64_t offset, int whence){
-	OSFILE *file = (OSFILE*) datasource;
-	return OSBasics::seek(file, offset, whence);
+	Polycode::CoreFile *file = (Polycode::CoreFile*) datasource;
+	return file->seek(offset, whence);
 }
 
 int custom_closefunc(void *datasource) {
-	OSFILE *file = (OSFILE*) datasource;
-	return OSBasics::close(file);
+	Polycode::CoreFile *file = (Polycode::CoreFile*) datasource;
+	Services()->getCore()->closeFile(file);
+    return 0;
 }
 
 long custom_tellfunc(void *datasource) {
-	OSFILE *file = (OSFILE*) datasource;
-	return OSBasics::tell(file);
+	CoreFile *file = (CoreFile*) datasource;
+	return file->tell();
 }
 
 Sound::Sound(const String& fileName, bool generateFloatBuffer) :  referenceDistance(1), maxDistance(MAX_FLOAT), pitch(1), volume(1), sampleLength(-1), streamingSound(false) {
@@ -186,11 +187,11 @@ void Sound::loadFile(String fileName, bool generateFloatBuffer) {
 	}
 
 	String actualFilename = fileName;
-	OSFILE *test = OSBasics::open(fileName, "rb");
+	CoreFile *test = Services()->getCore()->openFile(fileName, "rb");
 	if(!test) {
 		actualFilename = "default/default.wav";
 	} else {
-		OSBasics::close(test);	
+		Services()->getCore()->closeFile(test);
 	}
 	
 	String extension;
@@ -511,12 +512,12 @@ ALuint Sound::loadOGG(const String& fileName, bool generateFloatBuffer) {
 	int bitStream;
 	long bytes;
 	char array[BUFFER_SIZE];    // Local fixed size array
-	OSFILE *f;
+	CoreFile *f;
 	ALenum format;
 	ALsizei freq;
 	
 	// Open for binary reading
-	f = OSBasics::open(fileName.c_str(), "rb");		
+	f = Services()->getCore()->openFile(fileName.c_str(), "rb");
 	if(!f) {
 		soundError("Error loading OGG file!\n");
 		return buffer;
@@ -577,13 +578,13 @@ ALuint Sound::loadWAV(const String& fileName, bool generateFloatBuffer) {
 	ALsizei freq;
 	
 	// Local resources
-	OSFILE *f = NULL;
+	CoreFile *f = NULL;
 	char *array = NULL;
 	
 	checkALError("loadWAV: pre-generate buffer");
 	
 		// Open for binary reading
-		f = OSBasics::open(fileName.c_str(), "rb");
+		f = Services()->getCore()->openFile(fileName.c_str(), "rb");
 		if (!f) {
 			soundError("LoadWav: Could not load wav from " + fileName);
 			return buffer;
@@ -596,50 +597,50 @@ ALuint Sound::loadWAV(const String& fileName, bool generateFloatBuffer) {
 		unsigned char data16[2];
 		
 		// check magic
-		soundCheck(OSBasics::read(magic,4,1,f) == 1, "LoadWav: Cannot read wav file "+ fileName );
+		soundCheck(f->read(magic,4,1) == 1, "LoadWav: Cannot read wav file "+ fileName );
 		soundCheck(String(magic) == "RIFF", "LoadWav: Wrong wav file format. This file is not a .wav file (no RIFF magic): "+ fileName );
 		
 		// skip 4 bytes (file size)
-		OSBasics::seek(f,4,SEEK_CUR);
+		f->seek(4,SEEK_CUR);
 		
 		// check file format
-		soundCheck(OSBasics::read(magic,4,1,f) == 1, "LoadWav: Cannot read wav file "+ fileName );
+		soundCheck(f->read(magic,4,1) == 1, "LoadWav: Cannot read wav file "+ fileName );
 		soundCheck(String(magic) == "WAVE", "LoadWav: Wrong wav file format. This file is not a .wav file (no WAVE format): "+ fileName );
 		
 		// check 'fmt ' sub chunk (1)
-		soundCheck(OSBasics::read(magic,4,1,f) == 1, "LoadWav: Cannot read wav file "+ fileName );
+		soundCheck(f->read(magic,4,1) == 1, "LoadWav: Cannot read wav file "+ fileName );
 		soundCheck(String(magic) == "fmt ", "LoadWav: Wrong wav file format. This file is not a .wav file (no 'fmt ' subchunk): "+ fileName );
 		
 		// read (1)'s size
-		soundCheck(OSBasics::read(data32,4,1,f) == 1, "LoadWav: Cannot read wav file "+ fileName );
+		soundCheck(f->read(data32,4,1)   == 1, "LoadWav: Cannot read wav file "+ fileName );
 		unsigned long subChunk1Size = readByte32(data32);
 		soundCheck(subChunk1Size >= 16, "Wrong wav file format. This file is not a .wav file ('fmt ' chunk too small, truncated file?): "+ fileName );
 		
 		// check PCM audio format
-		soundCheck(OSBasics::read(data16,2,1,f) == 1, "LoadWav: Cannot read wav file "+ fileName );
+		soundCheck(f->read(data16,2,1) == 1, "LoadWav: Cannot read wav file "+ fileName );
 		unsigned short audioFormat = readByte16(data16);
 		soundCheck(audioFormat == 1, "LoadWav: Wrong wav file format. This file is not a .wav file (audio format is not PCM): "+ fileName );
 		
 		// read number of channels
-		soundCheck(OSBasics::read(data16,2,1,f) == 1, "LoadWav: Cannot read wav file "+ fileName );
+		soundCheck(f->read(data16,2,1) == 1, "LoadWav: Cannot read wav file "+ fileName );
 		unsigned short channels = readByte16(data16);
 		
 		// read frequency (sample rate)
-		soundCheck(OSBasics::read(data32,4,1,f) == 1, "LoadWav: Cannot read wav file "+ fileName );
+		soundCheck(f->read(data32,4,1) == 1, "LoadWav: Cannot read wav file "+ fileName );
 		unsigned long frequency = readByte32(data32);
 		
 		// skip 6 bytes (Byte rate (4), Block align (2))
-		OSBasics::seek(f,6,SEEK_CUR);
+		f->seek(6,SEEK_CUR);
 		
 		// read bits per sample
-		soundCheck(OSBasics::read(data16,2,1,f) == 1, "LoadWav: Cannot read wav file "+ fileName );
+		soundCheck(f->read(data16,2,1) == 1, "LoadWav: Cannot read wav file "+ fileName );
 		unsigned short bps = readByte16(data16);
 		
 		// check 'data' sub chunk (2)
-		soundCheck(OSBasics::read(magic,4,1,f) == 1, "LoadWav: Cannot read wav file "+ fileName );
+		soundCheck(f->read(magic,4,1) == 1, "LoadWav: Cannot read wav file "+ fileName );
 		soundCheck(String(magic) == "data", "LoadWav: Wrong wav file format. This file is not a .wav file (no data subchunk): "+ fileName );
 		
-		soundCheck(OSBasics::read(data32,4,1,f) == 1, "LoadWav: Cannot read wav file "+ fileName );
+		soundCheck(f->read(data32,4,1) == 1, "LoadWav: Cannot read wav file "+ fileName );
 		unsigned long subChunk2Size = readByte32(data32);
 		
 		// The frequency of the sampling rate
@@ -650,7 +651,7 @@ ALuint Sound::loadWAV(const String& fileName, bool generateFloatBuffer) {
 		
 		while (data.size() != subChunk2Size) {
 			// Read up to a buffer's worth of decoded sound data
-			bytes = OSBasics::read(array, 1, BUFFER_SIZE, f);
+			bytes = f->read(array, 1, BUFFER_SIZE);
 			
 			if (bytes <= 0)
 				break;
@@ -665,7 +666,7 @@ ALuint Sound::loadWAV(const String& fileName, bool generateFloatBuffer) {
 		delete []array;
 		array = NULL;
 		
-		OSBasics::close(f);
+		Services()->getCore()->closeFile(f);
 		f = NULL;
 				
 		return loadBytes(&data[0], data.size(), freq, channels, bps, generateFloatBuffer);

+ 17 - 14
src/core/tinyxml.cpp

@@ -30,18 +30,20 @@ distribution.
 #endif
 
 #include "tinyxml.h"
+#include "polycode/core/PolyCore.h"
+#include "polycode/core/PolyCoreServices.h"
 
 // This document has been altered from the original in the following ways:
-// * It opens files through the Polycode OSFile abstraction rather than directly.
+// * It opens files through the Polycode CoreFile abstraction rather than directly.
 // * It now uses Windows linebreaks consistently regardless of platform.
 #define NEWLINE "\n"
 
 bool TiXmlBase::condenseWhiteSpace = true;
 
 // Microsoft compiler security
-OSFILE* TiXmlFOpen( const char* filename, const char* mode )
+Polycode::CoreFile* TiXmlFOpen( const char* filename, const char* mode )
 {
-	return OSBasics::open( filename, mode );
+    return Polycode::Services()->getCore()->openFile( filename, mode );
 }
 
 void TiXmlBase::EncodeString( const TIXML_STRING& str, TIXML_STRING* outString )
@@ -954,12 +956,12 @@ bool TiXmlDocument::LoadFile( const char* _filename, TiXmlEncoding encoding )
 	value = filename;
 
 	// reading in binary mode so that tinyxml can normalize the EOL
-	OSFILE* file = TiXmlFOpen( value.c_str (), "rb" );	
+    Polycode::CoreFile* file = TiXmlFOpen( value.c_str (), "rb" );
 
 	if ( file )
 	{
 		bool result = LoadFile( file, encoding );
-		OSBasics::close( file );
+        Polycode::Services()->getCore()->closeFile(file);
 		return result;
 	}
 	else
@@ -969,7 +971,7 @@ bool TiXmlDocument::LoadFile( const char* _filename, TiXmlEncoding encoding )
 	}
 }
 
-bool TiXmlDocument::LoadFile( OSFILE* file, TiXmlEncoding encoding )
+bool TiXmlDocument::LoadFile(Polycode::CoreFile* file, TiXmlEncoding encoding )
 {
 	if ( !file ) 
 	{
@@ -983,9 +985,9 @@ bool TiXmlDocument::LoadFile( OSFILE* file, TiXmlEncoding encoding )
 
 	// Get the file size, so we can pre-allocate the string. HUGE speed impact.
 	long length = 0;
-	OSBasics::seek( file, 0, SEEK_END );
-	length = OSBasics::tell( file );
-	OSBasics::seek( file, 0, SEEK_SET );
+	file->seek(0, SEEK_END );
+	length = file->tell();
+	file->seek(0, SEEK_SET );
 
 	// Strange case, but good to handle up front.
 	if ( length <= 0 )
@@ -1023,7 +1025,7 @@ bool TiXmlDocument::LoadFile( OSFILE* file, TiXmlEncoding encoding )
 	char* buf = new char[ length+1 ];
 	buf[0] = 0;
 
-	if ( OSBasics::read( buf, length, 1, file ) != 1 ) {
+	if ( file->read( buf, length, 1) != 1 ) {
 		delete [] buf;
 		SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN );
 		return false;
@@ -1087,12 +1089,13 @@ bool TiXmlDocument::LoadFile( OSFILE* file, TiXmlEncoding encoding )
 bool TiXmlDocument::SaveFile( const char * filename ) const
 {
 	// The old c stuff lives on...
-	OSFILE* fp = TiXmlFOpen( filename, "wb" );
+    Polycode::CoreFile* fp = TiXmlFOpen( filename, "wb" );
 	if ( fp )
 	{
-		bool result = SaveFile( fp->file );
-		fclose( fp->file );
-		return result;
+        // NOCMAKE_TODO: Fix this
+		//bool result = SaveFile( fp->file );
+		//fclose( fp->file );
+		//return result;
 	}
 	return false;
 }