Created read method on MString to read from sockets.

This commit is contained in:
Brad Arant 2024-07-09 12:56:10 -07:00
parent cca957b948
commit 7341d26852
3 changed files with 16 additions and 1 deletions

View File

@ -6,6 +6,8 @@
#include <format> #include <format>
#include <iomanip> #include <iomanip>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
namespace coreutils { namespace coreutils {
@ -247,6 +249,13 @@ namespace coreutils {
} }
length = size; length = size;
} }
MString &MString::read(int fd) {
char ch;
while(::read(fd, &ch, 1))
write(ch);
return *this;
}
int MString::offset() { int MString::offset() {
return cursor - data; return cursor - data;

View File

@ -213,6 +213,12 @@ namespace coreutils {
/// ///
MString &write(ZString &value); MString &write(ZString &value);
///
/// Read data from a socket and store in MString.
///
MString &read(int fd);
int offset(); int offset();

View File

@ -5,7 +5,7 @@ do
filename="${file%.*}" filename="${file%.*}"
list="$list $filename.o" list="$list $filename.o"
echo -n "Compiling $filename..." echo -n "Compiling $filename..."
g++ -g -c $file -std=c++20 & g++ -g -c $file -std=c++23 &
if [ $? = '0' ] if [ $? = '0' ]
then then
echo "OK" echo "OK"