Skip to content

Commit

Permalink
util/zippath.cpp: OSD_WINDOWS isn't a safe way to detect Windows targ…
Browse files Browse the repository at this point in the history
…et, and OSD_* macros must not be used outside libocore/libosd.
  • Loading branch information
cuavas committed Aug 26, 2021
1 parent 2e9297e commit bdbf452
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/lib/util/zippath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,17 @@ int is_path_separator(char c)

bool is_root(std::string_view path)
{
#if defined(OSD_WINDOWS)
#if defined(WIN32)
// FIXME: don't assume paths are DOS-like - UNC paths, \\?\ long path prefix, etc. complicate this

// skip drive letter
if (path.length() >= 2 && isalpha(path[0]) && (path[1] == ':'))
path.remove_prefix(2);

// skip path separators
return path.find_first_not_of(PATH_SEPARATOR) == std::string_view::npos;
#else
// FIXME: handle multiple successive path separators, current directory references, parent directory references
return (path.length() == 1) && (path[0] == '/');
#endif
}
Expand Down

0 comments on commit bdbf452

Please sign in to comment.