blob: 9f1589d47790039aec0efff7bd6f1d7f92196cd8 (
plain)
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
40
41
|
// -*- related-file-name: "../../liblcdf/filename.cc" -*-
#ifndef LCDF_FILENAME_HH
#define LCDF_FILENAME_HH
#include <lcdf/string.hh>
#include <stdio.h>
class Filename { public:
Filename() : _dir("."), _actual(0) { }
Filename(const String &);
Filename(const String &dir, const String &name);
Filename(FILE *, const String &fake_name);
bool fake() const { return _actual != 0; }
const String &directory() const { return _dir; }
const String &name() const { return _name; }
const String &path() const { return _path; }
String base() const;
String extension() const;
operator bool() const { return _name; }
bool operator!() const { return !_name; }
FILE *open_read(bool binary = false) const;
bool readable() const;
FILE *open_write(bool binary = false) const;
Filename from_directory(const String &n) const { return Filename(_dir, n);}
private:
mutable String _dir; // mutable for c_str()
mutable String _name;
mutable String _path;
FILE *_actual;
};
#endif
|