1 // Copyright (C) 2018-2019 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
6 * \brief TODO: short file description
17 #include <mach/clock.h>
18 #include <mach/mach.h>
21 namespace testing { namespace FileUtils {
23 /// @brief TODO: description
24 const std::string FileSeparator = "\\";
26 /// @brief TODO: description
27 const std::string FileSeparator = "/";
29 /// @brief TODO: description
30 const std::string FileSeparator2 = "/"; // second option
33 * @brief TODO: description
34 * @param fileName - TODO: param
35 * @return TODO: ret obj
37 long long fileSize(const char *fileName);
40 * @brief TODO: description
41 * @param f - TODO: param
42 * @return TODO: ret obj
44 inline long long fileSize(const std::string& f) {
45 return fileSize(f.c_str());
49 * @brief TODO: description
50 * @param fileName - TODO: param
51 * @return TODO: ret obj
53 inline bool fileExist(const char *fileName) {
54 return fileSize(fileName)>=0;
58 * @brief TODO: description
59 * @param fileName - TODO: param
60 * @return TODO: ret obj
62 inline bool fileExist(const std::string &fileName) {
63 return fileExist(fileName.c_str());
67 * @brief TODO: description
68 * @param file_name - TODO: param
69 * @param buffer - TODO: param
70 * @param maxSize - TODO: param
72 void readAllFile(const std::string& file_name, void* buffer, size_t maxSize);
75 * @brief TODO: description
76 * @param filepath - TODO: param
77 * @return TODO: ret obj
79 std::string folderOf(const std::string &filepath);
82 * @brief TODO: description
83 * @param folder - TODO: param
84 * @param file - TODO: param
85 * @return TODO: ret obj
87 std::string makePath(const std::string& folder, const std::string& file);
90 * @brief TODO: description
91 * @param filepath - TODO: param
92 * @return TODO: ret obj
94 std::string fileNameNoExt(const std::string &filepath);
97 * @brief TODO: description
98 * @param filename - TODO: param
99 * @return TODO: ret obj
101 std::string fileExt(const char* filename);
104 * @brief TODO: description
105 * @param filename - TODO: param
106 * @return TODO: ret obj
108 std::string fileExt(const std::string &filename);
111 * @brief TODO: description
112 * @return TODO: please use c++11 chrono module for time operations
114 inline long long GetMicroSecTimer() {
117 static LARGE_INTEGER Frequency = { 0 };
119 if (Frequency.QuadPart==0) QueryPerformanceFrequency(&Frequency);
120 QueryPerformanceCounter(&timer);
121 return (timer.QuadPart * 1000000) / Frequency.QuadPart;
127 host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock);
128 clock_get_time(cclock, &mts);
129 mach_port_deallocate(mach_task_self(), cclock);
130 now.tv_sec = mts.tv_sec;
131 now.tv_nsec = mts.tv_nsec;
133 clock_gettime(CLOCK_REALTIME, &now);
135 return now.tv_sec * 1000000L + now.tv_nsec / 1000;