mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 01:44:06 -04:00
scan_directory() for python
This commit is contained in:
parent
1a02e76c28
commit
be494155cf
@ -1886,6 +1886,33 @@ scan_directory(vector_string &contents) const {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_PYTHON
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: Filename::scan_directory
|
||||||
|
// Access: Published
|
||||||
|
// Description: This variant on scan_directory returns a Python list
|
||||||
|
// of strings on success, or None on failure.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
PyObject *Filename::
|
||||||
|
scan_directory() const {
|
||||||
|
vector_string contents;
|
||||||
|
if (!scan_directory(contents)) {
|
||||||
|
PyObject *result = Py_None;
|
||||||
|
Py_INCREF(result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
PyObject *result = PyList_New(contents.size());
|
||||||
|
for (size_t i = 0; i < contents.size(); ++i) {
|
||||||
|
const string &filename = contents[i];
|
||||||
|
PyObject *str = PyString_FromStringAndSize(filename.data(), filename.size());
|
||||||
|
PyList_SET_ITEM(result, i, str);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
#endif // HAVE_PYTHON
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: Filename::open_read
|
// Function: Filename::open_read
|
||||||
// Access: Published
|
// Access: Published
|
||||||
|
@ -181,6 +181,9 @@ PUBLISHED:
|
|||||||
int find_on_searchpath(const DSearchPath &searchpath);
|
int find_on_searchpath(const DSearchPath &searchpath);
|
||||||
|
|
||||||
bool scan_directory(vector_string &contents) const;
|
bool scan_directory(vector_string &contents) const;
|
||||||
|
#ifdef HAVE_PYTHON
|
||||||
|
PyObject *scan_directory() const;
|
||||||
|
#endif
|
||||||
|
|
||||||
bool open_read(ifstream &stream) const;
|
bool open_read(ifstream &stream) const;
|
||||||
bool open_write(ofstream &stream, bool truncate = true) const;
|
bool open_write(ofstream &stream, bool truncate = true) const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user