- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
到目前为止,我假设 Windows 不允许所有在命令行中有意义的特殊字符。但是,完全有可能有一个名为“file%sometext%”的文件
如果在批处理脚本或类似命令中调用此文件名,空变量 %sometext% 将被扩展为空,文件名将被解析为"file"。
是否有任何其他合法文件名可能会以这种方式在批处理脚本中引起问题?
最佳答案
Windows NT 是一个运行其他操作系统的操作系统。无论操作系统执行文件操作有什么规则,都是适用的规则。
这些是 Windows 的规则。 Unix 程序将遵循 Unix 的规则。可以在 Unix 中创建无法在 Windows 中打开的文件,反之亦然。
File Name Conventions
Although each file system can have specific rules about the formation of individual components in a directory or file name, all file systems follow the same general conventions: a base file name and an optional extension, separated by a period. For example, the MS-DOS FAT file system supports 8 characters for the base file name and 3 characters for the extension. This is known as an 8.3 file name. The FAT file system and NTFS support file names that can be up to 255 characters long. This is known as a long file name. To get an MS-DOS file name given a long file name, use the GetShortPathName function. To get the full path of a file, use the GetFullPathName function.
Both file systems use the backslash (\) character to separate directory names and the file name when forming a path.
General rules for applications creating names for directories and files or processing names supplied by the user include the following:
Use any character in the current code page for a name, but do not use a path separator, a character in the range 0 through 31, or any character explicitly disallowed by the file system. A name can contain characters in the extended character set (128–255).
Use the backslash (\), the forward slash (/), or both to separate components in a path. No other character is acceptable as a path separator. Note that UNC names must adhere to the following format: \\server\share. Use a period (.) as a directory component in a path to represent the current directory.
Use two consecutive periods (..) as a directory component in a path to represent the parent of the current directory. Use a period (.) to separate the base file name from the extension in a directory name or file name.
Do not use the following characters in directory names or file names, because they are reserved:
< > : " / \ |
Do not use device names, such as aux, con, lpt1, and prn, as file names or directory names.
Process a path as a null-terminated string. The maximum length for a path, including a trailing backslash, is given by MAX_PATH. The Unicode versions of several functions permit paths that exceed the MAX_PATH length if the path has the "\\?\" prefix. The "\\?\" tells the function to turn off path parsing. However, each component in the path cannot be more than MAX_PATH characters long. Use the "\\?\" prefix with paths for local storage devices and the "\\?\UNC\" prefix with paths having the Universal Naming Convention (UNC) format. The "\\?\" is ignored as part of the path. For example, "\\?\C:\myworld\private" is seen as "C:\myworld\private", and "\\?\UNC\bill_g_1\hotstuff\coolapps" is seen as "\\bill_g_1\hotstuff\coolapps".
Do not assume case sensitivity. Consider names such as OSCAR, Oscar, and oscar to be the same.
The following reserved words cannot be used as the name of a file: CON, PRN, AUX, CLOCK$, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and LPT9. Also, reserved words followed by an extension—for example, NUL.tx7—are invalid file names.
By following the rules listed in this section, an application can create valid names for files and directories regardless of the file system in use.
Backslashes (\) are used as element dividers in paths (dividing the file name from the path to it, or directories from one another in a path). You cannot use them in file or directory names. They may be required as part of volume names (for example, "C:\").
Platform SDK Release: August 2001
关于Windows 命令行和批处理文件 : potential problems with unescaped special characters in filenames?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40082508/
我有名为 xxx.java.i、xxx.java.d、xxx.jar.i 的文件。我知道这些文件与 Java 有某种关系。这个扩展是什么意思以及它的用途是什么?它与 .class 扩展名的类型相同吗?
我的命名尽量在语法上正确*。我一直使用 filename 而不是 fileName。 java 约定似乎也使用这个,但 FxCop 更喜欢 fileName。 有一个discussion on Wik
来自MISRA-C 2004 : 19.3 (req): The '#include' directive shall be followed by either a or "filename" s
我有一个 SKScene 类,我需要在其中实现一个自定义初始化程序来覆盖 SKScene 父类(super class) SKNode 的初始化程序 init(fileNamed: fileNamed
在 C 和 C++ 编程语言中,在 include 中使用尖括号和使用引号有什么区别?声明,如下? #include #include "filename" 最佳答案 实际上,区别在于预处理器搜索包
我想解压一个文件,例如使用 shell 命令将“tar123.tar.gz”复制到目录/myunzip/tar123/”。 tar -xf tar123.tar.gz 将解压缩文件,但在与我工作的目录
我是 C 语言新手,我知道这两个命令都完成相同的任务,但是其中一个命令是否会执行与另一个命令不同的操作? 最佳答案 首先,如果您使用 make,那么对于 hello.c,您将调用 make 作为 ma
我正在编写一个程序,它将文件名列表存储为字符串数组。当我将其声明为 char *filenames[1] 我没有错误......但是当我这样做时 char *filenames 我遇到了一些错误。不在
我在将 Appirater 集成到我的应用程序时遇到了一些问题。我已经正确添加了所有必要的文件,并拥有正确的代码(我认为),但是在尝试将其实现到我的 AppDelegate.m 文件中时出现错误。当我
在 include 中使用尖括号和引号有什么区别?指令? #include <filename> #include "filename"
我目前正在寻找一种批量获取变量并仅解析文件名的方法。 例如,我将来自另一个应用程序的 -s 参数传递给我的批处理文件,该参数随后被设置为我的源变量。源文件变量通常包含如下内容:C:\Program F
在 GNU Makefile(在 Ubuntu Linux 系统上)中,如何删除列表中每个文件名的文件名后缀,以便在第一个点处截断文件名? 假设我有 NAMES = file1.a.b.c file2
我正在尝试从源代码安装rtorrent,但是在编译时出现错误。我正在使用新的Ubuntu 20.04 VM。 libtorrent安装 sudo apt update sudo apt upgrade
在 GNU Makefile(在 Ubuntu Linux 系统上)中,如何删除列表中每个文件名的文件名后缀,以便在第一个点处截断文件名? 假设我有 NAMES = file1.a.b.c file2
1-intro-to deepleanring and computer visionk.MKV 2.Kaggle Deep Learning - YouTube.MP4 Convolutional
我希望 gvim 始终在单独的窗口中打开并立即返回命令提示符。换句话说我想要 gvim filename 与相同 gvim filename & 看来我应该可以用别名来做到这一点。别名是否有特殊的通配
以下代码发送一个 GET 请求,该请求的响应应该在客户端 (Chrome) 上启动文件下载过程。 $.ajax({ type: "GET", traditional: true, asyn
我有一堆 filename.bz2.gz 的文件,我想将其转换为 filename.gz。 有什么帮助吗? 谢谢 最佳答案 有了您的文件名*.bz2.gz,我假设该文件是使用以下压缩顺序创建的: ec
这个问题在这里已经有了答案: 关闭 11 年前。 Possible Duplicate: Reference - What does this symbol mean in PHP? 我正在制作一个
如何合并 abc.mp4.tmp 与实际 交换文件abc.mp4 文件。我试图使用 Wowza Media server 3.6 录制现场事件,但录制的文件在最后一刻没有正确混合。 abc.mp4.t
我是一名优秀的程序员,十分优秀!