• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Razakhel / RaZ / 18059902851

27 Sep 2025 12:32PM UTC coverage: 74.093% (+0.04%) from 74.05%
18059902851

push

github

Razakhel
[Utils/Logger] Added formatted logging overloads

- Formatted calls to logging functions and made use of std::format() in several other places

100 of 170 new or added lines in 36 files covered. (58.82%)

4 existing lines in 2 files now uncovered.

8334 of 11248 relevant lines covered (74.09%)

1757.71 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

89.47
/src/RaZ/Utils/FileUtils.cpp
1
#include "RaZ/Utils/FilePath.hpp"
2
#include "RaZ/Utils/FileUtils.hpp"
3

4
#include "tracy/Tracy.hpp"
5

6
#include <fstream>
7

8
namespace Raz {
9

10
namespace {
11

12
template <typename T>
13
T readFile(const FilePath& filePath) {
34✔
14
  ZoneScopedN("[FileUtils]::readFile");
15
  ZoneTextF("Path: %s", filePath.toUtf8().c_str());
16

17
  std::ifstream file(filePath, std::ios::binary | std::ios::ate);
34✔
18

19
  if (!file)
34✔
NEW
20
    throw std::runtime_error(std::format("[FileUtils] Could not open the file '{}'", filePath));
×
21

22
  // Note that tellg() doesn't necessarily return a size, but rather a mark pointing at a specific place in the file
23
  // When opening a file in binary, however, it is currently pretty much always represented as a byte offset
24
  // See: https://stackoverflow.com/a/22986486/3292304
25
  const auto fileSize = file.tellg();
34✔
26

27
  if (fileSize == -1)
34✔
NEW
28
    throw std::runtime_error(std::format("[FileUtils] Failed to get the size of the file '{}'", filePath));
×
29

30
  // Returning at the beginning of the file to read it
31
  file.seekg(0, std::ios::beg);
34✔
32

33
  T fileContent;
34✔
34
  fileContent.resize(static_cast<std::size_t>(fileSize));
34✔
35
  file.read(reinterpret_cast<char*>(fileContent.data()), static_cast<std::streamsize>(fileSize));
34✔
36

37
  return fileContent;
68✔
38
}
34✔
39

40
} // namespace
41

42
bool FileUtils::isReadable(const FilePath& filePath) {
44✔
43
  return std::ifstream(filePath).good();
44✔
44
}
45

46
std::vector<unsigned char> FileUtils::readFileToArray(const FilePath& filePath) {
12✔
47
  ZoneScopedN("FileUtils::readFileToArray");
48
  ZoneTextF("Path: %s", filePath.toUtf8().c_str());
49
  return readFile<std::vector<unsigned char>>(filePath);
12✔
50
}
51

52
std::string FileUtils::readFileToString(const FilePath& filePath) {
22✔
53
  ZoneScopedN("FileUtils::readFileToString");
54
  ZoneTextF("Path: %s", filePath.toUtf8().c_str());
55
  return readFile<std::string>(filePath);
22✔
56
}
57

58
} // namespace Raz
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc