fileSystemRepresentation

fileSystemRepresentation

本文介绍了OS X-如何计算标准化文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在Windows和OS X上生成的文件名之间创建一个映射.我知道OS X "将所有文件名转换为分解后的Unicode",但是,"大多数卷格式均未遵循这些常规格式的确切规范"

I need to create a mapping between file names generated on Windows and OS X. I know that OS X "converts all file names to decomposed Unicode" however, "most volume formats do not follow the exact specification for these normal forms"

因此,使用标准UTF8 API将Windows名称转换为NFD并确保我具有正确的OS X名称似乎不是一件容易的事.有没有一种方法可以确定实际的OS X文件名,而无需在文件系统中实际创建文件,然后再扫描目录以查看实际创建的文件名?

So, it does not seem a simple matter of converting the Windows name to NFD using a standard UTF8 API and being sure I have the correct OS X name. Is there a way to determine what the actual OS X file name will be without actually creating the file in the file system and then scanning the directory to see what was actually created?

推荐答案

您可能正在寻找-[NSString fileSystemRepresentation]方法.

请注意,此任务没有通用的解决方案.有效的文件名取决于要保存的卷的文件系统.例如,并非每个对HFS +有效的文件名都对FAT32有效.

Note that there is no general solution for this task. What is a valid file name depends on filesystem of the volume you're saving on. Not every file name valid for HFS+ is valid for FAT32, for example.

对于Mac的标准"文件系统(当前为HFS +),fileSystemRepresentation应该提供您所需要的;对于其他文件系统,没有通用的方法.考虑一下不存在但将来会引入的那些,例如:)

For Mac's "standard" filesystem (currently HFS+), fileSystemRepresentation should give what you need; for other file systems, there is no general way. Think about ones that don't exist but will be introduced in the future, for example :)

这篇关于OS X-如何计算标准化文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 18:43