diff options
Diffstat (limited to 'protocols/Tox')
-rw-r--r-- | protocols/Tox/src/tox_avatars.cpp | 6 | ||||
-rw-r--r-- | protocols/Tox/src/tox_profile.cpp | 2 | ||||
-rw-r--r-- | protocols/Tox/src/tox_transfer.cpp | 17 | ||||
-rw-r--r-- | protocols/Tox/src/tox_transfer.h | 2 |
4 files changed, 15 insertions, 12 deletions
diff --git a/protocols/Tox/src/tox_avatars.cpp b/protocols/Tox/src/tox_avatars.cpp index 8f4410c5f3..a19f47faf9 100644 --- a/protocols/Tox/src/tox_avatars.cpp +++ b/protocols/Tox/src/tox_avatars.cpp @@ -35,7 +35,7 @@ void CToxProto::SetToxAvatar(std::tstring path, bool checkHash) return;
}*/
- int length;
+ long length;
uint8_t *data;
FILE *hFile = _tfopen(path.c_str(), L"rb");
if (!hFile)
@@ -55,8 +55,8 @@ void CToxProto::SetToxAvatar(std::tstring path, bool checkHash) }
data = (uint8_t*)mir_alloc(length);
- size_t readed = fread(data, sizeof(uint8_t), length, hFile);
- if (readed != length)
+ long read = fread(data, sizeof(uint8_t), length, hFile);
+ if (read != length)
{
fclose(hFile);
debugLogA("CToxProto::SetToxAvatar: failed to read avatar file");
diff --git a/protocols/Tox/src/tox_profile.cpp b/protocols/Tox/src/tox_profile.cpp index d169b21f78..9a1c2fc51b 100644 --- a/protocols/Tox/src/tox_profile.cpp +++ b/protocols/Tox/src/tox_profile.cpp @@ -31,7 +31,7 @@ bool CToxProto::LoadToxProfile() }
fseek(profile, 0, SEEK_END);
- size_t size = _ftelli64(profile);
+ long size = ftell(profile);
rewind(profile);
if (size == 0)
{
diff --git a/protocols/Tox/src/tox_transfer.cpp b/protocols/Tox/src/tox_transfer.cpp index 1ae16c2455..cad34a1646 100644 --- a/protocols/Tox/src/tox_transfer.cpp +++ b/protocols/Tox/src/tox_transfer.cpp @@ -178,8 +178,8 @@ HANDLE __cdecl CToxProto::SendFile(MCONTACT hContact, const PROTOCHAR*, PROTOCHA return NULL;
}
- fseek(hFile, 0, SEEK_END);
- size_t fileSize = _ftelli64(hFile);
+ _fseeki64(hFile, 0, SEEK_END);
+ uint64_t fileSize = _ftelli64(hFile);
rewind(hFile);
char *name = mir_utf8encodeW(fileName);
@@ -206,10 +206,10 @@ void CToxProto::SendFileAsync(void *arg) FileTransferParam *transfer = (FileTransferParam*)arg;
transfer->status = STARTED;
- size_t dataSize = 0;
- size_t fileProgress = transfer->pfts.currentFileProgress;
- size_t fileSize = transfer->pfts.currentFileSize;
- size_t chunkSize = min(fileSize, (size_t)tox_file_data_size(tox, transfer->friendNumber));
+ int dataSize = 0;
+ uint64_t fileProgress = transfer->pfts.currentFileProgress;
+ uint64_t fileSize = transfer->pfts.currentFileSize;
+ int chunkSize = min(tox_file_data_size(tox, transfer->friendNumber), fileSize);
uint8_t *data = (uint8_t*)mir_alloc(chunkSize);
while (transfer->status == STARTED && transfer->hFile != NULL && fileProgress < fileSize)
@@ -217,9 +217,12 @@ void CToxProto::SendFileAsync(void *arg) if (dataSize == 0)
{
dataSize = min(chunkSize, fileSize - fileProgress);
- if (fread(data, sizeof(uint8_t), dataSize, transfer->hFile) != dataSize)
+ int read = fread(data, sizeof(uint8_t), dataSize, transfer->hFile);
+ if (read != dataSize)
{
debugLogA("CToxProto::SendFileAsync: failed to read from file (%d)", transfer->fileNumber);
+ debugLogA("CToxProto::SendFileAsync: read %d of %d (%d)", read, dataSize, transfer->fileNumber);
+ debugLogA("CToxProto::SendFileAsync: sent %llu of %llu of file (%d)", transfer->pfts.currentFileProgress, transfer->pfts.currentFileSize, transfer->fileNumber);
ProtoBroadcastAck(transfer->pfts.hContact, ACKTYPE_FILE, ACKRESULT_FAILED, (HANDLE)transfer, 0);
transfer->status = FAILED;
tox_file_send_control(tox, transfer->friendNumber, transfer->GetDirection(), transfer->fileNumber, TOX_FILECONTROL_KILL, NULL, 0);
diff --git a/protocols/Tox/src/tox_transfer.h b/protocols/Tox/src/tox_transfer.h index 9658266191..a73b86bef6 100644 --- a/protocols/Tox/src/tox_transfer.h +++ b/protocols/Tox/src/tox_transfer.h @@ -21,7 +21,7 @@ struct FileTransferParam int friendNumber;
int fileNumber;
- FileTransferParam(int friendNumber, int fileNumber, const TCHAR* fileName, size_t fileSize)
+ FileTransferParam(int friendNumber, int fileNumber, const TCHAR* fileName, uint64_t fileSize)
{
status = NONE;
hFile = NULL;
|