FileRequest: make sure we're dealing with a file.
Trying to Read from a directory results in an error code, but we also missed that because an unsigned variable was used to store the result. Fixes #10210.
This commit is contained in:
@@ -35,7 +35,7 @@ BFileRequest::_ProtocolLoop()
|
|||||||
// FIXME error handling (file does not exists, etc.)
|
// FIXME error handling (file does not exists, etc.)
|
||||||
BFile file(fUrl.Path().String(), B_READ_ONLY);
|
BFile file(fUrl.Path().String(), B_READ_ONLY);
|
||||||
|
|
||||||
if(file.InitCheck() != B_OK)
|
if(file.InitCheck() != B_OK || !file.IsFile())
|
||||||
return B_PROT_CONNECTION_FAILED;
|
return B_PROT_CONNECTION_FAILED;
|
||||||
|
|
||||||
// Send all notifications to listener, if any
|
// Send all notifications to listener, if any
|
||||||
@@ -45,7 +45,7 @@ BFileRequest::_ProtocolLoop()
|
|||||||
file.GetSize(&size);
|
file.GetSize(&size);
|
||||||
fListener->DownloadProgress(this, size, size);
|
fListener->DownloadProgress(this, size, size);
|
||||||
|
|
||||||
size_t chunkSize;
|
ssize_t chunkSize;
|
||||||
char chunk[4096];
|
char chunk[4096];
|
||||||
while((chunkSize = file.Read(chunk, sizeof(chunk))) > 0)
|
while((chunkSize = file.Read(chunk, sizeof(chunk))) > 0)
|
||||||
fListener->DataReceived(this, chunk, chunkSize);
|
fListener->DataReceived(this, chunk, chunkSize);
|
||||||
|
|||||||
Reference in New Issue
Block a user