summaryrefslogtreecommitdiff
path: root/scene/io
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2015-08-23 20:15:56 -0300
committerJuan Linietsky <reduzio@gmail.com>2015-08-23 20:15:56 -0300
commit07e97414250827c3b930befa123a4bbd48d24861 (patch)
tree8ec9872421ad333d3a1150ee64db1d0d27bd4269 /scene/io
parent9d185ccc30ad5fe7eb716390ca2e7f5c06574ce0 (diff)
**WARNING BEFORE PULLING**
This push changes the binary and XML formats and bumps the major version to 2.0. As such, files saved in this version WILL NO LONGER WORK IN PREVIOUS VERSIONS. This compatibility breakage with older versions was required in order to properly provide project refactoring tools. If I were you, unless you are brave, I would wait a week or two before pulling, in case of bugs :) Summary of Changes -New Filesystem dock, with filesystem & tree view modes. -New refactoring tools, to change or fix dependencies. -Quick search dialog, to quickly search any file
Diffstat (limited to 'scene/io')
-rw-r--r--scene/io/resource_format_image.cpp13
-rw-r--r--scene/io/resource_format_image.h2
-rw-r--r--scene/io/resource_format_wav.cpp10
-rw-r--r--scene/io/resource_format_wav.h2
4 files changed, 22 insertions, 5 deletions
diff --git a/scene/io/resource_format_image.cpp b/scene/io/resource_format_image.cpp
index 8527498fc2..f67d50b56c 100644
--- a/scene/io/resource_format_image.cpp
+++ b/scene/io/resource_format_image.cpp
@@ -31,9 +31,11 @@
#include "io/image_loader.h"
#include "globals.h"
#include "os/os.h"
-RES ResourceFormatLoaderImage::load(const String &p_path,const String& p_original_path) {
-
+RES ResourceFormatLoaderImage::load(const String &p_path, const String& p_original_path, Error *r_error) {
+ if (r_error)
+ *r_error=ERR_CANT_OPEN;
+
if (p_path.extension()=="cube") {
// open as cubemap txture
@@ -83,6 +85,8 @@ RES ResourceFormatLoaderImage::load(const String &p_path,const String& p_origina
memdelete(f);
cubemap->set_name(p_path.get_file());
+ if (r_error)
+ *r_error=OK;
return cubemap;
@@ -112,6 +116,8 @@ RES ResourceFormatLoaderImage::load(const String &p_path,const String& p_origina
ERR_EXPLAIN("Failed loading image: "+p_path);
ERR_FAIL_COND_V(err, RES());
+ if (r_error)
+ *r_error=ERR_FILE_CORRUPT;
#ifdef DEBUG_ENABLED
#ifdef TOOLS_ENABLED
@@ -199,6 +205,9 @@ RES ResourceFormatLoaderImage::load(const String &p_path,const String& p_origina
print_line(" -make texture: "+rtos(total));
}
+ if (r_error)
+ *r_error=OK;
+
return RES( texture );
}
diff --git a/scene/io/resource_format_image.h b/scene/io/resource_format_image.h
index 1af65870f8..b5ec5a1200 100644
--- a/scene/io/resource_format_image.h
+++ b/scene/io/resource_format_image.h
@@ -40,7 +40,7 @@ class ResourceFormatLoaderImage : public ResourceFormatLoader {
int max_texture_size;
public:
- virtual RES load(const String &p_path,const String& p_original_path="");
+ virtual RES load(const String &p_path,const String& p_original_path="",Error *r_error=NULL);
virtual void get_recognized_extensions(List<String> *p_extensions) const;
virtual bool handles_type(const String& p_type) const;
virtual String get_resource_type(const String &p_path) const;
diff --git a/scene/io/resource_format_wav.cpp b/scene/io/resource_format_wav.cpp
index 7c90a4b3cd..090348c933 100644
--- a/scene/io/resource_format_wav.cpp
+++ b/scene/io/resource_format_wav.cpp
@@ -31,13 +31,18 @@
#include "scene/resources/sample.h"
-RES ResourceFormatLoaderWAV::load(const String &p_path,const String& p_original_path) {
+RES ResourceFormatLoaderWAV::load(const String &p_path, const String& p_original_path, Error *r_error) {
+ if (r_error)
+ *r_error=ERR_FILE_CANT_OPEN;
Error err;
FileAccess *file=FileAccess::open(p_path, FileAccess::READ,&err);
ERR_FAIL_COND_V( err!=OK, RES() );
+ if (r_error)
+ *r_error=ERR_FILE_CORRUPT;
+
/* CHECK RIFF */
char riff[5];
riff[4]=0;
@@ -244,6 +249,9 @@ RES ResourceFormatLoaderWAV::load(const String &p_path,const String& p_original_
file->close();
memdelete(file);
+ if (r_error)
+ *r_error=OK;
+
return sample;
}
diff --git a/scene/io/resource_format_wav.h b/scene/io/resource_format_wav.h
index 081a563d03..a74da041c1 100644
--- a/scene/io/resource_format_wav.h
+++ b/scene/io/resource_format_wav.h
@@ -33,7 +33,7 @@
class ResourceFormatLoaderWAV : public ResourceFormatLoader {
public:
- virtual RES load(const String &p_path,const String& p_original_path="");
+ virtual RES load(const String &p_path,const String& p_original_path="",Error *r_error=NULL);
virtual void get_recognized_extensions(List<String> *p_extensions) const;
virtual bool handles_type(const String& p_type) const;
virtual String get_resource_type(const String &p_path) const;