refactor: remove unused TR_SYS_FILE_APPEND (#7206)
This commit is contained in:
parent
c1047b8009
commit
f988da6aa1
|
@ -560,12 +560,11 @@ tr_sys_file_t tr_sys_file_open(char const* path, int flags, int permissions, tr_
|
|||
int native_value;
|
||||
};
|
||||
|
||||
auto constexpr NativeMap = std::array<native_map_item, 8>{
|
||||
auto constexpr NativeMap = std::array<native_map_item, 7U>{
|
||||
{ { TR_SYS_FILE_READ | TR_SYS_FILE_WRITE, TR_SYS_FILE_READ | TR_SYS_FILE_WRITE, O_RDWR },
|
||||
{ TR_SYS_FILE_READ | TR_SYS_FILE_WRITE, TR_SYS_FILE_READ, O_RDONLY },
|
||||
{ TR_SYS_FILE_READ | TR_SYS_FILE_WRITE, TR_SYS_FILE_WRITE, O_WRONLY },
|
||||
{ TR_SYS_FILE_CREATE, TR_SYS_FILE_CREATE, O_CREAT },
|
||||
{ TR_SYS_FILE_APPEND, TR_SYS_FILE_APPEND, O_APPEND },
|
||||
{ TR_SYS_FILE_TRUNCATE, TR_SYS_FILE_TRUNCATE, O_TRUNC },
|
||||
{ TR_SYS_FILE_SEQUENTIAL, TR_SYS_FILE_SEQUENTIAL, O_SEQUENTIAL } }
|
||||
};
|
||||
|
|
|
@ -825,11 +825,6 @@ tr_sys_file_t tr_sys_file_open(char const* path, int flags, int /*permissions*/,
|
|||
auto ret = open_file(path, native_access, native_disposition, native_flags, error);
|
||||
auto success = ret != TR_BAD_SYS_FILE;
|
||||
|
||||
if (success && (flags & TR_SYS_FILE_APPEND) != 0)
|
||||
{
|
||||
success = SetFilePointer(ret, 0, nullptr, FILE_END) != INVALID_SET_FILE_POINTER;
|
||||
}
|
||||
|
||||
if (!success)
|
||||
{
|
||||
set_system_error(error, GetLastError());
|
||||
|
|
|
@ -50,9 +50,8 @@ enum tr_sys_file_open_flags_t
|
|||
TR_SYS_FILE_READ = (1 << 0),
|
||||
TR_SYS_FILE_WRITE = (1 << 1),
|
||||
TR_SYS_FILE_CREATE = (1 << 2),
|
||||
TR_SYS_FILE_APPEND = (1 << 3),
|
||||
TR_SYS_FILE_TRUNCATE = (1 << 4),
|
||||
TR_SYS_FILE_SEQUENTIAL = (1 << 5)
|
||||
TR_SYS_FILE_TRUNCATE = (1 << 3),
|
||||
TR_SYS_FILE_SEQUENTIAL = (1 << 4)
|
||||
};
|
||||
|
||||
enum tr_sys_file_lock_flags_t
|
||||
|
|
|
@ -1128,22 +1128,11 @@ TEST_F(FileTest, fileOpen)
|
|||
tr_sys_path_remove(path1);
|
||||
createFileWithContents(path1, "test");
|
||||
|
||||
/* Pointer is at the end of file */
|
||||
/* File gets truncated */
|
||||
auto info = tr_sys_path_get_info(path1, TR_SYS_PATH_NO_FOLLOW);
|
||||
EXPECT_TRUE(info.has_value());
|
||||
assert(info.has_value());
|
||||
EXPECT_EQ(4U, info->size);
|
||||
fd = tr_sys_file_open(path1, TR_SYS_FILE_WRITE | TR_SYS_FILE_APPEND, 0600, &error);
|
||||
EXPECT_NE(TR_BAD_SYS_FILE, fd);
|
||||
EXPECT_FALSE(error) << error;
|
||||
tr_sys_file_write(fd, "s", 1, nullptr); /* On *NIX, pointer is positioned on each write but not initially */
|
||||
tr_sys_file_close(fd);
|
||||
|
||||
/* File gets truncated */
|
||||
info = tr_sys_path_get_info(path1, TR_SYS_PATH_NO_FOLLOW);
|
||||
EXPECT_TRUE(info.has_value());
|
||||
assert(info.has_value());
|
||||
EXPECT_EQ(5U, info->size);
|
||||
fd = tr_sys_file_open(path1, TR_SYS_FILE_WRITE | TR_SYS_FILE_TRUNCATE, 0600, &error);
|
||||
EXPECT_NE(TR_BAD_SYS_FILE, fd);
|
||||
EXPECT_FALSE(error) << error;
|
||||
|
|
Loading…
Reference in New Issue