fixing sign-conversion warnings, part 21, file_flags (#1750)
fixing sign-conversion warnings, part 21, file_flags
This commit is contained in:
parent
3a93e1767b
commit
97c8d0486c
|
@ -146,7 +146,7 @@ void bind_create_torrent()
|
||||||
std::string (file_storage::*file_storage_file_path)(file_index_t, std::string const&) const = &file_storage::file_path;
|
std::string (file_storage::*file_storage_file_path)(file_index_t, std::string const&) const = &file_storage::file_path;
|
||||||
std::int64_t (file_storage::*file_storage_file_size)(file_index_t) const = &file_storage::file_size;
|
std::int64_t (file_storage::*file_storage_file_size)(file_index_t) const = &file_storage::file_size;
|
||||||
std::int64_t (file_storage::*file_storage_file_offset)(file_index_t) const = &file_storage::file_offset;
|
std::int64_t (file_storage::*file_storage_file_offset)(file_index_t) const = &file_storage::file_offset;
|
||||||
int (file_storage::*file_storage_file_flags)(file_index_t) const = &file_storage::file_flags;
|
std::uint32_t (file_storage::*file_storage_file_flags)(file_index_t) const = &file_storage::file_flags;
|
||||||
|
|
||||||
#ifndef TORRENT_NO_DEPRECATE
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
file_entry (file_storage::*at)(int) const = &file_storage::at;
|
file_entry (file_storage::*at)(int) const = &file_storage::at;
|
||||||
|
|
|
@ -285,7 +285,7 @@ namespace libtorrent
|
||||||
, std::string const& path, std::int64_t file_size
|
, std::string const& path, std::int64_t file_size
|
||||||
, std::uint32_t file_flags = 0, char const* filehash = 0
|
, std::uint32_t file_flags = 0, char const* filehash = 0
|
||||||
, std::int64_t mtime = 0, string_view symlink_path = string_view());
|
, std::int64_t mtime = 0, string_view symlink_path = string_view());
|
||||||
void add_file(std::string const& path, std::int64_t file_size, int file_flags = 0
|
void add_file(std::string const& path, std::int64_t file_size, std::uint32_t file_flags = 0
|
||||||
, std::time_t mtime = 0, string_view symlink_path = string_view());
|
, std::time_t mtime = 0, string_view symlink_path = string_view());
|
||||||
|
|
||||||
// renames the file at ``index`` to ``new_filename``. Keep in mind
|
// renames the file at ``index`` to ``new_filename``. Keep in mind
|
||||||
|
@ -301,7 +301,7 @@ namespace libtorrent
|
||||||
// instead, use the wchar -> utf8 conversion functions
|
// instead, use the wchar -> utf8 conversion functions
|
||||||
// and pass in utf8 strings
|
// and pass in utf8 strings
|
||||||
TORRENT_DEPRECATED
|
TORRENT_DEPRECATED
|
||||||
void add_file(std::wstring const& p, std::int64_t size, int flags = 0
|
void add_file(std::wstring const& p, std::int64_t size, std::uint32_t flags = 0
|
||||||
, std::time_t mtime = 0, string_view s_p = "");
|
, std::time_t mtime = 0, string_view s_p = "");
|
||||||
TORRENT_DEPRECATED
|
TORRENT_DEPRECATED
|
||||||
void rename_file(file_index_t index, std::wstring const& new_filename);
|
void rename_file(file_index_t index, std::wstring const& new_filename);
|
||||||
|
@ -489,7 +489,7 @@ namespace libtorrent
|
||||||
|
|
||||||
// flags indicating various attributes for files in
|
// flags indicating various attributes for files in
|
||||||
// a file_storage.
|
// a file_storage.
|
||||||
enum file_flags_t
|
enum file_flags_t : std::uint32_t
|
||||||
{
|
{
|
||||||
// this file is a pad file. The creator of the
|
// this file is a pad file. The creator of the
|
||||||
// torrent promises the file is entirely filled with
|
// torrent promises the file is entirely filled with
|
||||||
|
@ -515,7 +515,7 @@ namespace libtorrent
|
||||||
|
|
||||||
// returns a bitmask of flags from file_flags_t that apply
|
// returns a bitmask of flags from file_flags_t that apply
|
||||||
// to file at ``index``.
|
// to file at ``index``.
|
||||||
int file_flags(file_index_t index) const;
|
std::uint32_t file_flags(file_index_t index) const;
|
||||||
|
|
||||||
// returns true if the file at the specified index has been renamed to
|
// returns true if the file at the specified index has been renamed to
|
||||||
// have an absolute path, i.e. is not anchored in the save path of the
|
// have an absolute path, i.e. is not anchored in the save path of the
|
||||||
|
|
|
@ -58,7 +58,7 @@ namespace libtorrent
|
||||||
inline bool ignore_subdir(std::string const& leaf)
|
inline bool ignore_subdir(std::string const& leaf)
|
||||||
{ return leaf == ".." || leaf == "."; }
|
{ return leaf == ".." || leaf == "."; }
|
||||||
|
|
||||||
int get_file_attributes(std::string const& p)
|
std::uint32_t get_file_attributes(std::string const& p)
|
||||||
{
|
{
|
||||||
#ifdef TORRENT_WINDOWS
|
#ifdef TORRENT_WINDOWS
|
||||||
WIN32_FILE_ATTRIBUTE_DATA attr;
|
WIN32_FILE_ATTRIBUTE_DATA attr;
|
||||||
|
@ -74,8 +74,8 @@ namespace libtorrent
|
||||||
return 0;
|
return 0;
|
||||||
#else
|
#else
|
||||||
struct stat s;
|
struct stat s;
|
||||||
if (lstat(convert_to_native(p).c_str(), &s) < 0) return 0;
|
if (::lstat(convert_to_native(p).c_str(), &s) < 0) return 0;
|
||||||
int file_attr = 0;
|
std::uint32_t file_attr = 0;
|
||||||
if (s.st_mode & S_IXUSR)
|
if (s.st_mode & S_IXUSR)
|
||||||
file_attr += file_storage::attribute_executable;
|
file_attr += file_storage::attribute_executable;
|
||||||
if (S_ISLNK(s.st_mode))
|
if (S_ISLNK(s.st_mode))
|
||||||
|
@ -142,7 +142,7 @@ namespace libtorrent
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// #error use the fields from s
|
// #error use the fields from s
|
||||||
int file_flags = get_file_attributes(f);
|
std::uint32_t file_flags = get_file_attributes(f);
|
||||||
|
|
||||||
// mask all bits to check if the file is a symlink
|
// mask all bits to check if the file is a symlink
|
||||||
if ((file_flags & file_storage::attribute_symlink)
|
if ((file_flags & file_storage::attribute_symlink)
|
||||||
|
@ -531,7 +531,7 @@ namespace libtorrent
|
||||||
file_index_t const first(0);
|
file_index_t const first(0);
|
||||||
if (m_include_mtime) info["mtime"] = m_files.mtime(first);
|
if (m_include_mtime) info["mtime"] = m_files.mtime(first);
|
||||||
info["length"] = m_files.file_size(first);
|
info["length"] = m_files.file_size(first);
|
||||||
int const flags = m_files.file_flags(first);
|
std::uint32_t const flags = m_files.file_flags(first);
|
||||||
if (flags & (file_storage::flag_pad_file
|
if (flags & (file_storage::flag_pad_file
|
||||||
| file_storage::flag_hidden
|
| file_storage::flag_hidden
|
||||||
| file_storage::flag_executable
|
| file_storage::flag_executable
|
||||||
|
@ -582,7 +582,7 @@ namespace libtorrent
|
||||||
path_e.list().push_back(entry(e));
|
path_e.list().push_back(entry(e));
|
||||||
}
|
}
|
||||||
|
|
||||||
int const flags = m_files.file_flags(i);
|
std::uint32_t const flags = m_files.file_flags(i);
|
||||||
if (flags != 0)
|
if (flags != 0)
|
||||||
{
|
{
|
||||||
std::string& attr = file_e["attr"].string();
|
std::string& attr = file_e["attr"].string();
|
||||||
|
|
|
@ -338,7 +338,7 @@ namespace libtorrent
|
||||||
|
|
||||||
void file_storage::add_file(file_entry const& fe, char const* filehash)
|
void file_storage::add_file(file_entry const& fe, char const* filehash)
|
||||||
{
|
{
|
||||||
int flags = 0;
|
std::uint32_t flags = 0;
|
||||||
if (fe.pad_file) flags |= file_storage::flag_pad_file;
|
if (fe.pad_file) flags |= file_storage::flag_pad_file;
|
||||||
if (fe.hidden_attribute) flags |= file_storage::flag_hidden;
|
if (fe.hidden_attribute) flags |= file_storage::flag_hidden;
|
||||||
if (fe.executable_attribute) flags |= file_storage::flag_executable;
|
if (fe.executable_attribute) flags |= file_storage::flag_executable;
|
||||||
|
@ -361,7 +361,7 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
|
|
||||||
void file_storage::add_file(std::wstring const& file, std::int64_t file_size
|
void file_storage::add_file(std::wstring const& file, std::int64_t file_size
|
||||||
, int file_flags, std::time_t mtime, string_view symlink_path)
|
, std::uint32_t file_flags, std::time_t mtime, string_view symlink_path)
|
||||||
{
|
{
|
||||||
add_file(wchar_utf8(file), file_size, file_flags, mtime, symlink_path);
|
add_file(wchar_utf8(file), file_size, file_flags, mtime, symlink_path);
|
||||||
}
|
}
|
||||||
|
@ -540,7 +540,7 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
|
|
||||||
void file_storage::add_file(std::string const& path, std::int64_t file_size
|
void file_storage::add_file(std::string const& path, std::int64_t file_size
|
||||||
, int file_flags, std::time_t mtime, string_view symlink_path)
|
, std::uint32_t file_flags, std::time_t mtime, string_view symlink_path)
|
||||||
{
|
{
|
||||||
add_file_borrow(nullptr, 0, path, file_size, file_flags, nullptr, mtime
|
add_file_borrow(nullptr, 0, path, file_size, file_flags, nullptr, mtime
|
||||||
, symlink_path);
|
, symlink_path);
|
||||||
|
@ -813,14 +813,14 @@ namespace libtorrent
|
||||||
return m_files[index].offset;
|
return m_files[index].offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
int file_storage::file_flags(file_index_t const index) const
|
std::uint32_t file_storage::file_flags(file_index_t const index) const
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT_PRECOND(index >= file_index_t(0) && index < end_file());
|
TORRENT_ASSERT_PRECOND(index >= file_index_t(0) && index < end_file());
|
||||||
internal_file_entry const& fe = m_files[index];
|
internal_file_entry const& fe = m_files[index];
|
||||||
return (fe.pad_file ? flag_pad_file : 0)
|
return (fe.pad_file ? flag_pad_file : 0u)
|
||||||
| (fe.hidden_attribute ? flag_hidden : 0)
|
| (fe.hidden_attribute ? flag_hidden : 0u)
|
||||||
| (fe.executable_attribute ? flag_executable : 0)
|
| (fe.executable_attribute ? flag_executable : 0u)
|
||||||
| (fe.symlink_attribute ? flag_symlink : 0);
|
| (fe.symlink_attribute ? flag_symlink : 0u);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool file_storage::file_absolute_path(file_index_t const index) const
|
bool file_storage::file_absolute_path(file_index_t const index) const
|
||||||
|
|
Loading…
Reference in New Issue