tools/isobuild/builder.js
//   directory rather than a file.
directory rather than a file.
directory rather than a file .
reserve(relPath, {directory} = {}) {
    if (relPath.slice(-1) === files.pathSep) {
      relPath = relPath.slice(0, -1);
    }
    const parts = relPath.split(files.pathSep);
    const partsSoFar = [];
    for (let i = 0; i < parts.length; i ++) {
      const part = parts[i];
      partsSoFar.push(part);
      const soFar = partsSoFar.join(files.pathSep);
      if (this.usedAsFile[soFar]) {
        throw new Error("Path reservation conflict: " + relPath);
      }
      const shouldBeDirectory = (i < parts.length - 1) || directory;
      if (shouldBeDirectory) {
        if (! (soFar in this.usedAsFile)) {
          let needToMkdir = true;
          if (soFar in this.previousUsedAsFile) {
            if (this.previousUsedAsFile[soFar]) {
              files.unlink(soFar);
            } else {
              needToMkdir = false;
            }
          }
          if (needToMkdir) {
            files.mkdir_p(files.pathJoin(this.buildPath, soFar), 0o755);
          }
          this.usedAsFile[soFar] = false;
        }
      } else {
        this.usedAsFile[soFar] = true;
      }
    }
    return files.pathJoin(this.buildPath, relPath);
  }
reserve ( relPath , { directory } = { } ) { if ( relPath . slice ( - 1 ) === files . pathSep ) { relPath = relPath . slice ( 0 , - 1 ) ; } const parts = relPath . split ( files . pathSep ) ; const partsSoFar = [ ] ; for ( let i = 0 ; i < parts . length ; i ++ ) { const part = parts [ i ] ; partsSoFar . push ( part ) ; const soFar = partsSoFar . join ( files . pathSep ) ; if ( this . usedAsFile [ soFar ] ) { throw new Error ( "Path reservation conflict: " + relPath ) ; } const shouldBeDirectory = ( i < parts . length - 1 ) || directory ; if ( shouldBeDirectory ) { if ( ! ( soFar in this . usedAsFile ) ) { let needToMkdir = true ; if ( soFar in this . previousUsedAsFile ) { if ( this . previousUsedAsFile [ soFar ] ) { files . unlink ( soFar ) ; } else { needToMkdir = false ; } } if ( needToMkdir ) { files . mkdir_p ( files . pathJoin ( this . buildPath , soFar ) , 0o755 ) ; } this . usedAsFile [ soFar ] = false ; } } else { this . usedAsFile [ soFar ] = true ; } } return files . pathJoin ( this . buildPath , relPath ) ; }
directory rather than a file.
directory rather than a file .
// Ensure no trailing slash // Return the path we reserved.