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

mavlink / MAVSDK / 6739182515

02 Nov 2023 11:04PM UTC coverage: 36.952% (+5.7%) from 31.229%
6739182515

push

github

web-flow
Merge pull request #2060 from mavlink/pr-split-ftp

Split Ftp plugin into Ftp and FtpServer

2002 of 2573 new or added lines in 26 files covered. (77.81%)

3 existing lines in 3 files now uncovered.

9920 of 26846 relevant lines covered (36.95%)

112.43 hits per line

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

81.25
/src/system_tests/fs_helpers.cpp
1
#include "fs_helpers.h"
2
#include <algorithm>
3
#include <iostream>
4
#include <iterator>
5
#include <filesystem>
6
#include <fstream>
7
#include <cstring>
8

9
bool create_temp_file(const fs::path& path, size_t len, uint8_t start)
121✔
10
{
11
    const auto parent_path = path.parent_path();
242✔
12
    create_directories(parent_path);
121✔
13

14
    std::ofstream tempfile{};
242✔
15
    tempfile.open(path, std::ios::out | std::ios::binary | std::ios::trunc);
121✔
16
    if (tempfile.fail()) {
121✔
NEW
17
        std::cout << "Failed to open temp file.";
×
NEW
18
        return false;
×
19
    }
20

21
    for (size_t i = 0; i < len; ++i) {
151,571✔
22
        const char c = (i + start) % 256;
151,450✔
23
        tempfile.write(&c, 1);
151,450✔
24
    }
25

26
    tempfile.close();
121✔
27

28
    return true;
121✔
29
}
30

31
bool reset_directories(const fs::path& path)
123✔
32
{
33
    std::error_code ec;
123✔
34
    fs::remove_all(path, ec);
123✔
35

36
    return fs::create_directories(path);
123✔
37
}
38

39
bool are_files_identical(const fs::path& path1, const fs::path& path2)
9✔
40
{
41
    std::ifstream file1(path1, std::ios::binary);
18✔
42
    std::ifstream file2(path2, std::ios::binary);
18✔
43

44
    if (!file1) {
9✔
NEW
45
        std::cout << "Could not open " << path1 << std::endl;
×
NEW
46
        return false;
×
47
    }
48

49
    if (!file2) {
9✔
NEW
50
        std::cout << "Could not open " << path2 << std::endl;
×
NEW
51
        return false;
×
52
    }
53

54
    std::istreambuf_iterator<char> begin1(file1);
9✔
55
    std::istreambuf_iterator<char> begin2(file2);
9✔
56
    std::istreambuf_iterator<char> end;
9✔
57

58
    return std::equal(begin1, end, begin2, end);
9✔
59
}
60

61
bool file_exists(const fs::path& path)
6✔
62
{
63
    return fs::exists(path);
6✔
64
}
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

© 2025 Coveralls, Inc