mirror of
https://github.com/erichelgeson/BlueSCSI.git
synced 2025-02-05 19:31:05 +00:00
Fix issue with large files MSB being overwritten
This commit is contained in:
parent
2be810e2ca
commit
98162fcd84
@ -1836,27 +1836,28 @@ byte onListFiles(SCSI_DEVICE *dev, const byte *cdb) {
|
|||||||
// FileEntry names[512];
|
// FileEntry names[512];
|
||||||
char names[512] ={0};
|
char names[512] ={0};
|
||||||
int ENTRY_SIZE = 40;
|
int ENTRY_SIZE = 40;
|
||||||
char name[MAX_FILE_PATH + 1];
|
char name[MAX_MAC_PATH + 1];
|
||||||
dir.open("/shared");
|
dir.open("/shared");
|
||||||
dir.rewindDirectory();
|
dir.rewindDirectory();
|
||||||
uint8_t index = 0;
|
uint8_t index = 0;
|
||||||
while (file.openNext(&dir, O_RDONLY)) {
|
while (file.openNext(&dir, O_RDONLY)) {
|
||||||
uint8_t isDir = file.isDirectory() ? 0x00 : 0x01;
|
uint8_t isDir = file.isDirectory() ? 0x00 : 0x01;
|
||||||
file.getName(name, MAX_FILE_PATH + 1);
|
file.getName(name, MAX_MAC_PATH + 1);
|
||||||
u_int32_t size = file.fileSize();
|
uint64_t size = file.fileSize();
|
||||||
file.close();
|
|
||||||
byte file_entry[ENTRY_SIZE] = {0};
|
byte file_entry[ENTRY_SIZE] = {0};
|
||||||
file_entry[0] = index;
|
file_entry[0] = index;
|
||||||
file_entry[1] = isDir;
|
file_entry[1] = isDir;
|
||||||
int c = 0;
|
int c = 0;
|
||||||
for(int i = 2; i < (MAX_FILE_PATH + 1 + 2); i++) { // bytes 2 - 34
|
for(int i = 2; i < (MAX_MAC_PATH + 1 + 2); i++) { // bytes 2 - 34
|
||||||
file_entry[i] = name[c++];
|
file_entry[i] = name[c++];
|
||||||
}
|
}
|
||||||
file_entry[35] = (size >> 32) & 0xff;
|
file_entry[35] = 0; //(size >> 32) & 0xff;
|
||||||
file_entry[36] = (size >> 24) & 0xff;
|
file_entry[36] = (size >> 24) & 0xff;
|
||||||
file_entry[37] = (size >> 16) & 0xff;
|
file_entry[37] = (size >> 16) & 0xff;
|
||||||
file_entry[38] = (size >> 8) & 0xff;
|
file_entry[38] = (size >> 8) & 0xff;
|
||||||
file_entry[39] = (size) & 0xff;
|
file_entry[39] = (size) & 0xff;
|
||||||
|
file.close();
|
||||||
memcpy(&(names[ENTRY_SIZE * index]), file_entry, ENTRY_SIZE);
|
memcpy(&(names[ENTRY_SIZE * index]), file_entry, ENTRY_SIZE);
|
||||||
index = index + 1;
|
index = index + 1;
|
||||||
}
|
}
|
||||||
@ -1933,6 +1934,7 @@ byte onGetFile(SCSI_DEVICE *dev, const byte *cdb) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32_t file_total = file.size();
|
uint32_t file_total = file.size();
|
||||||
|
|
||||||
byte buf[512] = {0};
|
byte buf[512] = {0};
|
||||||
file.seekSet(offset * 512);
|
file.seekSet(offset * 512);
|
||||||
int read_bytes = file.read(buf, 512);
|
int read_bytes = file.read(buf, 512);
|
||||||
@ -1950,10 +1952,10 @@ byte onGetFile(SCSI_DEVICE *dev, const byte *cdb) {
|
|||||||
File receveFile;
|
File receveFile;
|
||||||
byte onSendFilePrep(SCSI_DEVICE *dev, const byte *cdb)
|
byte onSendFilePrep(SCSI_DEVICE *dev, const byte *cdb)
|
||||||
{
|
{
|
||||||
char file_name[33];
|
char file_name[MAX_MAC_PATH+1];
|
||||||
|
|
||||||
memset(file_name, '\0', 33);
|
memset(file_name, '\0', MAX_MAC_PATH+1);
|
||||||
readDataPhase(33, m_buf);
|
readDataPhase(MAX_MAC_PATH+1, m_buf);
|
||||||
strcpy(file_name, (char *)m_buf);
|
strcpy(file_name, (char *)m_buf);
|
||||||
|
|
||||||
SD.chdir("/shared");
|
SD.chdir("/shared");
|
||||||
|
@ -242,6 +242,7 @@ enum SCSI_DEVICE_TYPE
|
|||||||
#define HDIMG_LUN_POS 3 // Position to embed LUN numbers
|
#define HDIMG_LUN_POS 3 // Position to embed LUN numbers
|
||||||
#define HDIMG_BLK_POS 5 // Position to embed block size numbers
|
#define HDIMG_BLK_POS 5 // Position to embed block size numbers
|
||||||
#define MAX_FILE_PATH 64 // Maximum file name length
|
#define MAX_FILE_PATH 64 // Maximum file name length
|
||||||
|
#define MAX_MAC_PATH 32 // Maximum file name length on vintage macs
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Data byte to BSRR register setting value and parity table
|
* Data byte to BSRR register setting value and parity table
|
||||||
|
Loading…
x
Reference in New Issue
Block a user