commit b05b6b7183a38ead8c47f637f48d21434fccf440 Author: Donnie Corbitt Date: Wed Jan 6 17:45:43 2021 -0600 Initial Commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5dd0907 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +test.go \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..b518c11 --- /dev/null +++ b/README.md @@ -0,0 +1,17 @@ +# Digby: The multi-compression application. +This is an application that allows you to compress to multiple compression systems all in one application. + +# Building: +run `go build main.go` and you're done! + +# Usage: +Run the executable and it'll ask you what file you are wanting to compress and where you'd like the output file to be. + +# Supported Compression Systems: +- gzip +- zlib + +# TODO: +- [ ] Have command line arguments +- [ ] Support things such a `*` for selecting multiple files +- [ ] Support compressing a folder \ No newline at end of file diff --git a/main.go b/main.go new file mode 100644 index 0000000..9d73de3 --- /dev/null +++ b/main.go @@ -0,0 +1,46 @@ +/* +Digby: A multi-file copmressor +*/ + +package main + +import ( + "bufio" + "compress/gzip" + "compress/zlib" + "fmt" + "io/ioutil" + "os" +) + +func main() { + // Asks user what file to compress and stores it as `file` + fmt.Printf("What file would you like to copmress: ") + var file string + fmt.Scanln(&file) + + // Asks user what dir to save the file. + fmt.Printf("\n\nWhat directory would you like to save your file: ") + var path string + fmt.Scanln(&path) + + fmt.Printf("\n\nWhat compression system: ") + var comp string + fmt.Scanln(&comp) + + // Compression shit + f, _ := os.Open(*&path + *&file) + read := bufio.NewReader(f) + data, _ := ioutil.ReadAll(read) + if *&comp == "gzip" { + f, _ = os.Create(*&path + *&file + ".gz") + w := gzip.NewWriter(f) + w.Write(data) + w.Close() + } else if *&comp == "zlib" { + f, _ = os.Create(*&path + *&file + ".zlib") + w := zlib.NewWriter(f) + w.Write(data) + w.Close() + } +} \ No newline at end of file