Skip to content

Commit

Permalink
Use 64 bit file sizes in remote file classes
Browse files Browse the repository at this point in the history
Updates the remote directory and file handling classes to function
correctly with the new 64 bit file sizes that are embedded in Yggdrasil
packets.
  • Loading branch information
Colin Ward committed Dec 14, 2023
1 parent d07671a commit da988c1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
6 changes: 4 additions & 2 deletions RemoteDir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ int RRemoteDir::open(const char *a_pattern)
if (handler->getResponse()->m_result == KErrNone)
{
const char *name;
uint32_t size;
TInt64 size;
TEntry *Entry;
TTime Now;

Expand All @@ -84,7 +84,7 @@ int RRemoteDir::open(const char *a_pattern)
{
name = reinterpret_cast<const char *>(payload);
payload += strlen(name) + 1;
READ_INT(size, payload);
READ_INT_64(size, payload);
payload += sizeof(size);

if ((Entry = m_entries.Append(name)) != NULL)
Expand All @@ -104,6 +104,8 @@ int RRemoteDir::open(const char *a_pattern)
}
catch (RSocket::Error &a_exception)
{
Utils::info("RRemoteDir::open() => Unable to perform I/O on socket (Error = %d)", a_exception.m_result);

retVal = KErrNotFound;
}

Expand Down
10 changes: 5 additions & 5 deletions RemoteFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,11 @@ int RRemoteFile::read(unsigned char *a_buffer, int a_length)

void RRemoteFile::readFromRemote()
{
uint32_t bytesRead = 0, bytesToRead, fileSize, size;
uint32_t bytesRead = 0, bytesToRead, size;
TInt64 fileSize;

m_socket.read(&fileSize, sizeof(fileSize));
SWAP(&fileSize);
SWAP64(&fileSize);

m_fileBuffer.resize(fileSize);

Expand Down Expand Up @@ -338,13 +339,12 @@ int RRemoteFile::close()
handler = new CSend(&m_socket, m_fileName.c_str());
handler->sendRequest();

int fileSize = static_cast<int>(m_fileBuffer.size());
SWAP(&fileSize);
TInt64 fileSize = static_cast<int>(m_fileBuffer.size());
SWAP64(&fileSize);

m_socket.write(&fileSize, sizeof(fileSize));
m_socket.write(m_fileBuffer.data(), static_cast<int>(m_fileBuffer.size()));

delete handler;
m_dirty = false;
}
catch (RSocket::Error &a_exception)
Expand Down

0 comments on commit da988c1

Please sign in to comment.