[network/libktorrent] src: ABI/API break: use enum class for File::SeekPos

Jack Hill <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 4f16f3c9851471c59ef281db6d40b69ec256e97e by Jack Hill.
Committed on 15/08/2026 at 10:19.
Pushed by jackh into branch 'master'.

ABI/API break: use enum class for File::SeekPos

No downstream changes required.

M  +2    -2    src/datachecker/multidatachecker.cpp
M  +1    -1    src/datachecker/singledatachecker.cpp
M  +3    -3    src/diskio/chunkmanager.cpp
M  +4    -4    src/diskio/dndfile.cpp
M  +2    -2    src/diskio/multifilecache.cpp
M  +2    -2    src/torrent/torrentcreator.cpp
M  +3    -3    src/util/file.cpp
M  +1    -1    src/util/file.h

https://invent.kde.org/network/libktorrent/-/commit/4f16f3c9851471c59ef281db6d40b69ec256e97e

diff --git a/src/datachecker/multidatachecker.cpp b/src/datachecker/multidatachecker.cpp
index f7fc8f1f..66886467 100644
--- a/src/datachecker/multidatachecker.cpp
+++ b/src/datachecker/multidatachecker.cpp
@@ -113,7 +113,7 @@ bool MultiDataChecker::loadChunk(Uint32 ci, Uint32 cs, const Torrent &tor)
         if (!f.doNotDownload()) {
             File *fptr = open(tor, tflist.first());
             const Uint64 off = f.fileOffset(ci, tor.getChunkSize());
-            if (fptr->seek(File::BEGIN, off) != off) {
+            if (fptr->seek(File::SeekPos::BEGIN, off) != off) {
                 return false;
             }
 
@@ -172,7 +172,7 @@ bool MultiDataChecker::loadChunk(Uint32 ci, Uint32 cs, const Torrent &tor)
                 }
 
                 File *fptr = open(tor, tflist[i]);
-                if (fptr->seek(File::BEGIN, off) != off) {
+                if (fptr->seek(File::SeekPos::BEGIN, off) != off) {
                     return false;
                 }
 
diff --git a/src/datachecker/singledatachecker.cpp b/src/datachecker/singledatachecker.cpp
index c7485801..77724d3e 100644
--- a/src/datachecker/singledatachecker.cpp
+++ b/src/datachecker/singledatachecker.cpp
@@ -55,7 +55,7 @@ void SingleDataChecker::check(const QString &path, const Torrent &tor, const QSt
             // read the chunk
             const Uint32 size = i == num_chunks - 1 ? tor.getLastChunkSize() : tor.getChunkSize();
 
-            fptr.seek(File::BEGIN, (Int64)i * tor.getChunkSize());
+            fptr.seek(File::SeekPos::BEGIN, (Int64)i * tor.getChunkSize());
             fptr.read(buf.data(), size);
             // generate and test hash
             const SHA1Hash h = SHA1Hash::generate(buf.data(), size);
diff --git a/src/diskio/chunkmanager.cpp b/src/diskio/chunkmanager.cpp
index bf1bfa52..ccd7660b 100644
--- a/src/diskio/chunkmanager.cpp
+++ b/src/diskio/chunkmanager.cpp
@@ -896,7 +896,7 @@ void ChunkManager::Private::writeIndexFileEntry(Chunk *c)
         }
     }
 
-    fptr.seek(File::END, 0);
+    fptr.seek(File::SeekPos::END, 0);
     NewChunkHeader hdr;
     hdr.index = c->getIndex();
     fptr.write(&hdr, sizeof(NewChunkHeader));
@@ -916,8 +916,8 @@ void ChunkManager::Private::loadIndexFile()
         return;
     }
 
-    if (fptr.seek(File::END, 0) != 0) {
-        fptr.seek(File::BEGIN, 0);
+    if (fptr.seek(File::SeekPos::END, 0) != 0) {
+        fptr.seek(File::SeekPos::BEGIN, 0);
 
         while (!fptr.eof()) {
             NewChunkHeader hdr;
diff --git a/src/diskio/dndfile.cpp b/src/diskio/dndfile.cpp
index 487c6f9b..450710a8 100644
--- a/src/diskio/dndfile.cpp
+++ b/src/diskio/dndfile.cpp
@@ -89,7 +89,7 @@ Uint32 DNDFile::readFirstChunk(Uint8 *buf, Uint32 off, Uint32 size)
     }
 
     const Uint64 read_pos = sizeof(DNDFileHeader) + off;
-    if (fptr.seek(File::BEGIN, read_pos) != read_pos) {
+    if (fptr.seek(File::SeekPos::BEGIN, read_pos) != read_pos) {
         return 0;
     }
 
@@ -105,7 +105,7 @@ Uint32 DNDFile::readLastChunk(Uint8 *buf, Uint32 off, Uint32 size)
     }
 
     const Uint64 read_pos = sizeof(DNDFileHeader) + first_size + off;
-    if (fptr.seek(File::BEGIN, read_pos) != read_pos) {
+    if (fptr.seek(File::SeekPos::BEGIN, read_pos) != read_pos) {
         return 0;
     }
 
@@ -123,7 +123,7 @@ void DNDFile::writeFirstChunk(const Uint8 *buf, Uint32 off, Uint32 size)
     }
 
     // write data
-    fptr.seek(File::BEGIN, sizeof(DNDFileHeader) + off);
+    fptr.seek(File::SeekPos::BEGIN, sizeof(DNDFileHeader) + off);
     fptr.write(buf, size);
 }
 
@@ -137,7 +137,7 @@ void DNDFile::writeLastChunk(const Uint8 *buf, Uint32 off, Uint32 size)
         }
     }
 
