-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathutils.cpp
25 lines (22 loc) · 874 Bytes
/
utils.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include "utils.h"
#include <iostream>
#include <limits.h>
std::string GetPath(const std::string& filename)
{
char path[PATH_MAX];
std::string compiler = realpath(filename.c_str(), path);
std::string::size_type pos = compiler.find_last_of("/");
return compiler.substr(0, pos);
}
// TODO: Do we want a source location too?
void InternalCompilerError(const char* file, int line, const std::string& msg)
{
std::cerr << "Internal compiler error at " << file << ":" << line << ":\n" << msg << "\n" << std::endl;
std::abort();
}
void InternalCompilerError(const char* file, int line, const std::string& condStr, const std::string& msg)
{
std::cerr << "Condition failed: " << condStr << "\n";
std::cerr << "Internal compiler error at " << file << ":" << line << ":\n" << msg << "\n" << std::endl;
std::abort();
}