| 179 | } |
| 180 | |
| 181 | bool NetConnection::startSendingFile(const char *fileName) |
| 182 | { |
| 183 | if(!fileName || Con::getBoolVariable("$NetConnection::neverUploadFiles")) |
| 184 | { |
| 185 | sendConnectionMessage(SendNextDownloadRequest); |
| 186 | return false; |
| 187 | } |
| 188 | |
| 189 | mCurrentDownloadingFile = FileStream::createAndOpen( fileName, Torque::FS::File::Read ); |
| 190 | if(!mCurrentDownloadingFile) |
| 191 | { |
| 192 | // the server didn't have the file, so send a 0 byte chunk: |
| 193 | Con::printf("No such file '%s'.", fileName); |
| 194 | postNetEvent(new FileChunkEvent(NULL, 0)); |
| 195 | return false; |
| 196 | } |
| 197 | |
| 198 | Con::printf("Sending file '%s'.", fileName); |
| 199 | mCurrentFileBufferSize = mCurrentDownloadingFile->getStreamSize(); |
| 200 | mCurrentFileBufferOffset = 0; |
| 201 | |
| 202 | // always have 32 file chunks (64 bytes each) in transit |
| 203 | sendConnectionMessage(FileDownloadSizeMessage, mCurrentFileBufferSize); |
| 204 | for(U32 i = 0; i < 32; i++) |
| 205 | sendFileChunk(); |
| 206 | return true; |
| 207 | } |
| 208 | |
| 209 | void NetConnection::sendNextFileDownloadRequest() |
| 210 | { |
no test coverage detected