Created read method on MString to read from sockets.

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

No files matched your search

+9
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;
+6
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();
+1 -1
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"