如何确定 JavaScript 中的操作系统路径分隔符? [英] How to determine the OS path separator in JavaScript?
问题描述
如何在 JavaScript 中判断运行脚本的操作系统中使用的路径分隔符是什么?
你总是可以使用/作为路径分隔符,即使在 Windows 上也是如此.
引自 http://bytes.com/forum/thread23123.html:><块引用>
所以,可以总结一下情况很简单:
自 DOS 2.0 以来的所有 DOS 服务和所有 Windows API 都接受任一转发斜线或反斜线.总是有.
标准命令外壳程序(CMD 或 COMMAND)都不会接受转发斜线.即使是cd ./tmp"示例上一篇文章中给出的失败.
How can I tell in JavaScript what path separator is used in the OS where the script is running?
Afair you can always use / as a path separator, even on Windows.
Quote from http://bytes.com/forum/thread23123.html:
So, the situation can be summed up rather simply:
All DOS services since DOS 2.0 and all Windows APIs accept either forward slash or backslash. Always have.
None of the standard command shells (CMD or COMMAND) will accept forward slashes. Even the "cd ./tmp" example given in a previous post fails.
这篇关于如何确定 JavaScript 中的操作系统路径分隔符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!