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

nasa / trick / 25459968639

06 May 2026 08:42PM UTC coverage: 55.916% (-0.8%) from 56.7%
25459968639

Pull #2011

github

web-flow
Merge f11412d5f into 7054e405e
Pull Request #2011: Single-file CI and code style adoption

14607 of 26123 relevant lines covered (55.92%)

466416.66 hits per line

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

48.28
/trick_source/sim_services/Message/MessageFile.cpp
1

2
#include <iostream>
3
#include <unistd.h>
4
#include <string>
5

6
#include "trick/MessageFile.hh"
7
#include "trick/command_line_protos.h"
8
#include "trick/message_proto.h"
9
#include "trick/message_type.h"
10

11

12

13
/**
14
@details
15
-# Initializes everything
16
*/
17
Trick::MessageFile::MessageFile() {
374✔
18
    enabled = 1 ;
374✔
19
    color = 0 ;
374✔
20
}
374✔
21

22
/**
23
@details
24
-# Overwrites the file name
25
*/
26
int Trick::MessageFile::set_file_name(std::string in_name) {
×
27

28
    file_name = in_name ;
×
29
    return(0) ;
×
30

31
}
32

33
/**
34
@details
35
-# If enabled and level < 100
36
    -# Write the header and message to the file stream
37
    -# Flush the stream
38
*/
39
void Trick::MessageFile::update( unsigned int level , std::string header, std::string message ) {
×
40

41
    if ( enabled && level < 100 ) {
×
42
        out_stream << header << message ;
×
43
        out_stream.flush() ;
×
44
    }
45

46
}
×
47

48
/**
49
@details
50
-# Deletes the current output file
51
-# Opens a new file with the name "file_name"
52
*/
53
int Trick::MessageFile::init() {
310✔
54

55
    unlink((std::string(command_line_args_get_output_dir()) + "/" + file_name).c_str()) ;
620✔
56

57
    // Create the directory if we need to
58
    int pos = file_name.find_last_of("/");
310✔
59
    if (pos != std::string::npos) {
310✔
60
        std::string dir = std::string(command_line_args_get_output_dir()) + "/" + file_name.substr(0, pos);
×
61
        create_path(dir.c_str());
×
62
    }
×
63

64
    out_stream.open((std::string(command_line_args_get_output_dir()) + "/" + file_name).c_str() , std::fstream::out | std::fstream::app ) ;
620✔
65
    if (!out_stream.is_open()) {
310✔
66
        message_publish(MSG_ERROR, "Failed to open message file %s\n",file_name.c_str());
×
67
    }
68
    return(0) ;
310✔
69
}
70

71
int Trick::MessageFile::restart() {
×
72
    out_stream.open((std::string(command_line_args_get_output_dir()) + "/" + file_name).c_str() , std::fstream::out | std::fstream::app ) ;
×
73
    return(0) ;
×
74
}
75

76
/**
77
@details
78
-# Close the file stream
79
*/
80
Trick::MessageFile::~MessageFile() {
374✔
81
    out_stream.close() ;
374✔
82
}
374✔
83

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