From a6f207a2a598e74516d996e63e40a0fcea562629 Mon Sep 17 00:00:00 2001 From: cosineblast <55855728+cosineblast@users.noreply.github.com> Date: Wed, 17 Jan 2024 00:33:49 -0300 Subject: [PATCH] Improve FindAbsolutePath documentation and API --- src/cc65/input.c | 2 +- src/cc65/preproc.c | 2 +- src/common/pathutil.c | 9 +++++---- src/common/pathutil.h | 8 ++++---- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/cc65/input.c b/src/cc65/input.c index a5a0c7e37..a84d68405 100644 --- a/src/cc65/input.c +++ b/src/cc65/input.c @@ -317,7 +317,7 @@ void OpenIncludeFile (const char* Name, InputType IT, StringPool *FilesToIgnore) } /* Resolve real path of file in case of a symlink */ - M = FindAbsolutePath(N); + M = FindRealPath(N); if (M == 0) { PPError ("Cannot resolve absolute path of '%s'", N); xfree (N); diff --git a/src/cc65/preproc.c b/src/cc65/preproc.c index 4fdb65283..69358bdc3 100644 --- a/src/cc65/preproc.c +++ b/src/cc65/preproc.c @@ -2979,7 +2979,7 @@ static void DoPragmaOnce (void) AbEnd ("Cannot find the full path for the file %s", Filename); } - const char * const FullPath = FindAbsolutePath(IncludePath); + const char * const FullPath = FindRealPath(IncludePath); if (FullPath == NULL) { AbEnd ("Failed to find the full path for the file %s", Filename); diff --git a/src/common/pathutil.c b/src/common/pathutil.c index acfea84ec..157e54964 100644 --- a/src/common/pathutil.c +++ b/src/common/pathutil.c @@ -3,17 +3,18 @@ #if defined(_WIN32) # include +# include # include "xmalloc.h" #endif #if defined(_WIN32) -char *FindAbsolutePath (const char *Path) +char *FindRealPath (const char *Path) /* -** Determines the absolute path of the given relative path. +** Determines the real path the given relative path of an existing file. ** If the path points to a symlink, resolves such symlink. -** The absolute path for the file is stored in a malloced buffer. -** Returns NULL if some error occured. +** The real path for the file is stored in a malloced buffer. +** Returns NULL if the file doesn't exist. ** The returned path's separator is system specific. */ { diff --git a/src/common/pathutil.h b/src/common/pathutil.h index 50875330e..e86a9c1a0 100644 --- a/src/common/pathutil.h +++ b/src/common/pathutil.h @@ -41,12 +41,12 @@ /*****************************************************************************/ -char *FindAbsolutePath (const char *path); +char *FindRealPath (const char *path); /* -** Determines the absolute path of the given relative path. +** Determines the real path the given relative path of an existing file. ** If the path points to a symlink, resolves such symlink. -** The absolute path for the file is stored in a malloced buffer. -** Returns NULL if some error occured. +** The real path for the file is stored in a malloced buffer. +** Returns NULL if the file doesn't exist. ** The returned path's separator is system specific. */