Skip to content

Commit b475377

Browse files
committed
OrcLib: FileAttribute: fix attribute flags integer output
When there are any unknown flag the displayed attribute could be a negative value.
1 parent 74c86a3 commit b475377

File tree

2 files changed

+8
-17
lines changed

2 files changed

+8
-17
lines changed

src/OrcLib/Filesystem/FileAttribute.cpp

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ constexpr std::string_view kFileAttributePinned = "FILE_ATTRIBUTE_PINNED";
4242
constexpr std::string_view kFileAttributeUnpinned = "FILE_ATTRIBUTE_UNPINNED";
4343
constexpr std::string_view kFileAttributeRecallOnOpen = "FILE_ATTRIBUTE_RECALL_ON_OPEN";
4444
constexpr std::string_view kFileAttributeRecallOnDataAccess = "FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS";
45+
constexpr std::string_view kFileAttributeStrictlySequential = "FILE_ATTRIBUTE_STRICTLY_SEQUENTIAL";
4546

4647
constexpr std::array kFileAttributes = {
4748
std::tuple {FileAttribute::kFileAttributeReadOnly, kFileAttributeReadOnly, 'R'},
@@ -66,6 +67,7 @@ constexpr std::array kFileAttributes = {
6667
std::tuple {FileAttribute::kFileAttributeUnpinned, kFileAttributeUnpinned, 'u'},
6768
std::tuple {FileAttribute::kFileAttributeRecallOnOpen, kFileAttributeRecallOnOpen, 'o'},
6869
std::tuple {FileAttribute::kFileAttributeRecallOnDataAccess, kFileAttributeRecallOnDataAccess, 'a'},
70+
std::tuple {FileAttribute::kFileAttributeStrictlySequential, kFileAttributeStrictlySequential, 'l'}
6971
};
7072

7173
bool HasInvalidFlag(uint32_t flags)
@@ -102,10 +104,6 @@ std::string ToString(FileAttribute flags)
102104

103105
if (::HasInvalidFlag(std::underlying_type_t<FileAttribute>(flags)))
104106
{
105-
Log::Debug(
106-
"Failed to convert some FileAttribute flags to string (value: {})",
107-
std::underlying_type_t<FileAttribute>(flags));
108-
109107
return fmt::format("{:#x}", std::underlying_type_t<FileAttribute>(flags));
110108
}
111109

@@ -141,10 +139,6 @@ char ToIdentifier(FileAttribute flags)
141139

142140
if (::HasInvalidFlag(std::underlying_type_t<FileAttribute>(flags)))
143141
{
144-
Log::Debug(
145-
"Failed to convert some FileAttribute flags to identifier (value: {})",
146-
std::underlying_type_t<FileAttribute>(flags));
147-
148142
return '?';
149143
}
150144

@@ -154,9 +148,6 @@ char ToIdentifier(FileAttribute flags)
154148
{
155149
if (flags != f)
156150
{
157-
Log::Debug(
158-
"Failed to convert some FileAttribute flags to unique identifier (value: {})",
159-
std::underlying_type_t<FileAttribute>(flags));
160151
return '?';
161152
}
162153

@@ -181,10 +172,6 @@ std::string ToIdentifiers(FileAttribute flags)
181172

182173
if (::HasInvalidFlag(std::underlying_type_t<FileAttribute>(flags)))
183174
{
184-
Log::Debug(
185-
"Failed to convert some FileAttribute flags to string (value: {})",
186-
std::underlying_type_t<FileAttribute>(flags));
187-
188175
return fmt::format("{:#x}", std::underlying_type_t<FileAttribute>(flags));
189176
}
190177

src/OrcLib/Filesystem/FileAttribute.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ namespace Orc {
3434
#define ORC_FILE_ATTRIBUTE_RECALL_ON_OPEN 0x00040000
3535
#define ORC_FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS 0x00400000
3636

37-
enum class FileAttribute
37+
//#define ORC_FILE_ATTRIBUTE_STRICTLY_SEQUENTIAL 0x00200000 // 10.0.16267.0
38+
#define ORC_FILE_ATTRIBUTE_STRICTLY_SEQUENTIAL 0x20000000 // >= 10.0.17134.0
39+
40+
enum class FileAttribute : uint32_t
3841
{
3942
kFileAttributeReadOnly = ORC_FILE_ATTRIBUTE_READONLY,
4043
kFileAttributeHidden = ORC_FILE_ATTRIBUTE_HIDDEN,
@@ -57,7 +60,8 @@ enum class FileAttribute
5760
kFileAttributePinned = ORC_FILE_ATTRIBUTE_PINNED,
5861
kFileAttributeUnpinned = ORC_FILE_ATTRIBUTE_UNPINNED,
5962
kFileAttributeRecallOnOpen = ORC_FILE_ATTRIBUTE_RECALL_ON_OPEN,
60-
kFileAttributeRecallOnDataAccess = ORC_FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS
63+
kFileAttributeRecallOnDataAccess = ORC_FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS,
64+
kFileAttributeStrictlySequential = ORC_FILE_ATTRIBUTE_STRICTLY_SEQUENTIAL
6165
};
6266

6367
ENABLE_BITMASK_OPERATORS(FileAttribute)

0 commit comments

Comments
 (0)