<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def build(self, *args, **kwargs):
 """Make directories and files of the `Flow`."""

        # Allocate here if not done yet!
        if not self.allocated: self.allocate()

        self.indir.makedirs()
        self.outdir.makedirs()
        self.tmpdir.makedirs()

        # Check the nodeid file in workdir
        nodeid_path = os.path.join(self.workdir, ".nodeid")

        if os.path.exists(nodeid_path):
            with open(nodeid_path, "rt") as fh:
                node_id = int(fh.read())

            if self.node_id != node_id:
                msg = ("\nFound node_id %s in file:\n\n  %s\n\nwhile the node_id of the present flow is %d.\n"
                       "This means that you are trying to build a new flow in a directory already used by another flow.\n"
                       "Possible solutions:\n"
                       "   1) Change the workdir of the new flow.\n"
                       "   2) remove the old directory either with `rm -r` or by calling the method flow.rmtree()\n"
                        % (node_id, nodeid_path, self.node_id))
                raise RuntimeError(msg)

        else:
            with open(nodeid_path, "wt") as fh:
                fh.write(str(self.node_id))

        if self.pyfile and os.path.isfile(self.pyfile):
            shutil.copy(self.pyfile, self.workdir)

        for work in self:
            work.build(*args, **kwargs)