@@ -712,12 +712,38 @@ private JSONObject handleGetResourceFile(JSONObject params) {
712712 for (ResourceFile resFile : context .getDecompiler ().getResources ()) {
713713 if (resourceName .equals (resFile .getOriginalName ())) {
714714 ResContainer container = resFile .loadContent ();
715- if (container .getText () != null ) {
715+ String contentStr = null ;
716+
717+ if (container .getDataType () == ResContainer .DataType .TEXT || container .getDataType () == ResContainer .DataType .RES_TABLE ) {
718+ ICodeInfo content = container .getText ();
719+ if (content != null ) {
720+ contentStr = content .getCodeStr ();
721+ }
722+ } else if (container .getDataType () == ResContainer .DataType .RES_LINK ) {
723+ try {
724+ contentStr = ResourcesLoader .decodeStream (resFile , (size , is ) -> {
725+ ByteArrayOutputStream buffer = new ByteArrayOutputStream ();
726+ int nRead ;
727+ byte [] data = new byte [1024 ];
728+ while ((nRead = is .read (data , 0 , data .length )) != -1 ) {
729+ buffer .write (data , 0 , nRead );
730+ }
731+ buffer .flush ();
732+ return new String (buffer .toByteArray (), StandardCharsets .UTF_8 );
733+ });
734+ } catch (Exception e ) {
735+ return errorJson ("Error decoding resource stream: " + e .getMessage ());
736+ }
737+ } else {
738+ return errorJson ("Unsupported resource type: " + container .getDataType ());
739+ }
740+
741+ if (contentStr != null ) {
716742 return new JSONObject ()
717743 .put ("resource_name" , resourceName )
718- .put ("content" , container . getText (). getCodeStr () );
744+ .put ("content" , contentStr );
719745 }
720- return errorJson ("Resource content is empty or not text ." );
746+ return errorJson ("Resource content is empty." );
721747 }
722748 }
723749 return errorJson ("Resource not found: " + resourceName );
0 commit comments