wavelength 1.0.0
Loading...
Searching...
No Matches
filepath.h
Go to the documentation of this file.
1#pragma once
2
3#include <vector>
4
5#include "os/binstream.h"
6#include "os/string.h"
7
14class FilePath : public String {
15public:
22 ~FilePath() override = default;
23
33 static void SetRoot(const char *pszRoot);
34
42 void Set(const char *pszPath);
43
53 const char *RelativePath() const;
54
63 static String sRoot;
64};
65
75inline BinStream &operator<<(BinStream &stream, const std::vector<FilePath> &paths) {
76 const int nSize = static_cast<int>(paths.size());
77 stream.WriteEndian(&nSize, sizeof(nSize));
78 for (const FilePath &path : paths) {
79 stream.WriteString(path.RelativePath());
80 }
81 return stream;
82}
Stream of raw bytes, the base of the memory, file, and network streams.
Definition binstream.h:22
BinStream & WriteString(const char *pszText)
Write a string with its length first.
void WriteEndian(const void *pData, int nBytes)
Write a value of 2, 4, 8, or 16 bytes, reversing its bytes unless the stream is little endian.
Path of a file, kept relative to a shared root directory.
Definition filepath.h:14
~FilePath() override=default
Destroy the object.
static void SetRoot(const char *pszRoot)
Set the root directory that relative paths resolve against.
static String sRoot
The root directory that relative paths resolve against, .
Definition filepath.h:63
void Set(const char *pszPath)
Set the path, resolving a relative path against the root directory.
const char * RelativePath() const
Report the path relative to the root directory.
String()
Construct an empty string.
Definition string.h:26
BinStream & operator<<(BinStream &stream, const std::vector< FilePath > &paths)
Write a vector of paths as its size followed by each path relative to the root directory.
Definition filepath.h:75