A file system that does not work with Ripple Emulator works with the device

Trying to get debugging and run it smoothly. Currently, I can test the FileSystem API by starting my device, but this is a painful process. I tried to configure the Chrome file system API using the code I found here on SO. I get a return to the file system (although it is not called "and fullPath =" / "). I get a request from Chrome that the application wants to save locally, and I accept it. But the creation of the directory is interrupted every time. Code for the device (only difference is a request for the local file system).

Any thoughts? I would really like you to be able to debug Ripple as a first step before moving on to the device.

// Chrome dev tools

// Request Quota (only for File System API)

navigator.webkitPersistentStorage.requestQuota(1024*1024, function(grantedBytes) {
window.webkitRequestFileSystem(PERSISTENT, grantedBytes, onFileSystemSuccess, onFileSystemFail); 
}, function(e) {
console.log('Error', e); 
});


// // Non-chrome (device): get local file system

// window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onFileSystemSuccess, onFileSystemFail);


function onFileSystemSuccess(fileSystem) {
    console.log(fileSystem.name);
    console.log(fileSystem.root.name);
    var storageDir = fileSystem.root
    console.log(storageDir, storageDir.fullPath);

    // Find or create new STL directory

    function getDirSuccess(dirEntry) {
        console.log("Directory Name: " + dirEntry.name);
        alert("Your files are stored in: " + dirEntry.name);


        // Find or create new templates file.
        //                    test file

          dirEntry.getFile("readme.txt", {create: true, exclusive: false}, gotFileEntry, fail);

          function gotFileEntry(fileEntry) {
              fileEntry.createWriter(gotFileWriter, fail);
          }

          function gotFileWriter(writer) {
              writer.onwriteend = function(evt) {
                  console.log("contents of file now 'some sample text'");
                  writer.truncate(11);
                  writer.onwriteend = function(evt) {
                      console.log("contents of file now 'some sample'");
                      writer.seek(4);
                      writer.write(" different text");
                      writer.onwriteend = function(evt){
                          console.log("contents of file now 'some different text'");
                      }
                  };
              };
              writer.write("some sample text");
              alert('wrote a text file');
          }

function fail(error) {
    console.log(error.code);
}
+4

Source: https://habr.com/ru/post/1529043/


All Articles