12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- package main
- import (
- "fmt"
- "os"
- )
- func check(e error) {
- if e != nil {
- panic(e)
- }
- }
- func init() {
- setting, err := os.Create("setting.config")
- check(err)
- defer setting.Close()
- setting.WriteString("")
- setting.Sync()
- }
- func file_exists(filepath string) bool {
- if _, err := os.Stat(filepath); !os.IsNotExist(err) {
- return true
- }
- return false
- }
- func mkdir(filepath string){
- os.MkdirAll(filepath, os.ModePerm)
- }
- func file_put_contents(file string, data string) bool{
- f, err := os.Create(file)
- check(err)
- _, err = f.WriteString(data)
- defer f.Close()
- if (err != nil){
- return false
- }
- return true
- }
- func main() {
- //arozdfs implementation in Golang
- /*
- Supported commands:
- help --> show all the help information
- init --> initiate the arozdfs structure according to setup.config
- [Uploading to arozdfs commands]
- upload
- -infile <filename> --> declare the input file
- -storepath <pathname> --> Relative path from the arozdfs root
- -slice <filesize> --> declare the slicing filesize
- -push <clusterlist.config> --> push to a list of clusters and sync file index to other clusters
- [Download from arozdfs commands]
- download
- -outfile <file.index> --> rebuild a file from cluster storage to local drive
-
- [File Operations]
- remove <file.index> --> remove all chunks related to thie file index
- rename <file.index> <newfile.index> --> rename all records related to this file
- move <filepath/file.index> <newpath/file.index> --> move the file to a new path in index directory
- [System checking commands]
- checkfile <file.index> --> check if a file contains all chunks which has at least two copies of each chunks
- rebuild --> Check all files on the system and fix all chunks which has corrupted
- migrate <host-uuid>
- */
- for i, arg := range os.Args {
- // print index and value
- fmt.Println("item", i, "is", arg)
- }
-
- //Check if the required directory exists. If not, create it.
- if (!file_exists("chunks/")){
- mkdir("chunks/")
- }
- if (!file_exists("uploads/")){
- mkdir("uploads/")
- }
- file_put_contents("Hello World.txt","This is the content of the file.")
- }
|