Files
test2/source/blender/blenlib/tests/BLI_tempfile_test.cc
Sergey Sharybin 8c38d29feb BLI: Add utility to access system-wide temporary directory
It provides path to a directory suitable for storing temporary files
which satisfies the following conditions:

- The directory exists.
- The return path has trailing directory separator.

It is based on the code used in the appdir.c to get the temporary
directory.

For the C++ people: this is similar to the temp_directory_path()
from the std::filesystem.

No functional changes expected as it is a new code which is planned
to be used on other places as a followup development.
2023-03-24 14:52:43 +01:00

28 lines
560 B
C++

/* SPDX-License-Identifier: Apache-2.0 */
#include "BLI_tempfile.h"
#include "BLI_fileops.h"
#include "BLI_path_util.h"
#include "testing/testing.h"
namespace blender::tests {
TEST(BLI_tempfile, BLI_temp_directory_path_get)
{
char temp_dir[FILE_MAX];
BLI_temp_directory_path_get(temp_dir, sizeof(temp_dir));
ASSERT_STRNE(temp_dir, "");
EXPECT_EQ(temp_dir[strlen(temp_dir) - 1], SEP);
EXPECT_TRUE(BLI_exists(temp_dir));
EXPECT_TRUE(BLI_is_dir(temp_dir));
EXPECT_TRUE(BLI_path_is_abs_from_cwd(temp_dir));
}
} // namespace blender::tests