mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2026-03-03 23:09:44 +00:00
Refactor the filesystem and HTTP code
- Move the encoding/decoding from the Filesystem implementation to the individual handles. - Move each handle into an core.apis.handles package from the main fs API. - Move the HTTP response to inherit from these handles. - Allow binary handles' read function to accept a number, specifying how many characters to read - these will be returned as a Lua string. - Add readAll to binary handles - Allow binary handles' write function to accept a string which is decoded into the individual bytes. - Add "binary" argument to http.request and friends in order to return a binary handle. - Ensure file handles are open when reading from/writing to them. - Return the error message when opening a file fails.
This commit is contained in:
@@ -41,4 +41,17 @@ public class StringUtil
|
||||
{
|
||||
return net.minecraft.util.text.translation.I18n.translateToLocalFormatted( key, format );
|
||||
}
|
||||
|
||||
public static byte[] encodeString( String string )
|
||||
{
|
||||
byte[] chars = new byte[ string.length() ];
|
||||
|
||||
for( int i = 0; i < chars.length; ++i )
|
||||
{
|
||||
char c = string.charAt( i );
|
||||
chars[ i ] = c < 256 ? (byte) c : 63;
|
||||
}
|
||||
|
||||
return chars;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user