获取DirectoryEntry的完整路径 [英] Getting the full path of a DirectoryEntry
问题描述
有人知道如何在Chrome Packaged应用程序中获取 DirectoryEntry
对象的完整路径,无需任何折叠或其他快捷方式吗?
我在撰写谷歌浏览器打包应用程序。我的应用程序有一个按钮,用户可以使用 chrome.fileSystem API选择目录。当目录选择回到我的应用程序时,它由 DirectoryEntry
对象表示,该对象在 File API 。该对象在控制台中看起来像这样:
$ $ $ $ $ c $ DirectoryEntry {
filesystem:DOMFileSystem
fullPath:/ to_read
isDirectory:true
isFile:false
name:to_read
__proto__:DirectoryEntry
}
我使用的是Windows,目录的完整路径是
C:\ Users \David\Desktop\to_read
我想要一个函数那可以返回那条路径或其他东西。不幸的是,我发现的最接近的东西是 chrome.fileSystem.getDisplayPath
,但返回以下内容:
〜\Desktop\to_read
来自 getDisplayPath
的返回值对于因为我想获得目录的全名(包括驱动器),所以我可以将它与其他完整目录路径进行比较。
我试过调用 toURL()
放在 DirectoryEntry
中,并返回一个空字符串。
关于我的项目:我想以Chrome Packaged App的身份编写iTunes资料库同步器。 iTunes资料库XML文件包含完整路径,如 file:// localhost / D:/David/Music/Bob/Bob%20Album/01%20Bob.mp3
。用户将给我的应用程序访问他的音乐文件夹,我希望能够告诉他是否允许我访问正确的文件夹。
https://code.google.com/p/chromium/issues/detail?id = 322952
Does anyone know how to get the full path of a DirectoryEntry
object in a Chrome Packaged App, without any tildes or other shortcuts?
I am writing a Google Chrome Packaged App. My app has a button where a user can choose a directory using chrome.fileSystem API. When the directory choice comes back to my app, it is represented by a DirectoryEntry
object, which is defined in the File API. The object looks like this in the console:
DirectoryEntry {
filesystem: DOMFileSystem
fullPath: "/to_read"
isDirectory: true
isFile: false
name: "to_read"
__proto__: DirectoryEntry
}
I am using Windows and the full path of the directory is
C:\Users\David\Desktop\to_read
I would like a function that can return that path or something close. Unfortunately, the closest thing I found is chrome.fileSystem.getDisplayPath
, but that returns the following:
~\Desktop\to_read
The return value from getDisplayPath
is not useful to me, because I want to get the full name of the directory (including the drive) so I can compare it to some other full directory paths I have.
I tried calling toURL()
on the DirectoryEntry
and it returned an empty string.
A bit about my project: I want to write an iTunes library synchronizer as a Chrome Packaged App. The iTunes library XML file contains full paths like file://localhost/D:/David/Music/Bob/Bob%20Album/01%20Bob.mp3
. The user will give my app access to his music folders, and I want to be able to tell if he gave me access to the right folders.
This is currently (2014-01-10) not a feature of Chrome, but I have suggested it and they are working on it:
https://code.google.com/p/chromium/issues/detail?id=322952
这篇关于获取DirectoryEntry的完整路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!