Initial Commit
This commit is contained in:
commit
b05b6b7183
|
@ -0,0 +1 @@
|
||||||
|
test.go
|
|
@ -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
|
|
@ -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()
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue