diff options
-rw-r--r-- | akode/lib/file.h | 2 | ||||
-rw-r--r-- | akode/lib/localfile.cpp | 8 | ||||
-rw-r--r-- | akode/lib/localfile.h | 2 | ||||
-rw-r--r-- | akode/lib/mmapfile.cpp | 8 | ||||
-rw-r--r-- | akode/lib/mmapfile.h | 2 |
5 files changed, 11 insertions, 11 deletions
diff --git a/akode/lib/file.h b/akode/lib/file.h index 11a4fef..3685bcc 100644 --- a/akode/lib/file.h +++ b/akode/lib/file.h @@ -76,7 +76,7 @@ public: * Seeks to the position. * Behaves semantically as lseek. */ - virtual bool seek(long to, int whence = SEEK_SET) = 0; + virtual ssize_t seek(long to, int whence = SEEK_SET) = 0; /*! * Returns current position in file, or negative if unknown. */ diff --git a/akode/lib/localfile.cpp b/akode/lib/localfile.cpp index ff92760..35ce2f3 100644 --- a/akode/lib/localfile.cpp +++ b/akode/lib/localfile.cpp @@ -115,11 +115,11 @@ long LocalFile::write(const char* ptr, long num) { return n; } -bool LocalFile::seek(long to, int whence) { - if(_fd == -1) return false; - int s = ::lseek(_fd, to, whence); +ssize_t LocalFile::seek(long to, int whence) { + if(_fd == -1) return -1; + ssize_t s = ::lseek(_fd, to, whence); if (s >= 0) pos = s; - return (s >= 0); + return s; } long LocalFile::position() const { diff --git a/akode/lib/localfile.h b/akode/lib/localfile.h index 7f7c2c2..9003e43 100644 --- a/akode/lib/localfile.h +++ b/akode/lib/localfile.h @@ -50,7 +50,7 @@ public: long read(char* ptr, long num); long write(const char* ptr, long num); - bool seek(long to, int whence = SEEK_SET); + ssize_t seek(long to, int whence = SEEK_SET); long position() const; long length() const; diff --git a/akode/lib/mmapfile.cpp b/akode/lib/mmapfile.cpp index 4c45603..ec45f98 100644 --- a/akode/lib/mmapfile.cpp +++ b/akode/lib/mmapfile.cpp @@ -94,7 +94,7 @@ long MMapFile::write(const char*, long) { return false; } -bool MMapFile::seek(long to, int whence) { +ssize_t MMapFile::seek(long to, int whence) { if(!handle) return false; long newpos = 0; @@ -109,12 +109,12 @@ bool MMapFile::seek(long to, int whence) { newpos = len + to; break; default: - return false; + return length(); } if (newpos > len || newpos < 0) - return false; + return -1; pos = newpos; - return true; + return newpos; } long MMapFile::position() const { diff --git a/akode/lib/mmapfile.h b/akode/lib/mmapfile.h index 80c5913..c2de99f 100644 --- a/akode/lib/mmapfile.h +++ b/akode/lib/mmapfile.h @@ -47,7 +47,7 @@ public: long read(char* ptr, long num); long write(const char*, long); - bool seek(long to, int whence = SEEK_SET); + ssize_t seek(long to, int whence = SEEK_SET); long position() const; long length() const; |