emscripten Humble Cloud interface
Edward Rudd
2014-10-14 4ee52ebe2f2059e012dfad4189d7bd1666a18f80
client/library/library_cloudfs.js
@@ -130,6 +130,30 @@
                return false;
            }
        },
        populateDirs: function(entries, f, toAbsolute) {
          if (f.path.indexOf('/') !== -1) {
            // we have folders.. stuff them in the list
            var parts = f.path.split('/'),
                prefix = '';
            // remove the "file" from the end
            parts.pop();
            // remove the empty directory from the beginning
            if (parts[0] == '') parts.shift();
            parts.forEach(function(e) {
              var p = prefix.length ? PATH.join2(prefix, e) : e,
                abs = toAbsolute(p);
              if (!(abs in entries)) {
                entries[abs] = {
                  path: p,
                  type: 'dir',
                  timestamp: f.timestamp
                };
              }
              prefix = p;
            });
          }
        },
        // Getting list of entities
        getLocalSet: function(mount, callback) {
            function isRealDir(p) {
@@ -203,28 +227,8 @@
            for(var k in data) {
              var f = data[k];
              if (f.path.indexOf('/') !== -1) {
                  // we have folders.. stuff them in the list
                  var parts = f.path.split('/'),
                      prefix = '';
                  // remove the "file" from the end
                  parts.pop();
                  // remove the empty directory from the beginning
                  if (parts[0] == '') parts.shift();
              CLOUDFS.populateDirs(entries, f, toAbsolute);
                  parts.forEach(function(e) {
                      var p = prefix.length ? PATH.join2(prefix, e) : e,
                          abs = toAbsolute(p);
                      if (!(abs in entries)) {
                          entries[abs] = {
                              path: p,
                              type: 'dir',
                              timestamp: f.timestamp
                          };
                      }
                      prefix = p;
                  });
              }
              var p = toAbsolute(f.path);
              entries[p] = {
                url: f.url,