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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Copyright (C) 2011 Davis E. King (davis@dlib.net)
// License: Boost Software License See LICENSE.txt for the full license.
#include "common.h"
#include <fstream>
// ----------------------------------------------------------------------------------------
std::string strip_path (
const std::string& str,
const std::string& prefix
)
{
unsigned long i;
for (i = 0; i < str.size() && i < prefix.size(); ++i)
{
if (str[i] != prefix[i])
return str;
}
if (i < str.size() && (str[i] == '/' || str[i] == '\\'))
++i;
return str.substr(i);
}
// ----------------------------------------------------------------------------------------
void make_empty_file (
const std::string& filename
)
{
std::ofstream fout(filename.c_str());
if (!fout)
throw dlib::error("ERROR: Unable to open " + filename + " for writing.");
}
// ----------------------------------------------------------------------------------------