code: def _add_raster_layer(self, raster_layer, layer_name, save_style=False):
          
          if not self.is_writable():
              return False, 'The destination is not writable.'
  
          output = QFileInfo(self.uri.filePath(layer_name + '.tif'))
  
          source = QFileInfo(raster_layer.source())
          if source.exists() and source.suffix() in ['tiff', 'tif']:
              # If it's tiff file based.
              QFile.copy(source.absoluteFilePath(), output.absoluteFilePath())
  
          else:
              # If it's not file based.
              renderer = raster_layer.renderer()
              provider = raster_layer.dataProvider()
              crs = raster_layer.crs()
  
              pipe = QgsRasterPipe()
              pipe.set(provider.clone())
              pipe.set(renderer.clone())
  
              file_writer = QgsRasterFileWriter(output.absoluteFilePath())
              file_writer.Mode(1)
  
              file_writer.writeRaster(
                  pipe,
                  provider.xSize(),
                  provider.ySize(),
                  provider.extent(),
                  crs)
  
              del file_writer
  
          if save_style:
              style_path = QFileInfo(self.uri.filePath(layer_name + '.qml'))
              raster_layer.saveNamedStyle(style_path.absoluteFilePath())
  
          assert output.exists()
          return True, output.baseName()
docs: Add a raster layer to the folder.
  
          :param raster_layer: The layer to add.
          :type raster_layer: QgsRasterLayer
  
          :param layer_name: The name of the layer in the datastore.
          :type layer_name: str
  
          :param save_style: If we have to save a QML too. Default to False.
          :type save_style: bool
  
          :returns: A two-tuple. The first element will be True if we could add
              the layer to the datastore. The second element will be the layer
              name which has been used or the error message.
          :rtype: (bool, str)
  
          .. versionadded:: 4.0