Daniele Bartolini 10 yıl önce
ebeveyn
işleme
9ba3277763

+ 1 - 1
src/compilers/bundle_compiler.cpp

@@ -116,7 +116,7 @@ bool BundleCompiler::compile(const char* type, const char* name, const char* pla
 		File* outf = _bundle_fs.open(path.c_str(), FOM_WRITE);
 		uint32_t size = array::size(output);
 		uint32_t written = outf->write(array::begin(output), size);
-		_bundle_fs.close(outf);
+		_bundle_fs.close(*outf);
 		success = size == written;
 	}
 	else

+ 1 - 1
src/compilers/compile_options.h

@@ -51,7 +51,7 @@ struct CompileOptions
 		Buffer buf(default_allocator());
 		array::resize(buf, size);
 		file->read(array::begin(buf), size);
-		_fs.close(file);
+		_fs.close(*file);
 		return buf;
 	}
 

+ 2 - 3
src/core/filesystem/apk_filesystem.cpp

@@ -27,10 +27,9 @@ File* ApkFilesystem::open(const char* path, FileOpenMode mode)
 	return CE_NEW(default_allocator(), ApkFile)(_asset_manager, path);
 }
 
-void ApkFilesystem::close(File* file)
+void ApkFilesystem::close(File& file)
 {
-	CE_ASSERT_NOT_NULL(file);
-	CE_DELETE(default_allocator(), file);
+	CE_DELETE(default_allocator(), &file);
 }
 
 bool ApkFilesystem::exists(const char* path)

+ 1 - 1
src/core/filesystem/apk_filesystem.h

@@ -30,7 +30,7 @@ public:
 	File* open(const char* rel_path, FileOpenMode mode);
 
 	/// @copydoc Filesystem::close()
-	void close(File* file);
+	void close(File& file);
 
 	/// Returns always false under Android.
 	bool exists(const char* path);

+ 2 - 4
src/core/filesystem/disk_filesystem.cpp

@@ -38,11 +38,9 @@ File* DiskFilesystem::open(const char* path, FileOpenMode mode)
 	return CE_NEW(default_allocator(), DiskFile)(mode, abs_path.c_str());
 }
 
-void DiskFilesystem::close(File* file)
+void DiskFilesystem::close(File& file)
 {
-	CE_ASSERT_NOT_NULL(file);
-
-	CE_DELETE(default_allocator(), file);
+	CE_DELETE(default_allocator(), &file);
 }
 
 bool DiskFilesystem::exists(const char* path)

+ 1 - 1
src/core/filesystem/disk_filesystem.h

@@ -35,7 +35,7 @@ public:
 	File* open(const char* path, FileOpenMode mode);
 
 	/// Closes the given @a file.
-	void close(File* file);
+	void close(File& file);
 
 	/// Returns whether @a path exists.
 	bool exists(const char* path);

+ 1 - 1
src/core/filesystem/filesystem.h

@@ -29,7 +29,7 @@ public:
 	virtual File* open(const char* path, FileOpenMode mode) = 0;
 
 	/// Closes the given @a file.
-	virtual void close(File* file) = 0;
+	virtual void close(File& file) = 0;
 
 	/// Returns whether @a path exists.
 	virtual bool exists(const char* path) = 0;

+ 3 - 3
src/renderers/shader.cpp

@@ -93,15 +93,15 @@ namespace shader_resource
 
 		File* vs_file = opts._fs.open(vs_code_path.c_str(), FOM_WRITE);
 		vs_file->write(vs_code.c_str(), vs_code.length());
-		opts._fs.close(vs_file);
+		opts._fs.close(*vs_file);
 
 		File* fs_file = opts._fs.open(fs_code_path.c_str(), FOM_WRITE);
 		fs_file->write(fs_code.c_str(), fs_code.length());
-		opts._fs.close(fs_file);
+		opts._fs.close(*fs_file);
 
 		File* varying_file = opts._fs.open(varying_def_path.c_str(), FOM_WRITE);
 		varying_file->write(varying_def.c_str(), varying_def.length());
-		opts._fs.close(varying_file);
+		opts._fs.close(*varying_file);
 
 		TempAllocator4096 ta;
 		StringStream output(ta);

+ 1 - 1
src/resource/resource_loader.cpp

@@ -90,7 +90,7 @@ int32_t ResourceLoader::run()
 
 		File* file = _fs.open(path.c_str(), FOM_READ);
 		rr.data = rr.load_function(*file, *rr.allocator);
-		_fs.close(file);
+		_fs.close(*file);
 
 		add_loaded(rr);
 		_mutex.lock();

+ 1 - 1
src/resource/texture_resource.cpp

@@ -590,7 +590,7 @@ namespace texture_resource
 			CE_FATAL("Source image not supported");
 		}
 
-		opts._fs.close(source);
+		opts._fs.close(*source);
 
 		// Write DDS
 		opts.write(TEXTURE_VERSION); // Version