Skip to content

Commit

Permalink
Add nativePath() method to BitArchiveItem
Browse files Browse the repository at this point in the history
  • Loading branch information
rikyoz committed Apr 29, 2024
1 parent 310cf97 commit a78cf34
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
8 changes: 8 additions & 0 deletions include/bit7z/bitarchiveitem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ class BitArchiveItem : public BitGenericItem {
*/
BIT7Z_NODISCARD auto path() const -> tstring override;

/**
* @note Same as path(), but returning a native string (i.e., std::wstring on Windows, std::string elsewhere).
*
* @return the path of the item in the archive, if available or inferable from the name, or an empty string
* otherwise.
*/
BIT7Z_NODISCARD auto nativePath() const -> native_string;

/**
* @return the uncompressed size of the item.
*/
Expand Down
9 changes: 9 additions & 0 deletions src/bitarchiveitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@ auto BitArchiveItem::path() const -> tstring {
return path.getString();
}

auto BitArchiveItem::nativePath() const -> native_string {
BitPropVariant path = itemProperty( BitProperty::Path );
if ( path.isEmpty() ) {
path = itemProperty( BitProperty::Name );
return path.isEmpty() ? native_string{} : path.getNativeString();
}
return path.getNativeString();
}

auto BitArchiveItem::size() const -> uint64_t {
const BitPropVariant size = itemProperty( BitProperty::Size );
return size.isEmpty() ? 0 : size.getUInt64();
Expand Down

0 comments on commit a78cf34

Please sign in to comment.