auto fd = -1;
for (int i = 0; i < MAX_SAVED_FLOORS; i++) {
saved_floor_type *sf_ptr = &saved_floors[i];
- std::string floor_savefile = get_saved_floor_name(i);
+ auto floor_savefile = get_saved_floor_name(i);
safe_setuid_grab(player_ptr);
- fd = fd_make(floor_savefile.data());
+ fd = fd_make(floor_savefile);
safe_setuid_drop();
check_saved_tmp_files(fd, &force);
safe_setuid_grab(player_ptr);
safe_setuid_drop();
if (fd < 0) {
safe_setuid_grab(player_ptr);
- fd = fd_make(path.string());
+ fd = fd_make(path);
safe_setuid_drop();
}
movie_fd = fd_open(filename, O_WRONLY | O_TRUNC);
} else {
- movie_fd = fd_make(filename);
+ movie_fd = fd_make(path);
}
if (!movie_fd) {
fd = fd_open(filename_score, O_RDONLY);
if (fd < 0) {
safe_setuid_grab(player_ptr);
- fd = fd_make(filename_score, true);
+ fd = fd_make(path_score, true);
safe_setuid_drop();
if (fd < 0) {
std::string why = _("'", "Cannot create the '");
saving_savefile = nullptr;
safe_setuid_grab(player_ptr);
- auto fd = fd_make(floor_savefile.data());
+ auto fd = fd_make(floor_savefile);
safe_setuid_drop();
bool is_save_successful = false;
if (fd >= 0) {
/*!
* @brief OSごとの差異を吸収してファイルを作成する
- * @param file 作成先ファイルの相対パスまたは絶対パス
+ * @param path 作成先ファイルの相対パスまたは絶対パス
* @param can_write_group グループに書き込みを許可するか否か
*/
-int fd_make(std::string_view file, bool can_write_group)
+int fd_make(const std::filesystem::path &path, bool can_write_group)
{
const auto permission = can_write_group ? 0644 : 0664;
- const auto &path = path_parse(file);
- return open(path.string().data(), O_CREAT | O_EXCL | O_WRONLY | O_BINARY, permission);
+ const auto &parsed_path = path_parse(path);
+ return open(parsed_path.string().data(), O_CREAT | O_EXCL | O_WRONLY | O_BINARY, permission);
}
/*
errr angband_fclose(FILE *fff);
void fd_kill(std::string_view file);
void fd_move(std::string_view from, std::string_view to);
-int fd_make(std::string_view file, bool can_write_group = false);
+int fd_make(const std::filesystem::path &path, bool can_write_group = false);
int fd_open(std::string_view file, int mode);
errr fd_lock(int fd, int what);
errr fd_seek(int fd, ulong n);