From dca15ebabfa257fc76bb409387ec5e33887ca9da Mon Sep 17 00:00:00 2001 From: Nicholas Hastings Date: Mon, 27 Oct 2014 17:25:01 -0400 Subject: [PATCH] Fix OpenDirectory with use_valve_fs requirement of trailing slash. --- core/logic/smn_filesystem.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/core/logic/smn_filesystem.cpp b/core/logic/smn_filesystem.cpp index 16f20e3c..a5d2d8b2 100644 --- a/core/logic/smn_filesystem.cpp +++ b/core/logic/smn_filesystem.cpp @@ -271,13 +271,19 @@ static cell_t sm_OpenDirectory(IPluginContext *pContext, const cell_t *params) return 0; } + if (!path[0]) + { + return pContext->ThrowNativeError("Invalid file path"); + } + Handle_t handle = 0; if (params[0] >= 2 && params[2]) { + size_t len = strlen(path); char wildcardedPath[PLATFORM_MAX_PATH]; - snprintf(wildcardedPath, sizeof(wildcardedPath), "%s*", path); ValveDirectory *valveDir = new ValveDirectory; + snprintf(wildcardedPath, sizeof(wildcardedPath), "%s%s*", path, (path[len-1] != '/' && path[len-1] != '\\') ? "/" : ""); char *pathID; if ((err=pContext->LocalToStringNULL(params[3], &pathID)) != SP_ERROR_NONE)