OSDN Git Service

[Refactor] #3281 fd_open() の引数をstring_view からpath に差し替えた
[hengbandforosx/hengbandosx.git] / src / util / angband-files.h
1 #pragma once
2
3 #include "system/angband.h"
4 #include <filesystem>
5 #include <string_view>
6
7 /* Force definitions -- see fd_seek() */
8 #ifndef SEEK_SET
9 #define SEEK_SET 0
10 #endif
11 #ifndef SEEK_CUR
12 #define SEEK_CUR 1
13 #endif
14 #ifndef SEEK_END
15 #define SEEK_END 2
16 #endif
17
18 /* Force definitions -- see fd_lock() */
19 #ifndef F_UNLCK
20 #define F_UNLCK 0
21 #endif
22 #ifndef F_RDLCK
23 #define F_RDLCK 1
24 #endif
25 #ifndef F_WRLCK
26 #define F_WRLCK 2
27 #endif
28
29 #ifdef SET_UID
30 extern void user_name(char *buf, int id);
31 #ifndef HAVE_USLEEP
32 extern int usleep(ulong usecs);
33 #endif
34 #endif
35
36 #define FILE_READ_BUFF_SIZE 65535
37
38 enum class FileOpenMode {
39     READ,
40     WRITE,
41     APPEND,
42 };
43
44 std::filesystem::path path_parse(const std::filesystem::path &path);
45 std::filesystem::path path_build(const std::filesystem::path &path, std::string_view file);
46 FILE *angband_fopen(const std::filesystem::path &path, const FileOpenMode mode, const bool is_binary = false);
47 FILE *angband_fopen_temp(char *buf, int max);
48 errr angband_fgets(FILE *fff, char *buf, ulong n);
49 errr angband_fputs(FILE *fff, concptr buf, ulong n);
50 errr angband_fclose(FILE *fff);
51 void fd_kill(const std::filesystem::path &path);
52 void fd_move(std::string_view from, std::string_view to);
53 int fd_make(const std::filesystem::path &path, bool can_write_group = false);
54 int fd_open(const std::filesystem::path &path, int mode);
55 errr fd_lock(int fd, int what);
56 errr fd_seek(int fd, ulong n);
57 errr fd_read(int fd, char *buf, ulong n);
58 errr fd_write(int fd, concptr buf, ulong n);
59 errr fd_close(int fd);