Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/thirdparty/embree/common/sys/filename.h
9912 views
1
// Copyright 2009-2021 Intel Corporation
2
// SPDX-License-Identifier: Apache-2.0
3
4
#pragma once
5
6
#include "platform.h"
7
8
namespace embree
9
{
10
/*! Convenience class for handling file names and paths. */
11
class FileName
12
{
13
public:
14
15
/*! create an empty filename */
16
FileName ();
17
18
/*! create a valid filename from a string */
19
FileName (const char* filename);
20
21
/*! create a valid filename from a string */
22
FileName (const std::string& filename);
23
24
/*! returns path to executable */
25
static FileName executableFolder();
26
27
/*! auto convert into a string */
28
operator std::string() const { return filename; }
29
30
/*! returns a string of the filename */
31
const std::string str() const { return filename; }
32
33
/*! returns a c-string of the filename */
34
const char* c_str() const { return filename.c_str(); }
35
36
/*! returns the path of a filename */
37
FileName path() const;
38
39
/*! returns the file of a filename */
40
std::string base() const;
41
42
/*! returns the base of a filename without extension */
43
std::string name() const;
44
45
/*! returns the file extension */
46
std::string ext() const;
47
48
/*! drops the file extension */
49
FileName dropExt() const;
50
51
/*! replaces the file extension */
52
FileName setExt(const std::string& ext = "") const;
53
54
/*! adds file extension */
55
FileName addExt(const std::string& ext = "") const;
56
57
/*! concatenates two filenames to this/other */
58
FileName operator +( const FileName& other ) const;
59
60
/*! concatenates two filenames to this/other */
61
FileName operator +( const std::string& other ) const;
62
63
/*! removes the base from a filename (if possible) */
64
FileName operator -( const FileName& base ) const;
65
66
/*! == operator */
67
friend bool operator==(const FileName& a, const FileName& b);
68
69
/*! != operator */
70
friend bool operator!=(const FileName& a, const FileName& b);
71
72
/*! output operator */
73
friend std::ostream& operator<<(std::ostream& cout, const FileName& filename);
74
75
private:
76
std::string filename;
77
};
78
}
79
80