]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Rename some of the unexported file storage types
authorMatt Joiner <anacrolix@gmail.com>
Mon, 12 Sep 2016 07:26:39 +0000 (17:26 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Mon, 12 Sep 2016 07:26:39 +0000 (17:26 +1000)
storage/file.go
storage/file_storage_piece.go

index cee96e61852d838292f589a5e64f6994c90071bd..de14c2bb66529d750e80104a812f367e18057293 100644 (file)
@@ -13,22 +13,22 @@ import (
 
 // File-based storage for torrents, that isn't yet bound to a particular
 // torrent.
-type fileStorage struct {
+type fileClientImpl struct {
        baseDir string
 }
 
 func NewFile(baseDir string) ClientImpl {
-       return &fileStorage{
+       return &fileClientImpl{
                baseDir: baseDir,
        }
 }
 
-func (fs *fileStorage) OpenTorrent(info *metainfo.Info, infoHash metainfo.Hash) (TorrentImpl, error) {
+func (fs *fileClientImpl) OpenTorrent(info *metainfo.Info, infoHash metainfo.Hash) (TorrentImpl, error) {
        err := CreateNativeZeroLengthFiles(info, fs.baseDir)
        if err != nil {
                return nil, err
        }
-       return &fileTorrentStorage{
+       return &fileTorrentImpl{
                fs,
                info,
                infoHash,
@@ -37,16 +37,16 @@ func (fs *fileStorage) OpenTorrent(info *metainfo.Info, infoHash metainfo.Hash)
 }
 
 // File-based torrent storage, not yet bound to a Torrent.
-type fileTorrentStorage struct {
-       fs         *fileStorage
+type fileTorrentImpl struct {
+       fs         *fileClientImpl
        info       *metainfo.Info
        infoHash   metainfo.Hash
        completion pieceCompletion
 }
 
-func (fts *fileTorrentStorage) Piece(p metainfo.Piece) PieceImpl {
+func (fts *fileTorrentImpl) Piece(p metainfo.Piece) PieceImpl {
        // Create a view onto the file-based torrent storage.
-       _io := fileStorageTorrent{fts}
+       _io := fileTorrentImplIO{fts}
        // Return the appropriate segments of this.
        return &fileStoragePiece{
                fts,
@@ -56,7 +56,7 @@ func (fts *fileTorrentStorage) Piece(p metainfo.Piece) PieceImpl {
        }
 }
 
-func (fs *fileTorrentStorage) Close() error {
+func (fs *fileTorrentImpl) Close() error {
        fs.completion.Close()
        return nil
 }
@@ -82,12 +82,12 @@ func CreateNativeZeroLengthFiles(info *metainfo.Info, baseDir string) (err error
 }
 
 // Exposes file-based storage of a torrent, as one big ReadWriterAt.
-type fileStorageTorrent struct {
-       fts *fileTorrentStorage
+type fileTorrentImplIO struct {
+       fts *fileTorrentImpl
 }
 
 // Returns EOF on short or missing file.
-func (fst *fileStorageTorrent) readFileAt(fi metainfo.FileInfo, b []byte, off int64) (n int, err error) {
+func (fst *fileTorrentImplIO) readFileAt(fi metainfo.FileInfo, b []byte, off int64) (n int, err error) {
        f, err := os.Open(fst.fts.fileInfoName(fi))
        if os.IsNotExist(err) {
                // File missing is treated the same as a short file.
@@ -116,7 +116,7 @@ func (fst *fileStorageTorrent) readFileAt(fi metainfo.FileInfo, b []byte, off in
 }
 
 // Only returns EOF at the end of the torrent. Premature EOF is ErrUnexpectedEOF.
-func (fst fileStorageTorrent) ReadAt(b []byte, off int64) (n int, err error) {
+func (fst fileTorrentImplIO) ReadAt(b []byte, off int64) (n int, err error) {
        for _, fi := range fst.fts.info.UpvertedFiles() {
                for off < fi.Length {
                        n1, err1 := fst.readFileAt(fi, b, off)
@@ -144,7 +144,7 @@ func (fst fileStorageTorrent) ReadAt(b []byte, off int64) (n int, err error) {
        return
 }
 
-func (fst fileStorageTorrent) WriteAt(p []byte, off int64) (n int, err error) {
+func (fst fileTorrentImplIO) WriteAt(p []byte, off int64) (n int, err error) {
        for _, fi := range fst.fts.info.UpvertedFiles() {
                if off >= fi.Length {
                        off -= fi.Length
@@ -176,6 +176,6 @@ func (fst fileStorageTorrent) WriteAt(p []byte, off int64) (n int, err error) {
        return
 }
 
-func (fts *fileTorrentStorage) fileInfoName(fi metainfo.FileInfo) string {
+func (fts *fileTorrentImpl) fileInfoName(fi metainfo.FileInfo) string {
        return filepath.Join(append([]string{fts.fs.baseDir, fts.info.Name}, fi.Path...)...)
 }
index 5dce1ea391988ccea655084d706bd115ec4c6ac2..321440a713543e7b3f1d443980b4a23d94f874a8 100644 (file)
@@ -8,7 +8,7 @@ import (
 )
 
 type fileStoragePiece struct {
-       *fileTorrentStorage
+       *fileTorrentImpl
        p metainfo.Piece
        io.WriterAt
        io.ReaderAt