Browse Source

[php] return null when getting non-existing resources (close #4400)

Andy Li 10 years ago
parent
commit
a2de181eec
1 changed files with 10 additions and 2 deletions
  1. 10 2
      std/php/_std/haxe/Resource.hx

+ 10 - 2
std/php/_std/haxe/Resource.hx

@@ -49,11 +49,19 @@ class Resource {
 	}
 
 	public static function getString( name : String ) : String {
-		return sys.io.File.getContent(getPath(name));
+		var path = getPath(name);
+		return if (!sys.FileSystem.exists(path))
+			null;
+		else
+			sys.io.File.getContent(path);
 	}
 
 	public static function getBytes( name : String ) : haxe.io.Bytes {
-		return sys.io.File.getBytes(getPath(name));
+		var path = getPath(name);
+		return if (!sys.FileSystem.exists(path))
+			null;
+		else
+			sys.io.File.getBytes(path);
 	}
 
 }