w_ptr->character_icky_depth = 1;
const auto &path = path_build(ANGBAND_DIR_APEX, "scores.raw");
safe_setuid_grab(player_ptr);
- highscore_fd = fd_open(path.string(), O_RDWR);
+ highscore_fd = fd_open(path, O_RDWR);
safe_setuid_drop();
if (!check_death(player_ptr)) {
signals_ignore_tstp();
w_ptr->character_icky_depth = 1;
const auto &path = path_build(ANGBAND_DIR_APEX, "scores.raw");
- highscore_fd = fd_open(path.string(), O_RDWR);
+ highscore_fd = fd_open(path, O_RDWR);
/* 町名消失バグ対策(#38205)のためここで世界マップ情報を読み出す */
parse_fixed_map(player_ptr, WILDERNESS_DEFINITION, 0, 0, w_ptr->max_wild_y, w_ptr->max_wild_x);
{
screen_save();
const auto &path = path_build(ANGBAND_DIR_APEX, "scores.raw");
- highscore_fd = fd_open(path.string(), O_RDONLY);
+ highscore_fd = fd_open(path, O_RDONLY);
if (highscore_fd < 0) {
msg_print(_("スコア・ファイルが使用できません。", "Score file unavailable."));
msg_print(nullptr);
/* rr9: TODO - pluralize the race */
prt(std::string(_("最高の", "The Greatest of all the ")).append(race_info[race_num].title), 5, 15);
const auto &path = path_build(ANGBAND_DIR_APEX, "scores.raw");
- highscore_fd = fd_open(path.string(), O_RDONLY);
+ highscore_fd = fd_open(path, O_RDONLY);
if (highscore_fd < 0) {
msg_print(_("スコア・ファイルが使用できません。", "Score file unavailable."));
msg_print(nullptr);
errr file_character(PlayerType *player_ptr, concptr name)
{
const auto &path = path_build(ANGBAND_DIR_USER, name);
- const auto &filename = path.string();
- auto fd = fd_open(filename, O_RDONLY);
+ auto fd = fd_open(path, O_RDONLY);
if (fd >= 0) {
+ const auto &filename = path.string();
std::string query = _("現存するファイル ", "Replace existing file ");
query.append(filename).append(_(" に上書きしますか? ", "? "));
(void)fd_close(fd);
uint32_t counts_read(PlayerType *player_ptr, int where)
{
const auto &path = path_build(ANGBAND_DIR_DATA, _("z_info_j.raw", "z_info.raw"));
- auto fd = fd_open(path.string(), O_RDONLY);
+ auto fd = fd_open(path, O_RDONLY);
uint32_t count = 0;
if (counts_seek(player_ptr, fd, where, false) || fd_read(fd, (char *)(&count), sizeof(uint32_t))) {
count = 0;
{
const auto &path = path_build(ANGBAND_DIR_DATA, _("z_info_j.raw", "z_info.raw"));
safe_setuid_grab(player_ptr);
- auto fd = fd_open(path.string(), O_RDWR);
+ auto fd = fd_open(path, O_RDWR);
safe_setuid_drop();
if (fd < 0) {
safe_setuid_grab(player_ptr);
}
const auto &path = path_build(ANGBAND_DIR_USER, movie_filename);
- const auto &filename = path.string();
- auto fd = fd_open(filename, O_RDONLY);
+ auto fd = fd_open(path, O_RDONLY);
if (fd >= 0) {
+ const auto &filename = path.string();
(void)fd_close(fd);
std::string query = _("現存するファイルに上>書きしますか? (", "Replace existing file ");
query.append(filename);
return;
}
- movie_fd = fd_open(filename, O_WRONLY | O_TRUNC);
+ movie_fd = fd_open(path, O_WRONLY | O_TRUNC);
} else {
movie_fd = fd_make(path);
}
constexpr auto version_length = variant_length + 6;
char tmp_ver[version_length]{};
if (!err) {
- fd = fd_open(savefile_str.data(), O_RDONLY);
+ fd = fd_open(savefile, O_RDONLY);
if (fd < 0) {
err = true;
}
}
case IDM_FILE_SCORE: {
const auto &path = path_build(ANGBAND_DIR_APEX, "scores.raw");
- highscore_fd = fd_open(path.string(), O_RDONLY);
+ highscore_fd = fd_open(path, O_RDONLY);
if (highscore_fd < 0) {
msg_print("Score file unavailable.");
} else {
switch (arg_graphics) {
case GRAPHICS_ORIGINAL: {
const auto &path = path_build(ANGBAND_DIR_XTRA, "graf/8x8.bmp");
- const auto &filename = path.string();
- if (0 == fd_close(fd_open(filename, O_RDONLY))) {
+ if (0 == fd_close(fd_open(path, O_RDONLY))) {
use_graphics = true;
pict_wid = pict_hgt = 8;
ANGBAND_GRAF = "old";
}
case GRAPHICS_ADAM_BOLT: {
const auto &path = path_build(ANGBAND_DIR_XTRA, "graf/16x16.bmp");
- const auto &filename = path.string();
- if (0 == fd_close(fd_open(filename, O_RDONLY))) {
+ if (0 == fd_close(fd_open(path, O_RDONLY))) {
use_graphics = true;
pict_wid = pict_hgt = 16;
ANGBAND_GRAF = "new";
void init_angband(PlayerType *player_ptr, bool no_term)
{
const auto &path_news = path_build(ANGBAND_DIR_FILE, _("news_j.txt", "news.txt"));
- auto fd = fd_open(path_news.string(), O_RDONLY);
+ auto fd = fd_open(path_news, O_RDONLY);
if (fd < 0) {
std::string why = _("'", "Cannot access the '");
why.append(path_news.string());
}
const auto &path_score = path_build(ANGBAND_DIR_APEX, "scores.raw");
- const auto &filename_score = path_score.string();
- fd = fd_open(filename_score, O_RDONLY);
+ fd = fd_open(path_score, O_RDONLY);
if (fd < 0) {
safe_setuid_grab(player_ptr);
fd = fd_make(path_score, true);
safe_setuid_drop();
if (fd < 0) {
+ const auto &filename_score = path_score.string();
std::string why = _("'", "Cannot create the '");
why.append(filename_score);
why.append(_("'ファイルを作成できません!", "' file!"));
/*
* @brief OSごとの差異を吸収してファイルを開く
- * @param file ファイルの相対パスまたは絶対パス
+ * @param path ファイルの相対パスまたは絶対パス
* @param mode ファイルのオープンモード (読み書き、Append/Trunc等)
*/
-int fd_open(std::string_view file, int mode)
+int fd_open(const std::filesystem::path &path, int mode)
{
- const auto &path = path_parse(file);
- return open(path.string().data(), mode | O_BINARY, 0);
+ const auto &path_abs = path_parse(path);
+ return open(path_abs.string().data(), mode | O_BINARY, 0);
}
/*
void fd_kill(const std::filesystem::path &path);
void fd_move(std::string_view from, std::string_view to);
int fd_make(const std::filesystem::path &path, bool can_write_group = false);
-int fd_open(std::string_view file, int mode);
+int fd_open(const std::filesystem::path &path, int mode);
errr fd_lock(int fd, int what);
errr fd_seek(int fd, ulong n);
errr fd_read(int fd, char *buf, ulong n);