veyron/services/mgmt/binary/impl: rename merge_file package to multipart.

Also rename NewMergeFile to NewFile.

Change-Id: If331c15675ef9da65ed88d9d323668bd9ffda5a3
diff --git a/services/mgmt/binary/impl/http.go b/services/mgmt/binary/impl/http.go
index df6ec69..251ff00 100644
--- a/services/mgmt/binary/impl/http.go
+++ b/services/mgmt/binary/impl/http.go
@@ -8,7 +8,7 @@
 
 	"veyron.io/veyron/veyron2/vlog"
 
-	"veyron.io/veyron/veyron/services/mgmt/binary/impl/merge_file"
+	"veyron.io/veyron/veyron/services/mgmt/binary/impl/multipart"
 )
 
 // NewHTTPRoot returns an implementation of http.FileSystem that can be used
@@ -24,7 +24,7 @@
 // TODO(caprita): Tie this in with DownloadURL, to control which binaries
 // are downloadable via url.
 
-// Open implements http.FileSystem.  It uses the merge file implementation
+// Open implements http.FileSystem.  It uses the multipart file implementation
 // to wrap the content parts into one logical file.
 func (r httpRoot) Open(name string) (http.File, error) {
 	name = strings.TrimPrefix(name, "/")
@@ -45,5 +45,5 @@
 			return nil, errOperationFailed
 		}
 	}
-	return merge_file.NewMergeFile(name, partFiles)
+	return multipart.NewFile(name, partFiles)
 }
