mirror of
https://github.com/QB64-Phoenix-Edition/QB64pe.git
synced 2024-07-06 19:50:22 +00:00
Update func__files() to return directory names with trailing slash
This commit is contained in:
parent
28c9964d09
commit
c558d2a2d2
|
@ -629,6 +629,8 @@ static const char *GetDirectoryEntryName(const char *fileSpec) {
|
||||||
/// @param passed Flags for optional parameters
|
/// @param passed Flags for optional parameters
|
||||||
/// @return Retuns a qbs with the directory entry name or an empty string if there are no more entries
|
/// @return Retuns a qbs with the directory entry name or an empty string if there are no more entries
|
||||||
qbs *func__files(qbs *qbsFileSpec, int32_t passed) {
|
qbs *func__files(qbs *qbsFileSpec, int32_t passed) {
|
||||||
|
static std::string directory;
|
||||||
|
std::string pathName;
|
||||||
const char *entry;
|
const char *entry;
|
||||||
qbs *final;
|
qbs *final;
|
||||||
|
|
||||||
|
@ -636,6 +638,7 @@ qbs *func__files(qbs *qbsFileSpec, int32_t passed) {
|
||||||
if (passed) {
|
if (passed) {
|
||||||
std::string fileSpec(reinterpret_cast<char *>(qbsFileSpec->chr), qbsFileSpec->len);
|
std::string fileSpec(reinterpret_cast<char *>(qbsFileSpec->chr), qbsFileSpec->len);
|
||||||
|
|
||||||
|
filepath_split(fileSpec, directory, pathName); // split the file path
|
||||||
entry = GetDirectoryEntryName(fileSpec.c_str());
|
entry = GetDirectoryEntryName(fileSpec.c_str());
|
||||||
|
|
||||||
if (IsStringEmpty(entry)) {
|
if (IsStringEmpty(entry)) {
|
||||||
|
@ -648,10 +651,10 @@ qbs *func__files(qbs *qbsFileSpec, int32_t passed) {
|
||||||
entry = GetDirectoryEntryName(nullptr);
|
entry = GetDirectoryEntryName(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
filepath_join(pathName, directory, entry);
|
||||||
auto size = strlen(entry);
|
auto size = strlen(entry);
|
||||||
|
|
||||||
// TODO: Need to join the base directory here!
|
if (size && DirectoryExists(pathName.c_str())) {
|
||||||
if (DirectoryExists(entry)) {
|
|
||||||
// Add a trailing slash if it is a directory
|
// Add a trailing slash if it is a directory
|
||||||
final = qbs_new(size + 1, 1);
|
final = qbs_new(size + 1, 1);
|
||||||
memcpy(final->chr, entry, size);
|
memcpy(final->chr, entry, size);
|
||||||
|
|
Loading…
Reference in a new issue