fa <fery....@gmail.com> schrieb am Fr. 7. Juli 2023 um 09:21: > Hi Jeffrey Walton > > > Sorry I answered late. > > > std::filesystem::path _path { > std::filesystem::u8path(filePath.toStdString()) }; > > std::string _path_string { _path.u8string() }; > > std::ifstream m_file(_path_string, std::ios::in); > > FileSource f(m_file, true, new HashFilter(hash, new HexEncoder(new > StringSink(digest)))); > > > > ERROR: > > > terminate called after throwing an instance of > 'CryptoPP::FileStore::ReadErr' > > what(): FileStore: error reading file > > > The error message you're encountering suggests that there's an issue with > reading the file specified by _path_string in your code. The error is > thrown by CryptoPP::FileStore, indicating a problem while trying to read > the file. > > Here are a few possible reasons for this error: > > 1. > > Incorrect file path: Double-check that filePath.toStdString() returns > the correct file path. Ensure that the file exists at that location and > that you have read permissions. > 2. > > File permission issues: Make sure that the file you're trying to read > has proper read permissions set. Check the file's permissions and adjust > them if necessary. > 3. > > File not found: If the file specified by _path_string doesn't exist, > you'll encounter this error. Verify that the file exists at the given path > and that there are no typos in the file name or path. > 4. > > Insufficient privileges: If your program doesn't have sufficient > privileges to access the file, you may encounter this error. Ensure that > your program has the necessary permissions to read files from the specified > location. > 5. > > Encoding issues: It's possible that the file you're trying to read > contains data encoded in an incompatible format. Ensure that the file is in > a readable format and that it's not corrupted or encoded in a way that the > std::ifstream cannot handle. > > To pinpoint the exact cause of the error, you can try adding some error > handling and debugging statements to your code. For example, you can check > if the file exists before attempting to read it using > std::filesystem::exists(_path). > > Here's an updated version of your code that includes some error handling: > > cpp > > std::filesystem::path _path{ std::filesystem::u8path(filePath.toStdString()) }; std::string _path_string{ _path.u8string() };
if (!std::filesystem::exists(_path)) { std::cerr << "File does not exist: " << _path_string << std::endl; // Handle the error accordingly } else { std::ifstream m_file(_path_string, std::ios::in); if (!m_file) { std::cerr << "Failed to open file: " << _path_string << std::endl; // Handle the error accordingly } else { FileSource f(m_file, true, new HashFilter(hash, new HexEncoder(new StringSink(digest)))); // Continue processing the file } } the file } } > > By using this updated code, you should be able to identify the specific > issue causing the CryptoPP::FileStore::ReadErr error and handle it > appropriately. > > > -- > You received this message because you are subscribed to the Google Groups > "Crypto++ Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to cryptopp-users+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/cryptopp-users/cb4562d6-7ea9-4b7c-9a6f-c280421fffc1n%40googlegroups.com > <https://groups.google.com/d/msgid/cryptopp-users/cb4562d6-7ea9-4b7c-9a6f-c280421fffc1n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "Crypto++ Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to cryptopp-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/cryptopp-users/CAJm61-DgJM5PhAK0SeNEMb_h7yuqx28FyWZhkN4WRB6YZ0hPhw%40mail.gmail.com.