-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathio.cpp
More file actions
36 lines (29 loc) · 676 Bytes
/
Copy pathio.cpp
File metadata and controls
36 lines (29 loc) · 676 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// This file contains I/O functions.
// There should be no need to modify this file.
#include <fcntl.h>
#include <unistd.h>
#include "io.hpp"
#include "engine.hpp"
// out of line definitions for the mutexes in SyncCerr/SyncCout
std::mutex SyncCerr::mut;
std::mutex SyncCout::mut;
void ClientConnection::freeHandle()
{
if(m_handle != -1)
{
close(m_handle);
m_handle = -1;
}
}
ReadResult ClientConnection::readInput(ClientCommand& read_into)
{
switch(read(m_handle, &read_into, sizeof(ClientCommand)))
{
case 0: //
return ReadResult::EndOfFile;
case sizeof(ClientCommand): //
return ReadResult::Success;
default: //
return ReadResult::Error;
}
}