FileSystemDirectoryEntry.removeRecursively() - Web APIs 编辑

Obsolete

This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.

Experimental

This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The FileSystemDirectoryEntry interface's method removeRecursively() removes the directory as well as all of its content, hierarchically iterating over its entire subtree of descendant files and directories.

To remove a single file, or an empty directory, you can also use FileSystemEntry.remove().

Syntax

FileSystemDirectoryEntry.removeRecursively(successCallback[, errorCallback]);

Parameters

successCallback
A function to call once the directory removal process has completed. The callback has no parameters.
errorCallback Optional
A function to be called if an error occurs while attempting to remove the directory subtree. Receives a FileError describing the error which occurred as input.

Return value

undefined.

Errors

If an error occurs and an errorCallback was specified, it gets called with a single parameter: a FileError object describing the error. The FileError.code specifies what type of error occurred, as follows:

FileError.INVALID_MODIFICATION_ERR
An attempt was made to remove the root directory; this is not permitted.
FileError.NO_MODIFICATION_ALLOWED_ERR
The file system's state doesn't permit modification.
FileError.NOT_FOUND_ERR
The directory represented by the FileSystemDirectoryEntry no longer exists.
FileError.NOT_READABLE_ERR
The directory is not accessible; perhaps it's in use by another application or is locked at the operating system level.
FileError.SECURITY_ERR
The directory could not be removed for security reasons. Possible reasons include:
  • The directory and/or its contents may not be safe to access from a Web application.
  • Too many file system calls are being made.
  • Other security concerns as raised by the user agent or the operating system.

If you try to delete a directory which contains one or more files that can't be removed, or if an error occurs while deletion of a number of files is underway, some files may not be deleted. You should provide an errorCallback to watch for and handle this, perhaps by trying again.

Example

directory.removeRecursively(function() {
  /* The directory was removed successfully */
}, function() {
  /* an error occurred while removing the directory */
});

Browser compatibility

BCD tables only load in the browser

See also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:93 次

字数:4990

最后编辑:7年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文