Added vscode
This commit is contained in:
1 parent
6894968732
commit
c00476719c
10 files changed
+183
-158
No files matched your search
@@ -2,40 +2,40 @@
|
||||
#include "Exception.h"
|
||||
|
||||
namespace coreutils {
|
||||
|
||||
|
||||
File::File(std::string fileName, int mode, int authority) {
|
||||
|
||||
|
||||
this->fileName = fileName;
|
||||
|
||||
|
||||
struct stat status;
|
||||
stat(fileName.c_str(), &status);
|
||||
|
||||
|
||||
buffer = NULL;
|
||||
|
||||
|
||||
setBufferSize(status.st_size);
|
||||
|
||||
fd = open(fileName.c_str(), mode, authority);
|
||||
|
||||
fd = open(fileName.c_str(), mode, authority);
|
||||
if(fd < 0) {
|
||||
std::stringstream temp;
|
||||
temp << "Error opening file " << fileName << ".";
|
||||
throw Exception(temp.str(), __FILE__, __LINE__);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
File::~File() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void File::setBufferSize(size_t size) {
|
||||
buffer = (char *)realloc(buffer, size);
|
||||
this->size = size;
|
||||
}
|
||||
|
||||
|
||||
void File::read() {
|
||||
size = ::read(fd, buffer, size);
|
||||
setBufferSize(size);
|
||||
setBufferSize(size);
|
||||
}
|
||||
|
||||
|
||||
void File::write(std::string data) {
|
||||
::write(fd, data.c_str(), data.length());
|
||||
}
|
||||
@@ -43,5 +43,5 @@ namespace coreutils {
|
||||
std::string File::asString() {
|
||||
return std::string(buffer, size);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user