Eliminate includes file and include locally as required.

This commit is contained in:
Brad Arant 2022-02-14 07:04:20 -08:00
parent be014d0d24
commit 91286649cc
10 changed files with 46 additions and 38 deletions

View File

@ -1,40 +1,42 @@
#ifndef __DirectoryEntry_h__ #ifndef __DirectoryEntry_h__
# define __DirectoryEntry_h__ # define __DirectoryEntry_h__
# include "includes" #include <dirent.h>
#include <string>
#include <string.h>
namespace coreutils { namespace coreutils {
class DirectoryEntry { class DirectoryEntry {
public: public:
DirectoryEntry(struct dirent *entry) { DirectoryEntry(struct dirent *entry) {
memcpy(&this->entry, entry, sizeof(struct dirent)); memcpy(&this->entry, entry, sizeof(struct dirent));
} }
~DirectoryEntry() {} ~DirectoryEntry() {}
std::string getName() { std::string getName() {
return std::string(entry.d_name); return std::string(entry.d_name);
} }
unsigned char getType() { unsigned char getType() {
return entry.d_type; return entry.d_type;
} }
bool isFile() { bool isFile() {
return entry.d_type == DT_REG; return entry.d_type == DT_REG;
} }
bool isDirectory() { bool isDirectory() {
return entry.d_type == DT_DIR; return entry.d_type == DT_DIR;
} }
private: private:
struct dirent entry; struct dirent entry;
}; };
} }
#endif #endif

View File

@ -1,5 +1,10 @@
#include "File.h" #include "File.h"
#include "Exception.h" #include "Exception.h"
#include <sys/stat.h>
#include <sstream>
#include <fcntl.h>
#include <sys/types.h>
#include <unistd.h>
namespace coreutils { namespace coreutils {

3
File.h
View File

@ -1,7 +1,8 @@
#ifndef __File_h__ #ifndef __File_h__
#define __File_h__ #define __File_h__
#include "includes" #include <string>
#include <fcntl.h>
/// ///
/// File /// File

View File

@ -34,20 +34,10 @@ namespace coreutils {
out << newHeaders.str() << "\r\n"; out << newHeaders.str() << "\r\n";
} }
void IMFMessage::addHeader(const char *key, const char *value) { void IMFMessage::addHeader(IMFHeader header) {
newHeaders << key << ": " << value << "\r\n"; std::stringstream out;
} header.output(out);
newHeaders << out.str() ;
void IMFMessage::addHeader(const char *key, std::string &value) {
newHeaders << key << ": " << value << "\r\n";
}
void IMFMessage::addHeader(ZString &key, ZString &value) {
newHeaders << key << ": " << value << "\r\n";
}
void IMFMessage::addHeader(const char *key, ZString &value) {
newHeaders << key << ": " << value << "\r\n";
} }
ZString IMFMessage::getHeader(ZString key, bool valueOnly) { ZString IMFMessage::getHeader(ZString key, bool valueOnly) {

View File

@ -1,6 +1,7 @@
#ifndef __IMFMessage_h__ #ifndef __IMFMessage_h__
#define __IMFMessage_h__ #define __IMFMessage_h__
#include <typeinfo>
#include <sstream> #include <sstream>
#include <string> #include <string>
#include <vector> #include <vector>
@ -10,6 +11,10 @@
namespace coreutils { namespace coreutils {
///
///
///
class IMFMessage : public ZString { class IMFMessage : public ZString {
public: public:
@ -19,10 +24,7 @@ namespace coreutils {
void output(std::stringstream &out); void output(std::stringstream &out);
void addHeader(const char *key, std::string &value); void addHeader(IMFHeader header);
void addHeader(const char *key, const char *value);
void addHeader(ZString &key, ZString &value);
void addHeader(const char *key, ZString &value);
ZString getHeader(ZString key, bool valueOnly = true); ZString getHeader(ZString key, bool valueOnly = true);
ZString getHeaderKeyPairValue(const char *headerKey, const char *key); ZString getHeaderKeyPairValue(const char *headerKey, const char *key);

View File

@ -18,12 +18,12 @@ namespace coreutils {
if(mode == LENGTH) { if(mode == LENGTH) {
sprintf(contentLength, "%li", content.str().length()); sprintf(contentLength, "%li", content.str().length());
ZString conlen(contentLength); ZString conlen(contentLength);
addHeader("Content-Length", conlen); addHeader(IMFHeader("Content-Length", conlen));
} }
else else
addHeader("Transfer-Encoding", "chunked"); addHeader(IMFHeader("Transfer-Encoding", "chunked"));
addHeader("Server", "JETServer v0.0.1"); addHeader(IMFHeader("Server", "JETServer v0.0.1"));
output(response); output(response);
response << content.str(); response << content.str();

View File

@ -1,8 +1,9 @@
#ifndef __IMFResponse_h__ #ifndef __IMFResponse_h__
#define __IMFResponse_h__ #define __IMFResponse_h__
#include "includes"
#include "IMFMessage.h" #include "IMFMessage.h"
#include <sstream>
#include <string>
namespace coreutils { namespace coreutils {

View File

@ -1,5 +1,10 @@
#include "Log.h" #include "Log.h"
#include "LogListener.h" #include "LogListener.h"
#include <sstream>
#include <iostream>
#include <iomanip>
#include <sys/syscall.h>
#include <unistd.h>
namespace coreutils { namespace coreutils {

4
Log.h
View File

@ -1,9 +1,11 @@
#ifndef __Log_h__ #ifndef __Log_h__
#define __Log_h__ #define __Log_h__
#include "includes"
#include "File.h" #include "File.h"
#include "LogListener.h" #include "LogListener.h"
#include <mutex>
#include <string>
#include <sstream>
namespace coreutils { namespace coreutils {