这是我使用的代码:
File.open("#{time.hour} : 00,#{time.month}-#{time.day}-#{time.year}","a") do |mFile| mFile.syswrite("#{pKey} - #{tKey}: \n") mFile.syswrite("Items closed: #{itemsClosed} | Total items: #{totalItems} | Percent closed: % #{pClosed} \n") mFile.syswrite("\n") mFile.close end
这是输出(假设时间是1pm):
13 / 00,11-8-2012
13:00,11-8-2012
解决方法
编辑:经过更多的搜索,this USENIX paper描述了发生了什么.他们明显使用的规则是:
Another obvIoUs problem is the different path separators between HFS+ (colon,‘:’) and UFS (slash,‘/’). This also means that HFS+ file names may contain the slash character and not colons,while the opposite is true for UFS file names. This was easy to address,though it involves transforming strings back and forth. The HFS+ implementation in the kernel’s VFS layer converts colon to slash and vice versa when reading from and writing to the on-disk format. So on disk the separator is a colon,but at the VFS layer (and therefore anything above it and the kernel,such as libc) it’s a slash. However,the Traditional Mac OS toolkits expect colons,so above the BSD layer,the core Carbon toolkit does yet another translation. The result is that Carbon applications see colons,and everyone else sees slashes. This can create a user-visible schizophrenia in the rare cases of file names containing colon characters,which appear to Carbon applications as slash characters,but to BSD programs and Cocoa applications as colons.
原文地址:https://www.jb51.cc/ruby/273970.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。