Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Cordova-文件系统-为什么有这么多路径选择?_Cordova_Html5 Filesystem_Cordova Plugins - Fatal编程技术网

Cordova-文件系统-为什么有这么多路径选择?

Cordova-文件系统-为什么有这么多路径选择?,cordova,html5-filesystem,cordova-plugins,Cordova,Html5 Filesystem,Cordova Plugins,我正在浏览Cordova源代码,试图找出一些问题,目前有六种方法/属性可用于访问文件路径 目前(使用iOS运行),有: // Properties file.fullPath; // file:///full/path/syntax/file file.nativeURL; // file:///full/path/syntax/file // Method(s) file.toInternalURL(); // formats the file.fullPath into a cdvfile

我正在浏览Cordova源代码,试图找出一些问题,目前有六种方法/属性可用于访问文件路径

目前(使用iOS运行),有:

// Properties
file.fullPath; // file:///full/path/syntax/file
file.nativeURL; // file:///full/path/syntax/file

// Method(s)
file.toInternalURL(); // formats the file.fullPath into a cdvfile://localhost/persisten/file.
file.toURL(); // if file.nativeURL is set, uses file.nativeURL, otherwise use file.toInternalURL() or file.fullPath.

// Deprecated method(s)
file.toURI(); // deprecated - calls file.toURL();
file.toNativeURL() // deprecated - calls file.toURL();
我知道有两种方法不推荐使用,它们都指向
file.toURL()
,所以我可以忽略它们,只关注四种方法

但是
file.fullPath
file.nativeURL
之间的区别是什么?它们完全相同?它们都是文件对象上的属性-都可以公开访问

据我所知,
file.toURL()
使用这两种方法-首先
file.nativeURL
如果不是这样,那么
file.toInternalURL()
或者失败,然后
file.fullPath

最后,
file.toNativeURL()
返回一个
cdvfile://
格式化的位置

因此,大多数方法都指向
file.nativeURL
属性。
file.toURL()
是用来处理所有实例的方法吗?如果是这样,那么到底什么是
cdvfile://


谢谢

文件。fullPath
是规范的一部分,实际上应该是:
/path/relative/to/my/root
。如果您看到它有
文件://
,那么这就是一个bug

file.nativeURL
是一个实现细节。但可悲的是,它并没有明显的标记。它不是规范的一部分,在其他平台上也不存在

file.tour()
很可能就是您想要的。它是规范的一部分,为您提供了一个可以传递到
resolveLocalFileSystemURL
的URL,与
cdvfile:
URL相比,它具有更少的访问权限


file.toInternalURL()
不是规范的一部分,但它是特定于Cordova的扩展名。我不认为它会是一个有用的东西。

谢谢Andrew——在写这篇文章时,我使用的是Cordova 3.3.0;我目前还没有升级,但我会升级,并确认iOS是否仍然如此。