Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use 64 bit file sizes in remote file classes #43

Merged
merged 1 commit into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
12 changes: 6 additions & 6 deletions RemoteFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,16 +232,17 @@ 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);

do
{
bytesToRead = ((fileSize - bytesRead) >= TRANSFER_SIZE) ? TRANSFER_SIZE : (fileSize - bytesRead);
bytesToRead = ((fileSize - bytesRead) >= TRANSFER_SIZE) ? TRANSFER_SIZE : static_cast<uint32_t>(fileSize - bytesRead);
size = m_socket.read(m_fileBuffer.data() + bytesRead, bytesToRead);
bytesRead += size;
}
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