16 const time_t t = time(NULL);
17 struct tm* systemtime = localtime(&t);
18 std::string file_name =
"/" + std::to_string(
test_file_id_) +
"-" + std::to_string(1900 + systemtime->tm_year) +
"-" +
19 std::to_string(1 + systemtime->tm_mon) +
"-" + std::to_string(systemtime->tm_mday) +
"-" +
20 std::to_string(systemtime->tm_hour) +
"-" + std::to_string(systemtime->tm_min) +
"-" +
21 std::to_string(systemtime->tm_sec) + file_type;
29 std::ifstream file(file_path, std::ios::binary);
33 file.seekg(0, file.end);
34 data_buff.
size = file.tellg();
36 file.seekg(0, file.beg);
37 data_buff.
data =
new char[data_buff.
size];
38 file.read(data_buff.
data, data_buff.
size);
42 std::cout <<
"Fail to open expected audio file: " << file_path << std::endl;
51 std::fstream file(file_path, std::ios::in | std::ios::binary);
52 std::stringstream sstream;
54 sstream << file.rdbuf();
57 std::string str(sstream.str());
70 if ((dir = opendir(dir_path.c_str())) == NULL)
72 std::cout << (
"Open dir error...");
76 while ((ptr = readdir(dir)) != NULL)
78 if (strcmp(ptr->d_name,
".") == 0 || strcmp(ptr->d_name,
"..") == 0)
82 else if (ptr->d_type == 8)
84 files_name.push_back(ptr->d_name);
86 else if (ptr->d_type == 10)
90 else if (ptr->d_type == 4)
92 files_name.push_back(ptr->d_name);
97 sort(files_name.begin(), files_name.end());
103 std::getline(str, line);
104 std::stringstream lineStream(line);
108 while (std::getline(lineStream, cell,
','))
110 m_data.push_back(cell);
113 if (!lineStream && cell.empty())
116 m_data.push_back(
"");
123 while (!infile.eof())
125 if (infile.bad() || infile.fail())
127 std::cout <<
"Fail to open the CSV file! " << std::endl;
131 csv_table_.push_back(m_data);
138 int size = row_vector.size();
139 std::ofstream outFile(csv_file, std::ios::app);
140 if (outFile.is_open())
142 for (
int i = 0; i < size; i++)
144 outFile << row_vector[i] <<
',';
146 outFile << std::endl;
150 std::cout <<
"Fail to open the CSV file! " << std::endl;
std::string readFileAsString(const std::string file_path)
std::string setFileName(std::string file_type)
std::vector< std::vector< std::string > > readAllCSV(std::istream &str)
void readNextRow(std::istream &str)
void writeRowData(std::string csv_file, std::vector< std::string > row_vector)
void getAllFilesName(std::string dir_path, std::vector< std::string > &files_name)
struct DataBuff readFileAsDatabuffer(const std::string file_path)