''

def _filepath(self, layer, coord, format):

    l = layer.name()
    z = ('%d' % coord.zoom)
    e = format.lower()
    e += ((self._is_compressed(format) and '.gz') or '')
    if (self.dirs == 'safe'):
        x = ('%06d' % coord.column)
        y = ('%06d' % coord.row)
        (x1, x2) = (x[:3], x[3:])
        (y1, y2) = (y[:3], y[3:])
        filepath = os.sep.join((l, z, x1, x2, y1, ((y2 + '.') + e)))
    elif (self.dirs == 'portable'):
        x = ('%d' % coord.column)
        y = ('%d' % coord.row)
        filepath = os.sep.join((l, z, x, ((y + '.') + e)))
    elif (self.dirs == 'quadtile'):
        (pad, length) = ((1 << 31), (1 + coord.zoom))
        xs = bin((pad + int(coord.column)))[(- length):]
        ys = bin((pad + int(coord.row)))[(- length):]
        dirpath = ''.join([str(int((y + x), 2)) for (x, y) in zip(xs, ys)])
        parts = [dirpath[i:(i + 3)] for i in range(0, len(dirpath), 3)]
        filepath = os.sep.join((([l] + parts[:(-1)]) + [((parts[(-1)] + '.') + e)]))
    else:
        raise KnownUnknown(('Please    provide    a    valid    "dirs"    parameter    to    the    Disk    cache,    either    "safe",    "portable"    or    "quadtile"    but    not    "%s"' % self.dirs))
    return filepath
