From 591bb5635d9c0b6ef9b67d9cc1433cce1079caa7 Mon Sep 17 00:00:00 2001 From: nakst <> Date: Thu, 10 Mar 2022 21:32:05 +0000 Subject: [PATCH] global: rename DirectoryEnumerateChildren to DirectoryEnumerate --- apps/file_manager/commands.cpp | 2 +- apps/file_manager/folder.cpp | 2 +- apps/script_console.cpp | 2 +- desktop/api_tests.cpp | 12 ++++++------ desktop/files.cpp | 6 +++--- desktop/os.header | 2 +- kernel/files.cpp | 18 +++++++++--------- kernel/posix.cpp | 2 +- kernel/syscall.cpp | 2 +- util/api_table.ini | 2 +- util/build_core.c | 2 +- util/script.c | 14 +++++++------- util/start.script | 2 +- 13 files changed, 34 insertions(+), 34 deletions(-) diff --git a/apps/file_manager/commands.cpp b/apps/file_manager/commands.cpp index 975f8ad..425f88a 100644 --- a/apps/file_manager/commands.cpp +++ b/apps/file_manager/commands.cpp @@ -271,7 +271,7 @@ EsError CommandPasteFile(String source, String destinationBase, void **copyBuffe if (error == ES_ERROR_INCORRECT_NODE_TYPE) { uintptr_t childCount; - EsDirectoryChild *buffer = EsDirectoryEnumerateChildren(STRING(source), &childCount, &error); + EsDirectoryChild *buffer = EsDirectoryEnumerate(STRING(source), &childCount, &error); if (error == ES_SUCCESS) { error = EsPathCreate(STRING(destination), ES_NODE_DIRECTORY, false); diff --git a/apps/file_manager/folder.cpp b/apps/file_manager/folder.cpp index 93021e3..5016ef5 100644 --- a/apps/file_manager/folder.cpp +++ b/apps/file_manager/folder.cpp @@ -76,7 +76,7 @@ EsError FSDirEnumerate(Folder *folder) { uintptr_t _entryCount; EsError error; - EsDirectoryChild *buffer = EsDirectoryEnumerateChildren(STRING(folder->path), &_entryCount, &error); + EsDirectoryChild *buffer = EsDirectoryEnumerate(STRING(folder->path), &_entryCount, &error); if (error == ES_SUCCESS) { for (uintptr_t i = 0; i < _entryCount; i++) { diff --git a/apps/script_console.cpp b/apps/script_console.cpp index 79e8699..a135fa2 100644 --- a/apps/script_console.cpp +++ b/apps/script_console.cpp @@ -396,7 +396,7 @@ int External_DirectoryInternalStartIteration(ExecutionContext *context, Value *r STACK_POP_STRING(entryText, entryBytes); EsHeapFree(directoryIterationBuffer); EsError error; - directoryIterationBuffer = EsDirectoryEnumerateChildren(entryText, entryBytes, &directoryIterationBufferCount, &error); + directoryIterationBuffer = EsDirectoryEnumerate(entryText, entryBytes, &directoryIterationBufferCount, &error); directoryIterationBufferPosition = 0; if (error == ES_SUCCESS) return EXTCALL_RETURN_ERR_UNMANAGED; RETURN_ERROR(error); diff --git a/desktop/api_tests.cpp b/desktop/api_tests.cpp index e67f03d..dcf7264 100644 --- a/desktop/api_tests.cpp +++ b/desktop/api_tests.cpp @@ -550,10 +550,10 @@ struct { const int testVariable = 3; -bool DirectoryEnumerateChildrenRecursive(const char *path, size_t pathBytes) { +bool DirectoryEnumerateRecursive(const char *path, size_t pathBytes) { size_t count; EsError error; - EsDirectoryChild *buffer = EsDirectoryEnumerateChildren(path, pathBytes, &count, &error); + EsDirectoryChild *buffer = EsDirectoryEnumerate(path, pathBytes, &count, &error); if (error != ES_SUCCESS) { EsPrint("Error %i enumerating at path \"%s\".\n", error, pathBytes, path); @@ -575,14 +575,14 @@ bool DirectoryEnumerateChildrenRecursive(const char *path, size_t pathBytes) { } if (dataBytes != (size_t) buffer[i].fileSize) { - EsPrint("File size mismatch reading path \"%s\" (got %d from EsFileReadAll, got %d from EsDirectoryEnumerateChildren).\n", + EsPrint("File size mismatch reading path \"%s\" (got %d from EsFileReadAll, got %d from EsDirectoryEnumerate).\n", childPathBytes, childPath, dataBytes, buffer[i].fileSize); return false; } EsHeapFree(data); } else if (buffer[i].type == ES_NODE_DIRECTORY) { - if (!DirectoryEnumerateChildrenRecursive(childPath, childPathBytes)) { + if (!DirectoryEnumerateRecursive(childPath, childPathBytes)) { return false; } } @@ -603,7 +603,7 @@ bool OldTests2018() { CHECK(testStruct.b == 2); CHECK(testVariable == 3); - CHECK(DirectoryEnumerateChildrenRecursive(EsLiteral("|Settings:"))); + CHECK(DirectoryEnumerateRecursive(EsLiteral("|Settings:"))); for (int count = 16; count < 100; count += 30) { EsHandle handles[100]; @@ -647,7 +647,7 @@ bool OldTests2018() { CHECK(EsPathExists(EsLiteral("|Settings:/a.txt"))); } - CHECK(DirectoryEnumerateChildrenRecursive(EsLiteral("|Settings:"))); + CHECK(DirectoryEnumerateRecursive(EsLiteral("|Settings:"))); { void *a = EsCRTmalloc(0x100000); diff --git a/desktop/files.cpp b/desktop/files.cpp index 749dff7..0505a0a 100644 --- a/desktop/files.cpp +++ b/desktop/files.cpp @@ -98,12 +98,12 @@ EsError EsFileControl(EsHandle file, uint32_t flags) { return EsSyscall(ES_SYSCALL_FILE_CONTROL, file, flags, 0, 0); } -ptrdiff_t DirectoryEnumerateChildrenFromHandle(EsHandle directory, EsDirectoryChild *buffer, size_t size) { +ptrdiff_t DirectoryEnumerateFromHandle(EsHandle directory, EsDirectoryChild *buffer, size_t size) { if (!size) return 0; return EsSyscall(ES_SYSCALL_DIRECTORY_ENUMERATE, directory, (uintptr_t) buffer, size, 0); } -EsDirectoryChild *EsDirectoryEnumerateChildren(const char *path, ptrdiff_t pathBytes, size_t *countOut, EsError *errorOut) { +EsDirectoryChild *EsDirectoryEnumerate(const char *path, ptrdiff_t pathBytes, size_t *countOut, EsError *errorOut) { *countOut = 0; *errorOut = ES_ERROR_UNKNOWN; @@ -131,7 +131,7 @@ EsDirectoryChild *EsDirectoryEnumerateChildren(const char *path, ptrdiff_t pathB EsDirectoryChild *buffer = (EsDirectoryChild *) EsHeapAllocate(sizeof(EsDirectoryChild) * node.directoryChildren, true); if (buffer) { - ptrdiff_t result = DirectoryEnumerateChildrenFromHandle(node.handle, buffer, node.directoryChildren); + ptrdiff_t result = DirectoryEnumerateFromHandle(node.handle, buffer, node.directoryChildren); if (ES_CHECK_ERROR(result)) { EsHeapFree(buffer); diff --git a/desktop/os.header b/desktop/os.header index d4d54c0..7255e0c 100644 --- a/desktop/os.header +++ b/desktop/os.header @@ -2126,7 +2126,7 @@ function void EsINIZeroTerminate(EsINIState *s); function const void *EsBundleFind(const EsBundle *bundle, STRING name, size_t *byteCount = ES_NULL) @out(byteCount) @fixed_buffer_out(return, byteCount*); // Pass null as the bundle to use the current application's bundle. -function EsDirectoryChild *EsDirectoryEnumerateChildren(STRING path, size_t *count, EsError *error = ES_NULL) @out(count) @out(error) @heap_array_out(return, count*); +function EsDirectoryChild *EsDirectoryEnumerate(STRING path, size_t *count, EsError *error = ES_NULL) @out(count) @out(error) @heap_array_out(return, count*); function void *EsFileReadAll(STRING filePath, size_t *fileSize, EsError *error = ES_NULL) @out(fileSize) @out(error) @heap_buffer_out(return, fileSize*); // Free with EsHeapFree. function void *EsFileReadAllFromHandle(EsHandle handle, size_t *fileSize, EsError *error = ES_NULL) @out(fileSize) @out(error) @heap_buffer_out(return, fileSize*); // Free with EsHeapFree. diff --git a/kernel/files.cpp b/kernel/files.cpp index 2517dfe..f9cdc78 100644 --- a/kernel/files.cpp +++ b/kernel/files.cpp @@ -66,7 +66,7 @@ void FSNodeCloseHandle(KNode *node, uint32_t flags); EsError FSNodeDelete(KNode *node); EsError FSNodeMove(KNode *node, KNode *destination, const char *newName, size_t nameNameBytes); EsError FSFileResize(KNode *node, EsFileOffset newSizeBytes); -ptrdiff_t FSDirectoryEnumerateChildren(KNode *node, K_USER_BUFFER EsDirectoryChild *buffer, size_t bufferSize); +ptrdiff_t FSDirectoryEnumerate(KNode *node, K_USER_BUFFER EsDirectoryChild *buffer, size_t bufferSize); EsError FSFileControl(KNode *node, uint32_t flags); bool FSTrimCachedNode(MMObjectCache *); bool FSTrimCachedDirectoryEntry(MMObjectCache *); @@ -650,7 +650,7 @@ EsError FSNodeMove(KNode *node, KNode *_newParent, const char *newName, size_t n return error; } -void _FSDirectoryEnumerateChildrenVisit(AVLItem *item, K_USER_BUFFER EsDirectoryChild *buffer, size_t bufferSize, uintptr_t *position) { +void _FSDirectoryEnumerateVisit(AVLItem *item, K_USER_BUFFER EsDirectoryChild *buffer, size_t bufferSize, uintptr_t *position) { if (!item || *position == bufferSize) { return; } @@ -660,7 +660,7 @@ void _FSDirectoryEnumerateChildrenVisit(AVLItem *item, K_USER_ *position = *position + 1; if (entry->node && (entry->node->flags & NODE_DELETED)) { - KernelPanic("_FSDirectoryEnumerateChildrenVisit - Deleted node %x found in directory tree.\n"); + KernelPanic("_FSDirectoryEnumerateVisit - Deleted node %x found in directory tree.\n"); } size_t nameBytes = entry->item.key.longKeyBytes > ES_MAX_DIRECTORY_CHILD_NAME_LENGTH ? ES_MAX_DIRECTORY_CHILD_NAME_LENGTH : entry->item.key.longKeyBytes; @@ -670,15 +670,15 @@ void _FSDirectoryEnumerateChildrenVisit(AVLItem *item, K_USER_ output->directoryChildren = entry->directoryChildren; output->nameBytes = nameBytes; - _FSDirectoryEnumerateChildrenVisit(item->children[0], buffer, bufferSize, position); - _FSDirectoryEnumerateChildrenVisit(item->children[1], buffer, bufferSize, position); + _FSDirectoryEnumerateVisit(item->children[0], buffer, bufferSize, position); + _FSDirectoryEnumerateVisit(item->children[1], buffer, bufferSize, position); } -ptrdiff_t FSDirectoryEnumerateChildren(KNode *node, K_USER_BUFFER EsDirectoryChild *buffer, size_t bufferSize) { +ptrdiff_t FSDirectoryEnumerate(KNode *node, K_USER_BUFFER EsDirectoryChild *buffer, size_t bufferSize) { // uint64_t start = ProcessorReadTimeStamp(); if (node->directoryEntry->type != ES_NODE_DIRECTORY) { - KernelPanic("FSDirectoryEnumerateChildren - Node %x is not a directory.\n", node); + KernelPanic("FSDirectoryEnumerate - Node %x is not a directory.\n", node); } FSDirectory *directory = (FSDirectory *) node; @@ -699,12 +699,12 @@ ptrdiff_t FSDirectoryEnumerateChildren(KNode *node, K_USER_BUFFER EsDirectoryChi } uintptr_t position = 0; - _FSDirectoryEnumerateChildrenVisit(directory->entries.root, buffer, bufferSize, &position); + _FSDirectoryEnumerateVisit(directory->entries.root, buffer, bufferSize, &position); KWriterLockReturn(&directory->writerLock, K_LOCK_EXCLUSIVE); // uint64_t end = ProcessorReadTimeStamp(); - // EsPrint("FSDirectoryEnumerateChildren took %dmcs for %d items.\n", (end - start) / KGetTimeStampTicksPerUs(), position); + // EsPrint("FSDirectoryEnumerate took %dmcs for %d items.\n", (end - start) / KGetTimeStampTicksPerUs(), position); return position; } diff --git a/kernel/posix.cpp b/kernel/posix.cpp index ee385b3..8ad6592 100644 --- a/kernel/posix.cpp +++ b/kernel/posix.cpp @@ -707,7 +707,7 @@ namespace POSIX { return -ENOMEM; } - size_t count = FSDirectoryEnumerateChildren(file->node, buffer, bufferSize); + size_t count = FSDirectoryEnumerate(file->node, buffer, bufferSize); if (ES_CHECK_ERROR(count)) { EsHeapFree(buffer, sizeof(EsDirectoryChild) * bufferSize, K_FIXED); diff --git a/kernel/syscall.cpp b/kernel/syscall.cpp index 2935726..d50d518 100644 --- a/kernel/syscall.cpp +++ b/kernel/syscall.cpp @@ -1183,7 +1183,7 @@ SYSCALL_IMPLEMENT(ES_SYSCALL_DIRECTORY_ENUMERATE) { if (argument2 > SYSCALL_BUFFER_LIMIT / sizeof(EsDirectoryChild)) SYSCALL_RETURN(ES_FATAL_ERROR_INVALID_BUFFER, true); SYSCALL_BUFFER(argument1, argument2 * sizeof(EsDirectoryChild), 1, true /* write */); - SYSCALL_RETURN(FSDirectoryEnumerateChildren(node, (K_USER_BUFFER EsDirectoryChild *) argument1, argument2), false); + SYSCALL_RETURN(FSDirectoryEnumerate(node, (K_USER_BUFFER EsDirectoryChild *) argument1, argument2), false); } SYSCALL_IMPLEMENT(ES_SYSCALL_FILE_CONTROL) { diff --git a/util/api_table.ini b/util/api_table.ini index 86ae045..256ec74 100644 --- a/util/api_table.ini +++ b/util/api_table.ini @@ -37,7 +37,6 @@ EsCommandSetCheck=35 EsTextboxGetContentsAsDouble=36 EsFileStoreAppend=37 EsBufferFlushToFileStore=38 -EsDirectoryEnumerateChildren=39 EsPathExists=40 EsInstanceSetClassViewer=41 EsPathDelete=42 @@ -494,3 +493,4 @@ DateToLinear=492 EsRectangleContainsAll=493 EsListViewFixedItemSetEnumStringsForColumn=494 EsImageDisplayGetImageHeight=495 +EsDirectoryEnumerate=496 diff --git a/util/build_core.c b/util/build_core.c index 37ec643..03fd3e2 100644 --- a/util/build_core.c +++ b/util/build_core.c @@ -414,7 +414,7 @@ void CreateImportNode(const char *path, ImportNode *node) { char *path2 = EsPOSIXConvertPath(path, &path2Bytes, true); EsError error; uintptr_t childCount; - EsDirectoryChild *children = EsDirectoryEnumerateChildren(path2, path2Bytes, &childCount, &error); + EsDirectoryChild *children = EsDirectoryEnumerate(path2, path2Bytes, &childCount, &error); EsAssert(error == ES_SUCCESS); EsHeapFree(path2, 0, NULL); diff --git a/util/script.c b/util/script.c index ff36fc5..bdd70bd 100644 --- a/util/script.c +++ b/util/script.c @@ -490,7 +490,7 @@ void *LibraryGetAddress(void *library, const char *name); char baseModuleSource[] = { // TODO Temporary. "struct DirectoryChild { str name; bool isDirectory; int size; };" - "DirectoryChild[] Dir() { str[] names = DirectoryEnumerateChildren(\"0:\"):assert(); DirectoryChild[] result = new DirectoryChild[]; result:resize(names:len()); for int i = 0; i < names:len(); i += 1 { result[i] = new DirectoryChild; result[i].name = names[i]; result[i].isDirectory = PathIsDirectory(\"0:/\"+names[i]); result[i].size = FileGetSize(\"0:/\"+names[i]):default(-1); } return result;}" + "DirectoryChild[] Dir() { str[] names = DirectoryEnumerate(\"0:\"):assert(); DirectoryChild[] result = new DirectoryChild[]; result:resize(names:len()); for int i = 0; i < names:len(); i += 1 { result[i] = new DirectoryChild; result[i].name = names[i]; result[i].isDirectory = PathIsDirectory(\"0:/\"+names[i]); result[i].size = FileGetSize(\"0:/\"+names[i]):default(-1); } return result;}" "str[] OpenDocumentEnumerate() #extcall;" // Logging: @@ -621,12 +621,12 @@ char baseModuleSource[] = { " }" " return #success;" "}" - "err[str[]] DirectoryEnumerateChildren(str path) {" + "err[str[]] DirectoryEnumerate(str path) {" " str[] result = new str[];" " err[void] e = _DirectoryInternalEnumerateChildren(path, \"\", result, false);" " reterr e; return result;" "}" - "err[str[]] DirectoryEnumerateChildrenRecursively(str path) {" + "err[str[]] DirectoryEnumerateRecursively(str path) {" " str[] result = new str[];" " err[void] e = _DirectoryInternalEnumerateChildren(PathTrimTrailingSlash(path), \"\", result, true);" " reterr e; return result;" @@ -635,7 +635,7 @@ char baseModuleSource[] = { "str PathTrimTrailingSlash(str x) { if x:len() > 0 && x[x:len() - 1] == \"/\" { return StringSlice(x, 0, x:len() - 1); } return x; }" "err[void] PathDeleteRecursively(str path) {" - " err[str[]] e = DirectoryEnumerateChildrenRecursively(path);" + " err[str[]] e = DirectoryEnumerateRecursively(path);" " if str[] all in e {" " for int i = 0; i < all:len(); i += 1 {" " str p = path + \"/\" + all[i];" @@ -655,7 +655,7 @@ char baseModuleSource[] = { " }" "}" "err[void] PathCopyRecursively(str source, str destination) {" - " err[str[]] e = DirectoryEnumerateChildrenRecursively(source);" + " err[str[]] e = DirectoryEnumerateRecursively(source);" " if str[] all in e {" " reterr PathCreateDirectory(destination);" " for int i = 0; i < all:len(); i += 1 {" @@ -691,8 +691,8 @@ char baseModuleSource[] = { "err[void] PathCopyFilteredInto(str sourceDirectory, str[] filter, int filterWildcard, str destinationDirectory) {" " assert filter:len() > 0;" " err[str[]] e;" - " if filterWildcard != -1 || filter:len() > 1 { e = DirectoryEnumerateChildrenRecursively(sourceDirectory); }" - " else { e = DirectoryEnumerateChildren(sourceDirectory); }" + " if filterWildcard != -1 || filter:len() > 1 { e = DirectoryEnumerateRecursively(sourceDirectory); }" + " else { e = DirectoryEnumerate(sourceDirectory); }" " if str[] items in e {" " for int i = 0; i < items:len(); i += 1 {" " if PathMatchesFilter(items[i], filter, filterWildcard) {" diff --git a/util/start.script b/util/start.script index 0cf83e7..170c6c1 100644 --- a/util/start.script +++ b/util/start.script @@ -84,7 +84,7 @@ void GenerateAPISamples() { str sourceFolder = "apps/samples/"; str destinationFolder = "root/API Samples/"; - for str configFile in DirectoryEnumerateChildren(sourceFolder):assert() { + for str configFile in DirectoryEnumerate(sourceFolder):assert() { if StringEndsWith(configFile, ".ini") { str[] config = StringSplitByCharacter(FileReadAll(sourceFolder + configFile):assert(), "\n", false); str sourceFile;