@@ -159,7 +159,11 @@ int FileIo::Impl::switchMode(OpMode opMode) {
159159 }
160160
161161 // Reopen the file
162- long offset = std::ftell (fp_);
162+ #ifdef _WIN32
163+ auto offset = _ftelli64 (fp_);
164+ #else
165+ auto offset = ftello (fp_);
166+ #endif
163167 if (offset == -1 )
164168 return -1 ;
165169 // 'Manual' open("r+b") to avoid munmap()
@@ -172,7 +176,11 @@ int FileIo::Impl::switchMode(OpMode opMode) {
172176 fp_ = std::fopen (path_.c_str (), openMode_.c_str ());
173177 if (!fp_)
174178 return 1 ;
175- return std::fseek (fp_, offset, SEEK_SET);
179+ #ifdef _WIN32
180+ return _fseeki64 (fp_, offset, SEEK_SET);
181+ #else
182+ return fseeko (fp_, offset, SEEK_SET);
183+ #endif
176184} // FileIo::Impl::switchMode
177185
178186int FileIo::Impl::stat (StructStat& buf) const {
@@ -460,15 +468,19 @@ int FileIo::seek(int64_t offset, Position pos) {
460468
461469 if (p_->switchMode (Impl::opSeek) != 0 )
462470 return 1 ;
463- #ifdef _WIN64
471+ #ifdef _WIN32
464472 return _fseeki64 (p_->fp_ , offset, fileSeek);
465473#else
466- return std::fseek (p_->fp_ , static_cast < long >( offset) , fileSeek);
474+ return fseeko (p_->fp_ , offset, fileSeek);
467475#endif
468476}
469477
470478size_t FileIo::tell () const {
471- const long pos = std::ftell (p_->fp_ );
479+ #ifdef _WIN32
480+ auto pos = _ftelli64 (p_->fp_ );
481+ #else
482+ auto pos = ftello (p_->fp_ );
483+ #endif
472484 Internal::enforce (pos >= 0 , ErrorCode::kerInputDataReadFailed);
473485 return static_cast <size_t >(pos);
474486}
@@ -1069,7 +1081,8 @@ size_t RemoteIo::Impl::populateBlocks(size_t lowBlock, size_t highBlock) {
10691081 throw Error (ErrorCode::kerErrorMessage, " Data By Range is empty. Please check the permission." );
10701082 }
10711083 auto source = reinterpret_cast <byte*>(const_cast <char *>(data.c_str ()));
1072- size_t remain = rcount, totalRead = 0 ;
1084+ size_t remain = rcount;
1085+ size_t totalRead = 0 ;
10731086 size_t iBlock = (rcount == size_) ? 0 : lowBlock;
10741087
10751088 while (remain) {
@@ -1109,7 +1122,9 @@ int RemoteIo::open() {
11091122 p_->blocksMap_ = new BlockMap[nBlocks];
11101123 p_->isMalloced_ = true ;
11111124 auto source = reinterpret_cast <byte*>(const_cast <char *>(data.c_str ()));
1112- size_t remain = p_->size_ , iBlock = 0 , totalRead = 0 ;
1125+ size_t remain = p_->size_ ;
1126+ size_t iBlock = 0 ;
1127+ size_t totalRead = 0 ;
11131128 while (remain) {
11141129 auto allow = std::min<size_t >(remain, p_->blockSize_ );
11151130 p_->blocksMap_ [iBlock].populate (&source[totalRead], allow);
@@ -1465,8 +1480,7 @@ void HttpIo::HttpImpl::writeRemote(const byte* data, size_t size, size_t from, s
14651480 }
14661481
14671482 // standardize the path without "/" at the beginning.
1468- std::size_t protocolIndex = scriptPath.find (" ://" );
1469- if (protocolIndex == std::string::npos && scriptPath.front () != ' /' ) {
1483+ if (scriptPath.find (" ://" ) == std::string::npos && scriptPath.front () != ' /' ) {
14701484 scriptPath = " /" + scriptPath;
14711485 }
14721486
@@ -1651,8 +1665,7 @@ void CurlIo::CurlImpl::writeRemote(const byte* data, size_t size, size_t from, s
16511665 Exiv2::Uri hostInfo = Exiv2::Uri::Parse (path_);
16521666
16531667 // add the protocol and host to the path
1654- std::size_t protocolIndex = scriptPath.find (" ://" );
1655- if (protocolIndex == std::string::npos) {
1668+ if (scriptPath.find (" ://" ) == std::string::npos) {
16561669 if (scriptPath.front () != ' /' )
16571670 scriptPath = " /" + scriptPath;
16581671 scriptPath = hostInfo.Protocol + " ://" + hostInfo.Host + scriptPath;
0 commit comments