What's a “canonical path”?

后端 未结 4 1042
青春惊慌失措
青春惊慌失措 2020-12-22 18:54

So, an absolute path it\'s a way to get to a certain file or location describing the full route to it, the full path, and it\'s OS dependent (the absolute paths for Windows

4条回答
  •  清歌不尽
    2020-12-22 19:40

    What a canonical path is (or its difference from an absolute path) is system dependent.
    Typically if a (full) path contains aliases, shortcuts or symbolic links the canonical path resolves all these into the actual directories they refer.
    Example: if /bin/a is a sym link, you can find it anywhere you request for an absolute path e.g. from java.io.File#getAbsolutePath while the real file (i.e. the actual target of the link) i.e. usr/local/bin/a would be return as a canonical path e.g. from java.io.File#getCanonicalPath

提交回复
热议问题