-    fptr.seek(File::BEGIN, sizeof(DNDFileHeader) + first_size + off);
+    fptr.seek(File::SeekPos::BEGIN, sizeof(DNDFileHeader) + first_size + off);
     fptr.write(buf, size);
 }
 
diff --git a/src/diskio/multifilecache.cpp b/src/diskio/multifilecache.cpp
index c6cd55d7..a2954c91 100644
--- a/src/diskio/multifilecache.cpp
+++ b/src/diskio/multifilecache.cpp
@@ -673,7 +673,7 @@ void MultiFileCache::saveFirstAndLastChunk(TorrentFile *tf, const QString &src_f
 
         if (tf->getFirstChunk() != tf->getLastChunk()) {
             const Uint64 off = FileOffset(tf->getLastChunk(), *tf, tor.getChunkSize());
-            fptr.seek(File::BEGIN, off);
+            fptr.seek(File::SeekPos::BEGIN, off);
             fptr.read(tmp, tf->getLastChunkSize());
             out.writeLastChunk(tmp, 0, tf->getLastChunkSize());
         }
@@ -716,7 +716,7 @@ void MultiFileCache::recreateFile(TorrentFile *tf, const QString &dnd_file, cons
 
         if (tf->getFirstChunk() != tf->getLastChunk()) {
             const Uint64 off = FileOffset(tf->getLastChunk(), *tf, tor.getChunkSize());
-            fptr.seek(File::BEGIN, off);
+            fptr.seek(File::SeekPos::BEGIN, off);
             to_read = dnd.readLastChunk(tmp, 0, tf->getLastChunkSize());
             if (to_read > 0) {
                 fptr.write(tmp, to_read);
diff --git a/src/torrent/torrentcreator.cpp b/src/torrent/torrentcreator.cpp
index baa35bab..65d6cd3d 100644
--- a/src/torrent/torrentcreator.cpp
+++ b/src/torrent/torrentcreator.cpp
@@ -228,7 +228,7 @@ bool TorrentCreator::calcHashSingle()
     }
 
     const Uint32 s = cur_chunk != num_chunks - 1 ? chunk_size : last_size;
-    fptr.seek(File::BEGIN, (Int64)cur_chunk * chunk_size);
+    fptr.seek(File::SeekPos::BEGIN, (Int64)cur_chunk * chunk_size);
     fptr.read(buf.data(), s);
     const SHA1Hash h = SHA1Hash::generate(buf.data(), s);
     hashes.append(h);
@@ -281,7 +281,7 @@ bool TorrentCreator::calcHashMulti()
         }
 
         // read part of data
-        fptr.seek(File::BEGIN, (Int64)off);
+        fptr.seek(File::SeekPos::BEGIN, (Int64)off);
         fptr.read(buf.data() + read, to_read);
         read += to_read;
     }
diff --git a/src/util/file.cpp b/src/util/file.cpp
index 94e551f2..edafee8f 100644
--- a/src/util/file.cpp
+++ b/src/util/file.cpp
@@ -116,13 +116,13 @@ Uint64 File::seek(SeekPos from, Int64 num)
 
     int p = SEEK_CUR; // use a default to prevent compiler warning
     switch (from) {
-    case BEGIN:
+    case SeekPos::BEGIN:
         p = SEEK_SET;
         break;
-    case END:
+    case SeekPos::END:
         p = SEEK_END;
         break;
-    case CURRENT:
+    case SeekPos::CURRENT:
         p = SEEK_CUR;
         break;
     default:
diff --git a/src/util/file.h b/src/util/file.h
index f74f14a4..90ed85e2 100644
--- a/src/util/file.h
+++ b/src/util/file.h
@@ -98,7 +98,7 @@ public:
      * \var CURRENT
      * Seek from the current position, the number of bytes can be positive to seek forwards or negative to seek backwards.
      */
-    enum SeekPos {
+    enum class SeekPos {
         BEGIN,
         END,
         CURRENT,
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.