[ovs-dev] Windows: Report absolute file name
diff mbox

Message ID CAM_3v9LW1249FsSk_knFDa56boXJ45L17PneyXmp9ANYtezgwA@mail.gmail.com
State Not Applicable
Headers show

Commit Message

Gurucharan Shetty Aug. 12, 2016, 4:58 p.m. UTC
On 12 August 2016 at 00:39, Alin Serdean <aserdean@cloudbasesolutions.com>
wrote:

> On Windows if a file path contains ":" we can safely say it is an absolute
> file name.
>
> This patch allows file_name checks to report correctly when using
> "abs_file_name".
>
> Found by testing.
>
> Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
>

I will add the following incremental before committing.

> ---
>  lib/util.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/lib/util.c b/lib/util.c
> index 241a7f1..689a9de 100644
> --- a/lib/util.c
> +++ b/lib/util.c
> @@ -926,6 +926,10 @@ abs_file_name(const char *dir, const char *file_name)
>  {
>      if (file_name[0] == '/') {
>          return xstrdup(file_name);
> +#ifdef _WIN32
> +    } else if (strchr(file_name, ':')) {
> +        return xstrdup(file_name);
> +#endif
>      } else if (dir && dir[0]) {
>          char *separator = dir[strlen(dir) - 1] == '/' ? "" : "/";
>          return xasprintf("%s%s%s", dir, separator, file_name);
> --
> 2.9.2.windows.1
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
>

Patch
diff mbox

diff --git a/lib/util.c b/lib/util.c
index 689a9de..21f0661 100644
--- a/lib/util.c
+++ b/lib/util.c
@@ -920,6 +920,9 @@  base_name(const char *file_name)
  * which itself must be absolute.  'dir' may be null or the empty string,
in
  * which case the current working directory is used.
  *
+ * Additionally on Windows, if 'file_name' has a ':', returns a copy of
+ * 'file_name'
+ *
  * Returns a null pointer if 'dir' is null and getcwd() fails. */