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 --> declare the input file -storepath --> Relative path from the arozdfs root -slice --> declare the slicing filesize -push --> push to a list of clusters and sync file index to other clusters [Download from arozdfs commands] download -outfile --> rebuild a file from cluster storage to local drive [File Operations] remove --> remove all chunks related to thie file index rename --> rename all records related to this file move --> move the file to a new path in index directory [System checking commands] checkfile --> 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 */ 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.") }