dtoolutil: Fix Filename division operator in Python 3

This commit is contained in:
rdb 2021-02-22 18:14:12 +01:00
parent 601ca323f5
commit 9d9337dc4d
3 changed files with 13 additions and 0 deletions

View File

@ -122,6 +122,7 @@ PUBLISHED:
INLINE Filename operator + (const std::string &other) const;
INLINE Filename operator / (const Filename &other) const;
EXTENSION(Filename __truediv__(const Filename &other) const);
// Or, you can use any of these.
INLINE std::string get_fullpath() const;

View File

@ -184,6 +184,15 @@ __fspath__() const {
return PyUnicode_FromWideChar(filename.data(), (Py_ssize_t)filename.size());
}
/**
* Returns a new Filename that is composed of the other filename added to the
* end of this filename, with an intervening slash added if necessary.
*/
Filename Extension<Filename>::
__truediv__(const Filename &other) const {
return Filename(*_this, other);
}
/**
* This variant on scan_directory returns a Python list of strings on success,
* or None on failure.

View File

@ -34,6 +34,9 @@ public:
PyObject *__reduce__(PyObject *self) const;
PyObject *__repr__() const;
PyObject *__fspath__() const;
Filename __truediv__(const Filename &other) const;
PyObject *scan_directory() const;
};