V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
css3
V2EX  ›  程序员

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

  •  
  •   css3 · 2022-04-29 21:17:23 +08:00 · 1752 次点击
    这是一个创建于 721 天前的主题,其中的信息可能已经有所发展或是发生改变。

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

    5 条回复    2022-04-30 07:34:27 +08:00
    yuzo555
        1
    yuzo555  
       2022-04-29 21:22:44 +08:00
    设备名称,类似的有 nul 、aux 、prn 、com1 、com2
    learningman
        2
    learningman  
       2022-04-29 21:23:18 +08:00
    con 在 Windows 上是 console 设备的名字
    但是 con.py 应该是没问题的吧。。。
    yzwduck
        3
    yzwduck  
       2022-04-29 21:43:08 +08:00   ❤️ 1
    @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
        4
    learningman  
       2022-04-29 21:45:38 +08:00
    @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
        5
    MiketsuSmasher  
       2022-04-30 07:34:27 +08:00
    不错,Windows 真够屎山
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   944 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 93ms · UTC 20:24 · PVG 04:24 · LAX 13:24 · JFK 16:24
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.