def saveInPlace(self):
        if self.readonly:
            raise IOError, "World is opened read only."

        self.checkSessionLock()

        for level in self.dimensions.itervalues():
            level.saveInPlace(True)

        dirtyChunkCount = 0
        for chunk in self._loadedChunkData.itervalues():
            cx, cz = chunk.chunkPosition
            if chunk.dirty:
                data = chunk.savedTagData()
                dirtyChunkCount += 1
                self.worldFolder.saveChunk(cx, cz, data)
                chunk.dirty = False

        for cx, cz in self.unsavedWorkFolder.listChunks():
            if (cx, cz) not in self._loadedChunkData:
                data = self.unsavedWorkFolder.readChunk(cx, cz)
                self.worldFolder.saveChunk(cx, cz, data)
                dirtyChunkCount += 1


        self.unsavedWorkFolder.closeRegions()
        shutil.rmtree(self.unsavedWorkFolder.filename, True)
        if not os.path.exists(self.unsavedWorkFolder.filename):
            os.mkdir(self.unsavedWorkFolder.filename)

        for path, tag in self.playerTagCache.iteritems():
            tag.save(path)

        self.playerTagCache.clear()

        self.root_tag.save(self.filename)
        log.info(u"Saved {0} chunks (dim {1})".format(dirtyChunkCount, self.dimNo))
dataset/ETHPy150Open mcedit/pymclevel/infiniteworld.py/MCInfdevOldLevel.saveInPlace/original