Skip to content

Commit

Permalink
add pointers to control where is the pointer in to the file.
Browse files Browse the repository at this point in the history
  • Loading branch information
ErnestoAvedillo committed Jun 25, 2024
1 parent b071748 commit c686ce7
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions mandatory/src/FileContent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,18 @@ std::string FileContent::getContent()
{
content = "";
char buffer[MAX_SENT_BYTES];
lastSendingPosition = currentSendingPosition;
if (this->startRange != 0 && this->getFirstFragment())
{
//file.seekg(0, std::ios::beg);
file.seekg(startRange, std::ios::beg);
lastSendingPosition = currentSendingPosition;
file.read(buffer, MAX_SENT_BYTES);
content.append(buffer, file.gcount());
this->setIsSendComplete(true);
//this->setIsSendComplete(true);
}
else
{
lastSendingPosition = currentSendingPosition;
file.read(buffer, MAX_SENT_BYTES);
content.append(buffer, file.gcount());
}
Expand Down Expand Up @@ -299,6 +300,8 @@ long long FileContent::getFileSize()

long long FileContent::getCurrentSendingPosition()
{
if (currentSendingPosition < 0)
return this->getFileSize()-1;
return currentSendingPosition;
}

Expand Down

0 comments on commit c686ce7

Please sign in to comment.