[llvm-commits] [llvm] r138213 - /llvm/trunk/lib/Support/Windows/PathV2.inc

NAKAMURA Takumi geek4civic at gmail.com
Sun Aug 21 07:09:28 PDT 2011


Aaron, thanks to submit it!

> +static bool isReservedName(StringRef path) {
> +  // This list of reserved names comes from MSDN, at:
> +  // http://msdn.microsoft.com/en-us/library/aa365247%28v=vs.85%29.aspx
> +  static const char *sReservedNames[] = { "nul", "con", "prn", "aux",
> +                              "com1", "com2", "com3", "com4", "com5", "com6",
> +                              "com7", "com8", "com9", "lpt1", "lpt2", "lpt3",
> +                              "lpt4", "lpt5", "lpt6", "lpt7", "lpt8", "lpt9" };

nitpick: I prefer;
static const char sReservedNames[][5] = {...};
(Yes, I know it is nitpick!)

> +  // First, check to see if this is a device namespace, which always
> +  // starts with \\.\, since device namespaces are not legal file paths.
> +  if (path.startswith("\\\\.\\"))
> +    return true;

I am not sure, though, I am dubious "\\.\" would be handled here
and other methods in PathV2 would be aware of "\\.\".

> +  // Then compare against the list of ancient reserved names
> +  for (size_t i = 0; i < sizeof(sReservedNames) / sizeof(const char *); ++i) {
> +    if (path.equals_lower(sReservedNames[i]))
> +      return true;
> +  }

Nitpick: Shall we handle "x:\path\to\com9.txt" here?

...Takumi




More information about the llvm-commits mailing list