Misc cosmetic improvements

This commit is contained in:
d0k3 2016-05-27 01:21:05 +02:00
parent c1b69229ad
commit 7082457918
2 changed files with 4 additions and 5 deletions

View File

@ -163,6 +163,7 @@ bool GetTempFileName(char* path) {
} }
bool FileSetData(const char* path, const u8* data, size_t size, size_t foffset) { bool FileSetData(const char* path, const u8* data, size_t size, size_t foffset) {
if (!CheckWritePermissions(path)) return false;
if (PathToNumFS(path) >= 0) { if (PathToNumFS(path) >= 0) {
UINT bytes_written = 0; UINT bytes_written = 0;
FIL file; FIL file;

View File

@ -300,16 +300,14 @@ u32 HexViewer(const char* path) {
else if ((pad_state & BUTTON_R1) && (pad_state & BUTTON_Y)) mode = (mode + 1) % 4; else if ((pad_state & BUTTON_R1) && (pad_state & BUTTON_Y)) mode = (mode + 1) % 4;
else if (pad_state & BUTTON_A) edit_mode = true; else if (pad_state & BUTTON_A) edit_mode = true;
else if (pad_state & BUTTON_B) break; else if (pad_state & BUTTON_B) break;
if (edit_mode && !CheckWritePermissions(path)) { if (edit_mode && CheckWritePermissions(path)) { // setup edit mode
edit_mode = false;
} else { // setup edit mode
cursor = 0; cursor = 0;
edit_start = ((offset - (offset % 0x200) <= (edit_bsize / 2)) || (fsize < edit_bsize)) ? 0 : edit_start = ((offset - (offset % 0x200) <= (edit_bsize / 2)) || (fsize < edit_bsize)) ? 0 :
offset - (offset % 0x200) - (edit_bsize / 2); offset - (offset % 0x200) - (edit_bsize / 2);
FileGetData(path, edit_buffer, edit_bsize, edit_start); FileGetData(path, edit_buffer, edit_bsize, edit_start);
memcpy(edit_buffer_cpy, edit_buffer, edit_bsize); memcpy(edit_buffer_cpy, edit_buffer, edit_bsize);
data = edit_buffer + (offset - edit_start); data = edit_buffer + (offset - edit_start);
} } else edit_mode = false;
} else { // editor mode } else { // editor mode
if (pad_state & BUTTON_B) { if (pad_state & BUTTON_B) {
edit_mode = false; edit_mode = false;