mirror of
https://github.com/EvernodeXRPL/hpcore.git
synced 2026-04-29 15:37:59 +00:00
Replaced ifstreams with file read inside the config and patch config read. (#220)
This commit is contained in:
@@ -364,6 +364,23 @@ namespace util
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads from a given file discriptor.
|
||||
* @param fd File descriptor to be read.
|
||||
* @param buf String buffer to be populated.
|
||||
* @return Returns number of bytes read in a successful read and -1 on error.
|
||||
*/
|
||||
int read_from_fd(const int fd, std::string &buf)
|
||||
{
|
||||
struct stat st;
|
||||
if (fstat(fd, &st) == -1)
|
||||
return -1;
|
||||
|
||||
buf.resize(st.st_size);
|
||||
|
||||
return read(fd, buf.data(), buf.size());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a record lock for the file descriptor. Lock is associated with the process (Not for forked child processes).
|
||||
* @param fd File descriptor to be locked.
|
||||
|
||||
Reference in New Issue
Block a user