summaryrefslogtreecommitdiff
path: root/src/AbstractDiskWriter.h
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2012-07-23 21:36:24 +0900
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2012-07-23 21:42:47 +0900
commit860f4dd06ace859470e118d4b9a8d10ddf92d076 (patch)
tree1effdc3fd73160b57f5d6d109662a66e33050d08 /src/AbstractDiskWriter.h
parentf56743b0833551aa6845d0a4f1d05da02cb52175 (diff)
Use int64_t instead of off_t
Using off_t, at least, in DiskAdaptor layer is problematic because torrent can contain under 2GiB files but total sum of those files may exceed 2GiB limit, which makes off_t overflow in 32 bit system without large file support. So we use int64_t in API. We'll check the file length before download so that it does not exceed max off_t.
Diffstat (limited to 'src/AbstractDiskWriter.h')
-rw-r--r--src/AbstractDiskWriter.h24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/AbstractDiskWriter.h b/src/AbstractDiskWriter.h
index ee177f7c..8ba9292c 100644
--- a/src/AbstractDiskWriter.h
+++ b/src/AbstractDiskWriter.h
@@ -49,37 +49,37 @@ private:
bool enableMmap_;
unsigned char* mapaddr_;
- off_t maplen_;
+ int64_t maplen_;
ssize_t writeDataInternal(const unsigned char* data, size_t len,
- off_t offset);
- ssize_t readDataInternal(unsigned char* data, size_t len, off_t offset);
+ int64_t offset);
+ ssize_t readDataInternal(unsigned char* data, size_t len, int64_t offset);
- void seek(off_t offset);
+ void seek(int64_t offset);
- void ensureMmapWrite(size_t len, off_t offset);
+ void ensureMmapWrite(size_t len, int64_t offset);
protected:
void createFile(int addFlags = 0);
public:
AbstractDiskWriter(const std::string& filename);
virtual ~AbstractDiskWriter();
- virtual void openFile(off_t totalLength = 0);
+ virtual void openFile(int64_t totalLength = 0);
virtual void closeFile();
- virtual void openExistingFile(off_t totalLength = 0);
+ virtual void openExistingFile(int64_t totalLength = 0);
- virtual void writeData(const unsigned char* data, size_t len, off_t offset);
+ virtual void writeData(const unsigned char* data, size_t len, int64_t offset);
- virtual ssize_t readData(unsigned char* data, size_t len, off_t offset);
+ virtual ssize_t readData(unsigned char* data, size_t len, int64_t offset);
- virtual void truncate(off_t length);
+ virtual void truncate(int64_t length);
// File must be opened before calling this function.
- virtual void allocate(off_t offset, off_t length);
+ virtual void allocate(int64_t offset, int64_t length);
- virtual off_t size();
+ virtual int64_t size();
virtual void enableReadOnly();