diff --git a/services/mgmt/binary/impl/merge_file/merge_file.go b/services/mgmt/binary/impl/multipart/multipart.go
similarity index 73%
rename from services/mgmt/binary/impl/merge_file/merge_file.go
rename to services/mgmt/binary/impl/multipart/multipart.go
index 06dd1a2..ab43178 100644
--- a/services/mgmt/binary/impl/merge_file/merge_file.go
+++ b/services/mgmt/binary/impl/multipart/multipart.go
@@ -1,9 +1,6 @@
-// merge_file provides an implementation for http.File that merges
-// several files into one logical file.
-package merge_file
-
-// TODO(caprita): rename this package to multipart, and the constructor to
-// NewFile. Usage: f, err := multipart.NewFile(...).
+// multipart provides an implementation for http.File that acts as one logical
+// file backed by several physical files (the 'parts').
+package multipart
 
 import (
 	"fmt"
@@ -15,11 +12,11 @@
 
 var internalErr = fmt.Errorf("internal error")
 
-// NewMergeFile creates the "merge" file out of the provided parts.
+// NewFile creates the multipart file out of the provided parts.
 // The sizes of the parts are captured at the outset and not updated
-// for the lifetime of the merge file (any subsequent modifications
+// for the lifetime of the multipart file (any subsequent modifications
 // in the parts will cause Read and Seek to work incorrectly).
-func NewMergeFile(name string, parts []*os.File) (http.File, error) {
+func NewFile(name string, parts []*os.File) (http.File, error) {
 	fileParts := make([]filePart, len(parts))
 	for i, p := range parts {
 		stat, err := p.Stat()
@@ -33,7 +30,7 @@
 		}
 		fileParts[i] = filePart{file: p, size: size}
 	}
-	return &mergeFile{name: name, parts: fileParts}, nil
+	return &multipartFile{name: name, parts: fileParts}, nil
 }
 
 type filePart struct {
@@ -41,14 +38,14 @@
 	size int64
 }
 
-type mergeFile struct {
+type multipartFile struct {
 	name       string
 	parts      []filePart
 	activePart int
 	partOffset int64
 }
 
-func (m *mergeFile) currPos() (res int64) {
+func (m *multipartFile) currPos() (res int64) {
 	for i := 0; i < m.activePart; i++ {
 		res += m.parts[i].size
 	}
@@ -56,7 +53,7 @@
 	return
 }
 
-func (m *mergeFile) totalSize() (res int64) {
+func (m *multipartFile) totalSize() (res int64) {
 	for _, p := range m.parts {
 		res += p.size
 	}
@@ -64,7 +61,7 @@
 }
 
 // Readdir is not implemented.
-func (*mergeFile) Readdir(int) ([]os.FileInfo, error) {
+func (*multipartFile) Readdir(int) ([]os.FileInfo, error) {
 	return nil, fmt.Errorf("Not implemented")
 }
 
@@ -75,12 +72,12 @@
 	modTime time.Time
 }
 
-// Name returns the name of the merge file.
+// Name returns the name of the multipart file.
 func (f *fileInfo) Name() string {
 	return f.name
 }
 
-// Size returns the size of the merge file (the sum of all parts).
+// Size returns the size of the multipart file (the sum of all parts).
 func (f *fileInfo) Size() int64 {
 	return f.size
 }
@@ -105,8 +102,8 @@
 	return nil
 }
 
-// Stat describes the merge file.
-func (m *mergeFile) Stat() (os.FileInfo, error) {
+// Stat describes the multipart file.
+func (m *multipartFile) Stat() (os.FileInfo, error) {
 	return &fileInfo{
 		name:    m.name,
 		size:    m.totalSize(),
@@ -116,7 +113,7 @@
 }
 
 // Close closes all the parts.
-func (m *mergeFile) Close() error {
+func (m *multipartFile) Close() error {
 	var lastErr error
 	for _, p := range m.parts {
 		if err := p.file.Close(); err != nil {
@@ -127,7 +124,7 @@
 }
 
 // Read reads from the parts in sequence.
-func (m *mergeFile) Read(buf []byte) (int, error) {
+func (m *multipartFile) Read(buf []byte) (int, error) {
 	if m.activePart >= len(m.parts) {
 		return 0, io.EOF
 	}
@@ -151,7 +148,7 @@
 }
 
 // Seek seeks into the part corresponding to the global offset.
-func (m *mergeFile) Seek(offset int64, whence int) (int64, error) {
+func (m *multipartFile) Seek(offset int64, whence int) (int64, error) {
 	var target int64
 	switch whence {
 	case 0:
diff --git a/services/mgmt/binary/impl/merge_file/merge_file_test.go b/services/mgmt/binary/impl/multipart/multipart_test.go
similarity index 91%
rename from services/mgmt/binary/impl/merge_file/merge_file_test.go
rename to services/mgmt/binary/impl/multipart/multipart_test.go
index 1d903a1..9866697 100644
--- a/services/mgmt/binary/impl/merge_file/merge_file_test.go
+++ b/services/mgmt/binary/impl/multipart/multipart_test.go
@@ -1,4 +1,4 @@
-package merge_file_test
+package multipart_test
 
 import (
 	"io"
@@ -10,7 +10,7 @@
 	"strings"
 	"testing"
 
-	"veyron.io/veyron/veyron/services/mgmt/binary/impl/merge_file"
+	"veyron.io/veyron/veyron/services/mgmt/binary/impl/multipart"
 )
 
 func read(t *testing.T, m http.File, thisMuch int) string {
@@ -32,11 +32,11 @@
 	}
 }
 
-// TestMergeFile verifies the http.File operations on the merge file.
-func TestMergeFile(t *testing.T) {
+// TestFile verifies the http.File operations on the multipart file.
+func TestFile(t *testing.T) {
 	contents := []string{"v", "is", "for", "vanadium"}
 	files := make([]*os.File, len(contents))
-	d, err := ioutil.TempDir("", "merge_files")
+	d, err := ioutil.TempDir("", "multiparts")
 	if err != nil {
 		t.Fatalf("TempDir() failed: %v", err)
 	}
@@ -53,9 +53,9 @@
 			t.Fatalf("Open(%v) failed: %v", fPath, err)
 		}
 	}
-	m, err := merge_file.NewMergeFile("bunnies", files)
+	m, err := multipart.NewFile("bunnies", files)
 	if err != nil {
-		t.Fatalf("newMergeFile failed: %v", err)
+		t.Fatalf("NewFile failed: %v", err)
 	}
 	defer func() {
 		if err := m.Close(); err != nil {