emscripten Humble Cloud interface
Edward Rudd
2014-08-20 498913b2cac212191f053acd45938002aed11b23
client/library/humble_cloud.js
@@ -63,23 +63,27 @@
                }
            };
            var check = FS.readdir(mount.mountpoint).filter(isRealDir).map(toAbsolute(mount.mountpoint));
            var check = FS.readdir(mount.mountpoint).filter(isRealDir);
            while (check.length) {
                var path = check.pop();
                var stat;
                var abs_path = PATH.join2(mount.mountpoint, path);
                try {
                    stat = FS.stat(path);
                    stat = FS.stat(abs_path);
                } catch (e) {
                    return callback(e);
                }
                if (FS.isDir(stat.mode)) {
                    check.push.apply(check, FS.readdir(path).filter(isRealDir).map(toAbsolute(path)));
                    check.push.apply(check, FS.readdir(abs_path).filter(isRealDir).map(toAbsolute(path)));
                }
                entries[path] = { timestamp: stat.mtime };
                entries[abs_path] = {
                    timestamp: stat.mtime,
                    path: path
                };
            }
            return callback(null, { type: 'local', entries: entries });
@@ -101,20 +105,26 @@
                  // remove the empty directory from the beginning
                  if (parts[0] == '') parts.shift();
                  var prefix = '';
                  parts.forEach(function(e) {
                      var p = toAbsolute(e);
                      if (!(p in entries)) {
                          entries[p] = {
                      var p = PATH.join2(prefix, e),
                          abs = toAbsolute(p);
                      if (!(abs in entries)) {
                          entries[abs] = {
                              path: p,
                              timestamp: timestamp
                          }
                          };
                      }
                      prefix = p;
                  })
              }
              entries[toAbsolute(f.path)] = {
              var p = toAbsolute(f.path);
              entries[p] = {
                url: (f.url.substr(0, 1) == '/') ? HUMBLE_CLOUD.remoteAPIEndpoint + f.url : f.url,
                path: f.path.trim('/'),
                timestamp: timestamp,
                size: f.size
              }
              };
            }
            return callback(null, { type: 'remote', entries: entries } );
          }, function(e) {