MCPcopy Create free account
hub / github.com/AutoHotkey/AutoHotkey / FileDelete

Method FileDelete

source/script2.cpp:8358–8373  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8356}
8357
8358ResultType Line::FileDelete(LPTSTR aFilePattern)
8359{
8360 if (!*aFilePattern)
8361 return LineError(ERR_PARAM1_INVALID, FAIL_OR_OK);
8362
8363 // The no-wildcard case could be handled via FilePatternApply(), but handling it this
8364 // way ensures deleting a non-existent path without wildcards is considered a failure:
8365 if (!StrChrAny(aFilePattern, _T("?*"))) // No wildcards; just a plain path/filename.
8366 {
8367 SetLastError(0); // For sanity: DeleteFile appears to set it only on failure.
8368 return SetLastErrorMaybeThrow(!DeleteFile(aFilePattern));
8369 }
8370
8371 // Otherwise aFilePattern contains wildcards, so we'll search for all matches and delete them.
8372 return FilePatternApply(aFilePattern, FILE_LOOP_FILES_ONLY, false, FileDeleteCallback, NULL);
8373}
8374
8375
8376

Callers

nothing calls this directly

Calls 1

StrChrAnyFunction · 0.85

Tested by

no test coverage detected