Example #1
0
DomFileSystem.prototype.list = function(path) {
  if (!this.isValidPath_(path))
    return Promise.reject(new AxiomError.Invalid('path', path.originalSpec));

  return domfsUtil.listDirectory(this.fileSystem.root,
      domfsUtil.makeDomfsPath(path)).then(function(entries) {
    return Promise.resolve(entries);
  });
};
Example #2
0
DomFileSystem.prototype.stat = function(path) {
  if (!this.isValidPath_(path))
    return Promise.reject(new AxiomError.Invalid('path', path.originalSpec));

  return domfsUtil.getFileOrDirectory(this.fileSystem.root,
      domfsUtil.makeDomfsPath(path)).then(function(r) {
    return domfsUtil.statEntry(r);
  });
};
Example #3
0
  return new Promise(function(resolve, reject) {
    var parentPath = path.getParentPath();
    var targetName = path.getBaseName();

    var onDirectoryFound = function(dir) {
      return domfsUtil.remove(dir, targetName).then(function(r) {
        return resolve(r);
      }).catch (function(e) {
        return reject(e);
      });
    };

    var onFileError =
        domfsUtil.rejectFileError.bind(null, path.relSpec, reject);

    this.fileSystem.root.getDirectory(domfsUtil.makeDomfsPath(parentPath),
        {create: false}, onDirectoryFound, onFileError);
  }.bind(this));
Example #4
0
    return new Promise(function(resolve, reject) {
      var onFileError = this.onFileError_.bind(null, reject);
      var onStat = function(stat) {
        this.entry_.file(function(f) {
            this.file_ = f;
            this.ready();
            return resolve();
        }.bind(this), onFileError);
      }.bind(this);

      var onFileFound = function(entry) {
        this.entry_ = entry;
        if (this.mode.write && this.mode.truncate) {
          this.entry_.createWriter(
              function(writer) {
                writer.truncate(0);
                domfsUtil.statEntry(entry).then(onStat).catch(onFileError);
              },
              reject);
          return;
        }

        domfsUtil.statEntry(entry).then(function(value) {
          onStat(value);
        }).catch(function(e) {
          reject(e);
        });
      }.bind(this);

      this.fileSystem.fileSystem.root.getFile(
          domfsUtil.makeDomfsPath(this.path),
          {create: this.mode.create,
           exclusive: this.mode.exclusive
          },
          onFileFound, onFileError);
    }.bind(this));
Example #5
0
 return new Promise(function(resolve, reject) {
   domfs.root.getFile(domfsUtil.makeDomfsPath(path), {create: true},
       resolve, reject);
 });