0

I'm trying to come up with a conclusive list of rules of what is illegal in naming conventions for OSes that can run node.js.

So far from reading many resources and similar questions on the internet this is what I found:
illegal characters anywhere in the name:

  1. windows_nt - /?<>\,:*|"
  2. Linux - /
  3. Darwin - / and maybe : ? (some say it's allowed on OS X but some says it's not, not really clear to me)

illegal names:

  1. windows_nt - CON, PRN, AUX, CLOCK$, NUL, COM1-9, LPT1-9 (some other device names were not included because they're illegal only on old dos distributions and node.js is not available for them)

  2. Linux -

  3. Darwin -

illegal trailing characters:

  1. windows_nt - . (dot) and (space)

  2. Linux -

  3. Darwin -

illegal leading characters:

  1. windows_nt -

  2. Linux -

  3. Darwin -

max file/dir name length:

  1. windows_nt -

  2. Linux -

  3. Darwin -

max path length:

  1. windows_nt -

  2. Linux -

  3. Darwin -

I would be glad if you could help me fill the gaps here of the rules set. Also, only OSes capable of running node.js should be taken into account.

Jorayen
  • 1,737
  • 2
  • 21
  • 52
  • Possible duplicate of [What characters are forbidden in Windows and Linux directory names?](http://stackoverflow.com/questions/1976007/what-characters-are-forbidden-in-windows-and-linux-directory-names) – sashoalm Apr 08 '16 at 09:15
  • @sashoalm Not really, I've already encountered this post and it's only talking about forbidden characters in names for Linux and Windows. If you read my post you'll see I've already filled those up, and I'm missing much more information not present in the mentioned question. – Jorayen Apr 08 '16 at 10:35
  • Surely it depends not only on the OS, but on the filesystem as well? – Biffen Apr 08 '16 at 12:53
  • @Biffen Yes I guess it does, but if I'm not wrong only some OSes are capable of running node.js and some of these distributions are coming with only certain filesystems. – Jorayen Apr 08 '16 at 13:11
  • @Jorayen Yeah, but even if you limit yourself to officially supported OSs and their officially supported filesystems, the list would be quite long. – Biffen Apr 08 '16 at 13:13
  • …I'm not sure what the actual problem you're trying to solve is, but if you want to create files at runtime and avoid illegal names while not losing information, URL-encoding might take care of the majority of issues. A common pre- or suffix might solve a lot of the remaining ones. – Biffen Apr 08 '16 at 13:15
  • @Biffen You've guessed it right pretty much. Unfortunately URL-encoding was not enough. While it helped significantly, I've done a-lot of testing and it wasn't sufficient. Also, I decided to make a separate module to handle this normalization of names/paths of file-systems, so I don't want pre- or suffix, not to compel my self on users with these. – Jorayen Apr 08 '16 at 17:16

1 Answers1

0

Darwin - / and maybe : ? (some say it's allowed on OS X but some says it's not, not really clear to me)

: and ? are valid in a filename in macOS. If you use the command line or API functions, you can create filenames with either character.

Finder (the file management GUI) will not allow you to use : in a filename/directory name, but it will allow you to use /. This is because it actually uses : in the filename, but displays that character as /.

$ ls -l
total 0
drwxr-xr-x  2 user  staff  64  6 Apr 21:40 abc:123

Finder window

illegal names:

. and .. come to mind on both Linux and macOS.

max file/dir name length:

On macOS on APFS (the default filesystem), the maximum length of an individual directory or filename seems to be 255. However the complete path can be much longer than that.

craig65535
  • 3,439
  • 1
  • 23
  • 49