Files
test/source/blender/editors/space_file/file_utils.cc
Campbell Barton 381898b6dc Refactor: move BLI_path_util header to C++, rename to BLI_path_utils
Move to a C++ header to allow C++ features to be used there,
use the "utils" suffix as it's preferred for new files.

Ref !128147
2024-09-26 21:13:39 +10:00

39 lines
1.0 KiB
C++

/* SPDX-FileCopyrightText: 2023 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup spfile
*/
#include "BLI_path_utils.hh"
#include "BLI_rect.h"
#include "BLI_string.h"
#include "BKE_blendfile.hh"
#include "ED_fileselect.hh"
#include "file_intern.hh"
void file_tile_boundbox(const ARegion *region, FileLayout *layout, const int file, rcti *r_bounds)
{
int xmin, ymax;
ED_fileselect_layout_tilepos(layout, file, &xmin, &ymax);
ymax = int(region->v2d.tot.ymax) - ymax; /* real, view space ymax */
BLI_rcti_init(r_bounds,
xmin,
xmin + layout->tile_w + layout->tile_border_x,
ymax - layout->tile_h - layout->tile_border_y,
ymax);
}
void file_path_to_ui_path(const char *path, char *r_path, int r_path_maxncpy)
{
char tmp_path[FILE_MAX_LIBEXTRA];
STRNCPY(tmp_path, path);
BLI_path_slash_rstrip(tmp_path);
BLI_strncpy(r_path, BKE_blendfile_extension_check(tmp_path) ? tmp_path : path, r_path_maxncpy);
}