chrome filesystem - 重命名目录

时间:2015-09-16 17:28:10

标签: javascript google-chrome html5-filesystem

在新的chrome文件系统api中,如何重命名目录?

目录本身的

moveTo()似乎不起作用,我不想迭代目录中的所有文件。

有一种简单的方法可以重命名吗? 谢谢!

1 个答案:

答案 0 :(得分:0)

这对我有用,你能否提供一些关于你遇到的错误的更多信息?

我们直接从条目中获取父级,只需将具有新名称的文件夹放在同一父级下。

请注意,如果新名称与旧名称相同,即使您更改了名称中的大写,也会失败,并且会出现无效修改错误。

var test = function( entry, new_name ){
    entry.getParent( function( parent ){
        entry.moveTo( parent , new_name, function( new_node ){
            console.log( new_node )
            console.log( "Succes creating the new node" ) //We were able to rename the node
        }, function( error ){
            console.error( error )
            console.error( "Something wrong when finding the parent" )
        })
    }, function( error ){
        console.error( error )
        console.error( "Something wrong when finding the parent" )
    })
}

test( entry, "For the watch" )