my computer is about to die!!!

This commit is contained in:
didier.amyot committed 2014-11-01 16:00:06 -07:00
1 parent d863dc3bd1
commit e80f2601ab
13 files changed
+244 -11

No files matched your search

+39
View File
@@ -0,0 +1,39 @@
package files
import (
"fmt"
"io"
"os"
"github.com/didiercrunch/filou/contract"
)
var _ = fmt.Print
type encryptor func(reader io.Reader, writer io.Writer, acceptedContract *contract.AcceptedContract) error
type PathEncryptor struct {
EncryptFile encryptor
EncryptDirectory encryptor
}
func (this *PathEncryptor) EncryptPath(path string, writer io.Writer, acceptedContract *contract.AcceptedContract) error {
f, err := os.Open(path)
if err != nil {
return err
}
defer func() {
if err := f.Close(); err != nil {
panic(err)
}
}()
if fd, err := f.Stat(); err != nil {
return err
} else if fd.IsDir() {
return this.EncryptDirectory(f, writer, acceptedContract)
} else {
return this.EncryptFile(f, writer, acceptedContract)
}
}