diff mbox

[ovs-dev] Windows: Report absolute file name

Message ID 20160812073848.8444-1-aserdean@cloudbasesolutions.com
State Accepted
Headers show

Commit Message

Alin Serdean Aug. 12, 2016, 7:39 a.m. UTC
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>
---
 lib/util.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Joe Stringer Aug. 12, 2016, 5:27 p.m. UTC | #1
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>

Out of curiousity, how does this interact with NTFS alternate data streams?

http://latkin.org/blog/2016/07/20/git-for-windows-accidentally-creates-ntfs-alternate-data-streams/
diff mbox

Patch

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);