File: filename.hh

package info (click to toggle)
lcdf-typetools 2.92%2Bdfsg1-0.1
  • links: PTS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 2,884 kB
  • sloc: cpp: 34,407; ansic: 2,106; sh: 1,032; makefile: 306
file content (41 lines) | stat: -rw-r--r-- 1,056 bytes parent folder | download | duplicates (20)
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