javascript - Clear HTML5 Filesystem API - Stack Overflow

How does one pletely empty (or delete all files in) a filesystem?Is there no 1 line solution like local

How does one pletely empty (or delete all files in) a filesystem?

Is there no 1 line solution like localStorage (localStorage.clear())? Or am I missing something really, really obvious?

Apparently, I wasn't very clear. I'm referring to the HTML5 Filesystem API. /

How does one pletely empty (or delete all files in) a filesystem?

Is there no 1 line solution like localStorage (localStorage.clear())? Or am I missing something really, really obvious?

Apparently, I wasn't very clear. I'm referring to the HTML5 Filesystem API. http://www.html5rocks./en/tutorials/file/filesystem/

Share Improve this question edited Apr 14, 2012 at 22:17 J. Chase asked Apr 14, 2012 at 22:04 J. ChaseJ. Chase 1,4131 gold badge11 silver badges10 bronze badges 3
  • 1 I am asking if there's a simple way to clear the Filesystem API like you can with localStorage. – J. Chase Commented Apr 14, 2012 at 22:15
  • 4 Come on, this question is pretty clear. – Ry- Commented Apr 14, 2012 at 22:17
  • 1 @minitech: With the edit, it is. – T.J. Crowder Commented Apr 14, 2012 at 22:19
Add a ment  | 

4 Answers 4

Reset to default 7

2016 Update: The File API "Directories and System" effort has been abandoned and what little support had made it into browsers is being dropped. The original File API is still valid, but the stuff providing an entire file area on the user's system has been abandoned.


It looks like DirectoryEntry#removeRecursively does that. It says you can't remove the root of a file system, but you can loop through the entries in the root and remove them recursively (or just always work with a subdirectory of the root, thereby letting you remove that with a one-liner).

Not a one line solution but you can always go to

chrome://settings/cookies

and remove the file system from the origin of your choice

In bro-fs there is special fs.clear() method exactly for that.

fs.init()
  .then(() => fs.mkdir('dir'))
  .then(() => fs.writeFile('file.txt', 'hello world'))
  .then(() => fs.clear())

Storage, in the Web Storage specification, does have a clear method. Are you confusing the File API with the web storage API?

At the level of the individual file, there's the truncate method.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1743742656a4499431.html

相关推荐

  • javascript - Clear HTML5 Filesystem API - Stack Overflow

    How does one pletely empty (or delete all files in) a filesystem?Is there no 1 line solution like local

    6天前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信