浏览代码

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

Andy Li 10 年之前
父节点
当前提交
a2de181eec
共有 1 个文件被更改,包括 10 次插入2 次删除
  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 {
 	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 {
 	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);
 	}
 	}
 
 
 }
 }