1212
1313namespace Abyss ::FileSystem {
1414
15- class CASCStream : public SizeableStreambuf {
15+ class CASCStream final : public SizeableStreambuf {
1616 public:
17- CASCStream (void *casc, std::string fileName);
17+ CASCStream (void *casc, const std::string& fileName);
1818
1919 ~CASCStream () override ;
2020
2121 protected:
2222 int underflow () override ;
2323 pos_type seekpos (pos_type pos, std::ios_base::openmode which) override ;
2424 pos_type seekoff (off_type off, std::ios_base::seekdir dir, std::ios_base::openmode which) override ;
25- std::streamsize size () const override ;
25+ [[nodiscard]] std::streamsize size () const override ;
2626
2727 private:
28- void *_file = 0 ;
28+ void *_file = nullptr ;
2929 std::streamsize _startOfBlock = 0 ;
3030 char _buffer[2048 ] = {};
3131};
3232
33- CASCStream::CASCStream (HANDLE storage, std::string fileName) {
33+ CASCStream::CASCStream (HANDLE storage, const std::string& fileName) {
3434 if (!CascOpenFile (storage, fileName.c_str (), 0 , CASC_OPEN_BY_NAME, &_file)) {
3535 throw std::runtime_error (absl::StrCat (" Failed to open file '" , fileName, " ' from CASC" ));
3636 }
@@ -85,7 +85,7 @@ CASCStream::pos_type CASCStream::seekoff(off_type off, std::ios_base::seekdir di
8585std::streamsize CASCStream::size () const {
8686 ULONGLONG ulongsize;
8787 CascGetFileSize64 (_file, &ulongsize);
88- return ulongsize;
88+ return static_cast <std::streamsize>( ulongsize) ;
8989}
9090
9191static bool casc_progress_callback (void *PtrUserParam, LPCSTR szWork, LPCSTR szObject, DWORD CurrentValue, DWORD TotalValue) {
@@ -106,12 +106,12 @@ static bool casc_progress_callback(void *PtrUserParam, LPCSTR szWork, LPCSTR szO
106106}
107107
108108CASC::CASC (const std::filesystem::path &cascPath) {
109- std::string path = std::filesystem::absolute (cascPath).string ();
109+ const std::string path = std::filesystem::absolute (cascPath).string ();
110110 CASC_OPEN_STORAGE_ARGS args = {};
111111 args.Size = sizeof (CASC_OPEN_STORAGE_ARGS);
112112 args.PfnProgressCallback = casc_progress_callback;
113113 if (!CascOpenStorageEx (path.c_str (), &args, 0 , &_storage)) {
114- throw std::runtime_error (std ::format (" Error occurred while opening CASC {}: {}" , cascPath.string (), GetCascError ()));
114+ throw std::runtime_error (fmt ::format (" Error occurred while opening CASC {}: {}" , cascPath.string (), GetCascError ()));
115115 }
116116}
117117
0 commit comments