Skip to content

Commit

Permalink
Fix comments and error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
rikyoz committed Jan 6, 2023
1 parent a70d278 commit 50b3cae
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
5 changes: 3 additions & 2 deletions include/bit7z/bitoutputarchive.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ class BitOutputArchive {
*/
explicit BitOutputArchive( const BitAbstractArchiveCreator& creator, tstring in_file = {} );


/**
* @brief Constructs a BitOutputArchive object, opening an input file archive from the given buffer.
*
Expand All @@ -81,7 +80,6 @@ class BitOutputArchive {
*/
BitOutputArchive( const BitAbstractArchiveCreator& creator, const vector< byte_t >& in_buffer );


/**
* @brief Constructs a BitOutputArchive object, reading an input file archive from the given std::istream.
*
Expand Down Expand Up @@ -205,6 +203,9 @@ class BitOutputArchive {
*/
const BitAbstractArchiveHandler& handler() const noexcept;

/**
* @brief Default destructor.
*/
virtual ~BitOutputArchive() = default;

protected:
Expand Down
8 changes: 4 additions & 4 deletions src/bitinputarchive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ IInArchive* BitInputArchive::openArchiveStream( const tstring& name, IInStream*
#ifdef BIT7Z_AUTO_FORMAT
bool detected_by_signature = false;
if ( *mDetectedFormat == BitFormat::Auto ) {
// Detecting format of the input file
// Detecting the format of the input file
mDetectedFormat = &( detectFormatFromSig( in_stream ) );
detected_by_signature = true;
}
Expand All @@ -102,7 +102,7 @@ IInArchive* BitInputArchive::openArchiveStream( const tstring& name, IInStream*

#ifdef BIT7Z_AUTO_FORMAT
if ( res != S_OK && mArchiveHandler.format() == BitFormat::Auto && !detected_by_signature ) {
/* User wanted auto-detection of format, an extension was detected but opening failed, so we try a more
/* User wanted auto-detection of the format, an extension was detected but opening failed, so we try a more
* precise detection by checking the signature.
* NOTE: If user specified explicitly a format (i.e., not BitFormat::Auto), this check is not performed,
* and an exception is thrown (next if)!
Expand Down Expand Up @@ -143,14 +143,14 @@ BitInputArchive::BitInputArchive( const BitAbstractArchiveHandler& handler, tstr
}

BitInputArchive::BitInputArchive( const BitAbstractArchiveHandler& handler, const vector< byte_t >& in_buffer )
: mDetectedFormat{ &handler.format() }, // if auto, detect the format from content, otherwise try passed format.
: mDetectedFormat{ &handler.format() }, // if auto, detect the format from content, otherwise try the passed format.
mArchiveHandler{ handler } {
auto buf_stream = bit7z::make_com< CBufferInStream, IInStream >( in_buffer );
mInArchive = openArchiveStream( BIT7Z_STRING( "." ), buf_stream );
}

BitInputArchive::BitInputArchive( const BitAbstractArchiveHandler& handler, std::istream& in_stream )
: mDetectedFormat{ &handler.format() }, // if auto, detect the format from content, otherwise try passed format.
: mDetectedFormat{ &handler.format() }, // if auto, detect the format from content, otherwise try the passed format.
mArchiveHandler{ handler } {
auto std_stream = bit7z::make_com< CStdInStream, IInStream >( in_stream );
mInArchive = openArchiveStream( BIT7Z_STRING( "." ), std_stream );
Expand Down
2 changes: 1 addition & 1 deletion src/bititemsvector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void BitItemsVector::indexPathsMap( const map< tstring, tstring >& in_paths, Ind
void BitItemsVector::indexItem( const FSItem& item, IndexingOptions options ) {
if ( !item.isDir() ) {
mItems.emplace_back( std::make_unique< FSItem >( item ) );
} else if ( options.recursive ) { //item is a directory
} else if ( options.recursive ) { // The item is a directory
if ( !item.inArchivePath().empty() ) {
mItems.emplace_back( std::make_unique< FSItem >( item ) );
}
Expand Down
10 changes: 5 additions & 5 deletions src/bitoutputarchive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ BitOutputArchive::BitOutputArchive( const BitAbstractArchiveCreator& creator, ts
}

if ( mArchiveCreator.updateMode() == UpdateMode::None ) {
throw BitException( "Cannot update existing archive",
throw BitException( "Cannot update the existing archive",
make_error_code( BitError::WrongUpdateMode ) );
}

if ( !mArchiveCreator.compressionFormat().hasFeature( FormatFeatures::MultipleFiles ) ) {
//Update mode is set but format does not support adding more files.
throw BitException( "Cannot update existing archive",
//Update mode is set, but the format does not support adding more files.
throw BitException( "Cannot update the existing archive",
make_error_code( BitError::FormatFeatureNotSupported ) );
}

Expand Down Expand Up @@ -183,7 +183,7 @@ void BitOutputArchive::compressOut( IOutArchive* out_arc,
}

void BitOutputArchive::compressToFile( const tstring& out_file, UpdateCallback* update_callback ) {
// Note: if mInputArchive != nullptr, new_arc will actually point to the same IInArchive object used by old_arc
// Note: if mInputArchive != nullptr, new_arc will actually point to the same IInArchive object used by the old_arc
// (see initUpdatableArchive function of BitInputArchive)!
const bool updating_archive = mInputArchive != nullptr && mInputArchive->archivePath() == out_file;
const CMyComPtr< IOutArchive > new_arc = initOutArchive();
Expand All @@ -193,7 +193,7 @@ void BitOutputArchive::compressToFile( const tstring& out_file, UpdateCallback*
if ( updating_archive ) { //we updated the input archive
auto close_result = mInputArchive->close();
if ( close_result != S_OK ) {
throw BitException( "Failed to close the opened archive", make_hresult_code( close_result ),
throw BitException( "Failed to close the archive", make_hresult_code( close_result ),
mInputArchive->archivePath() );
}
/* NOTE: In the following instruction, we use the (dot) operator, not the -> (arrow) operator:
Expand Down
7 changes: 3 additions & 4 deletions src/internal/fsitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,12 @@ using bit7z::filesystem::FSItem;

/* NOTES:
* 1) mPath contains the path to the file, including the filename. It can be relative or absolute, according to what
* the user passes as path parameter in the constructor. If it is a directory, it doesn't contain a trailing / or \
* character, to use the method FindFirstFile without problems (as requested by that WinAPI function).
* 2) mSearchPath contains the search path in which the item was found (e.g., if FSIndexer is searching items in
* the user passes as the path parameter in the constructor.
* 2) mSearchPath contains the search path in which the item was found (e.g., if FSIndexer is searching for items in
* "foo/bar/", each FSItem created for the elements it found will have mSearchPath == "foo/bar").
* As in mPath, mSearchPath does not contain trailing / or \! *
* 3) mInArchivePath is the path of the item in the archive. If not already given (i.e., the user doesn't want to custom
* the path of the file in the archive), the path in the archive is calculated form mPath and mSearchPath
* the path of the file in the archive), the path in the archive is calculated from mPath and mSearchPath
* (see inArchivePath() method). */

FSItem::FSItem( const fs::path& itemPath, fs::path inArchivePath )
Expand Down

0 comments on commit 50b3cae

Please sign in to comment.