<commit_before>///
/// @file util.cpp
/// including definition of FD and MyExeption
///

#include "include/util.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <string>
#include <exception>
#include <iostream>

FD::FD(): fd_(-1){}

FD::FD(const std::string& filepath, int o_flag, mode_t mode)
{
  open(filepath, o_flag, mode);
}

FD::~FD()
{
  close()
}

void FD::open(const std::string& filepath, int o_flag, mode_t mode)
{
  fd_ = ::open(filepath.c_str(), o_flag, mode);
  if(fd_ == -1){
	throw MyException("FD", "open");
  }
}

void FD::close()
{
  if(fd_ != -1){
	::close(fd_);
  }
}

MyException::MyException(const std::string& cause1, const std::string& cause2, const std::string& cause3) throw()
{<commit_msg>* 二重クローズに対応する<commit_after>///
/// @file util.cpp
/// including definition of FD and MyExeption
///

#include "include/util.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <string>
#include <exception>
#include <iostream>

FD::FD(): fd_(-1){}

FD::FD(const std::string& filepath, int o_flag, mode_t mode)
{
  open(filepath, o_flag, mode);
}

FD::~FD()
{
  close()
}

void FD::open(const std::string& filepath, int o_flag, mode_t mode)
{
  fd_ = ::open(filepath.c_str(), o_flag, mode);
  if(fd_ == -1){
	throw MyException("FD", "open");
  }
}

void FD::close()
{
  if(fd_ != -1){
	::close(fd_);
	fd_ = -1;
  }
}

MyException::MyException(const std::string& cause1, const std::string& cause2, const std::string& cause3) throw()
{
{'fraction_non_alphanumeric': 0.20670773442847365, 'fraction_numerical': 0.00889801505817933, 'mean_word_length': 4.516981132075472, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3030431', 'n_tokens_mistral': 601, 'n_tokens_neox': 596, 'n_words': 137}