Skip to content
This repository has been archived by the owner on Apr 26, 2021. It is now read-only.

Commit

Permalink
Use path.Join(a, b) instead of a + "/" + b
Browse files Browse the repository at this point in the history
  • Loading branch information
scorphus committed Aug 14, 2014
1 parent 1ad1c7c commit 3b62a6a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions multipartzip/multipartzip.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func CopyZipFile(f *zip.File, d, p string) error {
if p != "" {
dirname := path.Dir(p)
if dirname != "." {
err := os.MkdirAll(d+"/"+dirname, 0755)
err := os.MkdirAll(path.Join(d, dirname), 0755)
if err != nil {
return err
}
Expand All @@ -53,7 +53,7 @@ func CopyZipFile(f *zip.File, d, p string) error {
if err != nil {
return err
}
path := d + "/" + p
path := path.Join(d, p)
stat, err := os.Stat(path)
if err != nil || !stat.IsDir() {
file, err := fs.Filesystem().OpenFile(path, os.O_WRONLY|os.O_CREATE, 0755)
Expand Down
5 changes: 3 additions & 2 deletions multipartzip/multipartzip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"launchpad.net/gocheck"
"mime/multipart"
"os"
"path"
"testing"
)

Expand Down Expand Up @@ -44,7 +45,7 @@ func (s *S) TestCopyZipFile(c *gocheck.C) {
for _, f := range r.File {
err = CopyZipFile(f, tempDir, f.Name)
c.Assert(err, gocheck.IsNil)
fstat, errStat := os.Stat(tempDir + "/" + f.Name)
fstat, errStat := os.Stat(path.Join(tempDir, f.Name))
c.Assert(errStat, gocheck.IsNil)
c.Assert(fstat.IsDir(), gocheck.Equals, false)
}
Expand Down Expand Up @@ -76,7 +77,7 @@ func (s *S) TestExtractZip(c *gocheck.C) {
c.Assert(err, gocheck.IsNil)
ExtractZip(formfile, tempDir)
for _, file := range files {
body, err := ioutil.ReadFile(tempDir + "/" + file.Name)
body, err := ioutil.ReadFile(path.Join(tempDir, file.Name))
c.Assert(err, gocheck.IsNil)
c.Assert(string(body), gocheck.Equals, file.Body)
}
Expand Down
10 changes: 5 additions & 5 deletions repository/repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1182,7 +1182,7 @@ func (s *S) TestTempCloneIntegration(c *gocheck.C) {
c.Assert(errClone, gocheck.IsNil)
dstat, errStat := os.Stat(clone)
c.Assert(dstat.IsDir(), gocheck.Equals, true)
fstat, errStat := os.Stat(clone + "/" + file)
fstat, errStat := os.Stat(path.Join(clone, file))
c.Assert(fstat.IsDir(), gocheck.Equals, false)
c.Assert(errStat, gocheck.IsNil)
}
Expand Down Expand Up @@ -1219,7 +1219,7 @@ func (s *S) TestTempCloneWhenGitError(c *gocheck.C) {
c.Assert(errClone.Error(), gocheck.Equals, expectedErr)
dstat, errStat := os.Stat(clone)
c.Assert(dstat.IsDir(), gocheck.Equals, true)
fstat, errStat := os.Stat(clone + "/" + file)
fstat, errStat := os.Stat(path.Join(clone, file))
c.Assert(fstat, gocheck.IsNil)
c.Assert(errStat, gocheck.NotNil)
}
Expand Down Expand Up @@ -1429,7 +1429,7 @@ func (s *S) TestAddAllIntegration(c *gocheck.C) {
defer cloneCleanUp()
}
c.Assert(errClone, gocheck.IsNil)
errWrite := ioutil.WriteFile(clone+"/"+file, []byte(content+content), 0644)
errWrite := ioutil.WriteFile(path.Join(clone, file), []byte(content+content), 0644)
c.Assert(errWrite, gocheck.IsNil)
errWrite = ioutil.WriteFile(clone+"/WOWME", []byte(content+content), 0644)
c.Assert(errWrite, gocheck.IsNil)
Expand Down Expand Up @@ -1494,7 +1494,7 @@ func (s *S) TestCommitIntegration(c *gocheck.C) {
defer cloneCleanUp()
}
c.Assert(errClone, gocheck.IsNil)
errWrite := ioutil.WriteFile(clone+"/"+file, []byte(content+content), 0644)
errWrite := ioutil.WriteFile(path.Join(clone, file), []byte(content+content), 0644)
c.Assert(errWrite, gocheck.IsNil)
gitPath, err := exec.LookPath("git")
c.Assert(err, gocheck.IsNil)
Expand Down Expand Up @@ -1582,7 +1582,7 @@ func (s *S) TestPushIntegration(c *gocheck.C) {
defer cloneCleanUp()
}
c.Assert(errClone, gocheck.IsNil)
errWrite := ioutil.WriteFile(clone+"/"+file, []byte(content+content), 0644)
errWrite := ioutil.WriteFile(path.Join(clone, file), []byte(content+content), 0644)
c.Assert(errWrite, gocheck.IsNil)
errAddAll := AddAll(clone)
c.Assert(errAddAll, gocheck.IsNil)
Expand Down

0 comments on commit 3b62a6a

Please sign in to comment.