2013-11-22 3 views
0

누군가 여기서 내게 무슨 일이 일어 났는지 설명 할 수 있습니까? 아래 코드는 Android에서 완벽하게 작동하지만 블랙 베리 10에서는 작동하지 않습니다.codeova2.9와 webworks를 사용하여 blackberry10에서 디렉토리 경로를 반복적으로 생성

배열의 처음 두 디렉토리 구조에 대해서는 parentDir.getDirectory()가 호출되는 것을 볼 수는 없지만 배열의 마지막 경로 "dir/3/dir6")이 blackberry.io.home 폴더의 "parentFolder"폴더에 성공적으로 만들어집니다.

var dirList; 

// Wait for device API libraries to load 
// 
document.addEventListener("deviceready", onDeviceReady, false); 



// device APIs are available 
// 
function onDeviceReady() { 
    alert("device ready"); 
    blackberry.io.sandbox = false; 
    dirList = ["dir1/dir4/", "dir2/dir5/", "dir3/dir6/"]; 
    getFileSystem(); 
} 

function getFileSystem(){ 
    window.requestFileSystem(
      LocalFileSystem.PERSISTENT, 0, 
      function onFileSystemSuccess(fileSystem) 
      { 
       console.log("Success getting filesystem !!!"); 
       createDirectoryRecursive(fileSystem); 
      }, 
      function(error){ 
       console.log("Failed to get the filesystem !!!!!"); 
      } 
     ); 

} 

function createDirectoryRecursive(fs){ 
    var i; 
    for(i = 0; i < dirList.length; i++){ 
     createDirs(fs.root, dirList[i], -1); 
    } 
} 

function createDirs(parentDir, filePath, index) 
{ 
    console.log("createDirs params ===> parentDir=" + parentDir.toURL() + " filePath=" + filePath + " index=" + index); 
    var arrDirs = filePath.split("/"); 
console.log("number of levels in path = " + arrDirs.length); 
    if (index >= (arrDirs.length - 1)) 
    { 
     console.log("Done with " + filePath); 
    } 
    else{ 
     var dirName = "parentFolder"; 

     if (index >= 0) 
     { 
      dirName = arrDirs[index]; 
      console.log("current dirName is " + dirName); 
     } 

     //if device is Blackberry, build up a full directory path as we are trying to install outside of sandbox 
    var path, dirToCreate = "" 
     if(device.platform == "blackberry10"){ 

      path = "parentFolder/"; 
      console.log("Paths ======> arrDirs = " + arrDirs + " index = " +index); 
      for (i = 0; i <= index; i++){ 
       path += arrDirs[i] + "/"; 
       console.log("path = " + path + " i = " + i + " index = " + index); 
      } 

      dirToCreate = blackberry.io.home + "/" + path; 
      dirToCreate = dirToCreate.substring(0, dirToCreate.length - 1); 
      console.log("Paths Trying to create " + dirToCreate); 
      dirName = dirToCreate; 
     } 

     parentDir.getDirectory(dirName, {create: true, exclusive: false}, 
           function (directoryEntry) { 
             console.log("getDirectory callback =======> created directory " + directoryEntry.fullPath); 
             console.log("getDirectory callback =======> Current arrdirs " + arrDirs); 
             createDirs(directoryEntry, filePath, index + 1); 
            }, 
            function (error) {console.log("Failed to get directory " + dirName + " Error code : " + error.code);}); 

    } 
} 

코드는 실제로 그러나 더 콜백 (성공 또는 실패)가 호출되지 않으며, 배열에있는 모든 디렉토리에 대한 코르도바의 DirectoryEntry.getDirectory 기능을 입력한다. 목록의 마지막 디렉토리 경로 만 처리되고 blackberry 장치에서 성공적으로 작성됩니다.

답변

0

저는 같은 문제에 직면 해 왔습니다. 그것의 가치는

window.webkitRequestFileSystem(window.PERSISTENT, 5*1024*1024, onSuccess, null); 

대신,이 시도 :

window.requestFileSystem (LocalFileSystem.PERSISTENT, 1024 * 5 * 1024, 널 (null)는 onSuccess);

getFileSystem()

내가 통해 발굴이 문서 발견했을 때 나는 더 많은 정보를 가지고 :

https://bbjam.blackberryconferences.net/asia2013/connect/fileDownload/session/52C12DB41EDB8F70FDF15253F02948B7/JAM847_BBJamAsia-JAM847.pdf가 잘하면 모두를 위해 작동합니다.