forked from reconSuave/RustyDagger
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
It is now possible to create hero and load hero. Other call than find, read and write hero are not implemented. Only one hero at time.
- Loading branch information
Showing
7 changed files
with
97 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package DCourt.Tools; | ||
|
||
import DCourt.Items.Item; | ||
import java.io.File; | ||
import java.io.FileInputStream; | ||
import java.io.FileOutputStream; | ||
import java.io.IOException; | ||
|
||
/* loaded from: DCourt.jar:DCourt/Tools/Loader.class */ | ||
public class FileLoader extends Loader { | ||
static final String HEROFILE = "hero.txt"; | ||
|
||
public static Buffer cgiBuffer(String action, String data) { | ||
return new Buffer(cgi(action, data)); | ||
} | ||
|
||
public static Item cgiItem(String action, String data) { | ||
return Item.factory(cgi(action, data)); | ||
} | ||
|
||
public static String cgi(String action, String data) { | ||
switch (action) { | ||
case FINDHERO: | ||
return "2023-07-27|0||"; | ||
case SAVEHERO: | ||
try { | ||
FileOutputStream output = new FileOutputStream(HEROFILE); | ||
byte[] strToBytes = data.getBytes(); | ||
output.write(strToBytes); | ||
output.close(); | ||
return ""; | ||
} catch (IOException e) { | ||
return "Error: " + e.getMessage(); | ||
} | ||
case READHERO: | ||
File f = new File(HEROFILE); | ||
if (!f.exists()) { | ||
return ""; | ||
} | ||
try { | ||
FileInputStream input = new FileInputStream(HEROFILE); | ||
byte[] Bytes = new byte[32768]; | ||
input.read(Bytes); | ||
input.close(); | ||
String s = new String(Bytes, "US-ASCII"); | ||
return s; | ||
} catch (IOException e) { | ||
System.out.println(e.getMessage()); | ||
return "Error: " + e.getMessage(); | ||
} catch (Exception e) { | ||
System.out.println(e.getMessage()); | ||
return "Error: " + e.getMessage(); | ||
} | ||
} | ||
return "Error: " + action + " not implemented"; | ||
} | ||
} |