• 请不要在回答技术问题时复制粘贴 AI 生成的内容
css3
V2EX  ›  程序员

con.py 这个文件是有特殊含义吗?

  •  
  •   css3 · Apr 29, 2022 · 2842 views
    This topic created in 1653 days ago, the information mentioned may be changed or developed.

    linux服务器上随便手了一个con.py文件, 编写完,准备从windows上scp 过来, 发现竟然死活无法发送::/code/con.py: truncate: No error , 又尝试从xftp直接从远程拉,也直接显示错误, 然后把名称改了,竟然能正常发送了, 这是为啥,太好奇了

    5 replies  •  2022-04-30 07:34:27 +08:00
    yuzo555
    yuzo555
    Apr 29, 2022
    1
    设备名称,类似的有 nul 、aux 、prn 、com1 、com2
    learningman
    learningman
    Apr 29, 2022
    2
    con 在 Windows 上是 console 设备的名字
    但是 con.py 应该是没问题的吧。。。
    yzwduck
    yzwduck
    Apr 29, 2022❤️1
    3
    @learningman CON.PY 也一样会有兼容性问题,除非加上 \\?\ 前缀。
    文档 https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file

    Old New Things 写过一篇解释 "What's the deal with those reserved filenames like NUL and CON?"
    https://devblogs.microsoft.com/oldnewthing/20031022-00/?p=42073
    learningman
    learningman
    Apr 29, 2022
    4
    @yzwduck 看到了
    Because it turns off automatic expansion of the path string, the "\\?\" prefix also allows the use of ".." and "." in the path names, which can be useful if you are attempting to perform operations on a file with these otherwise reserved relative path specifiers as part of the fully qualified path.

    Many but not all file I/O APIs support "\\?\"; you should look at the reference topic for each API to be sure.

    Note that Unicode APIs should be used to make sure the "\\?\" prefix allows you to exceed the MAX_PATH
    MiketsuSmasher
    MiketsuSmasher
    Apr 30, 2022
    5
    不错,Windows 真够屎山
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1428 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 10:24 · PVG 18:24 · LAX 02:24 · JFK 05:24
    ♥ Do have faith in what you're doing.