Skip to content

Commit

Permalink
Commit because I could not face losing any work at this stage
Browse files Browse the repository at this point in the history
  • Loading branch information
thewalla07 committed Mar 17, 2016
1 parent 9b4261d commit 21a0e07
Show file tree
Hide file tree
Showing 4 changed files with 222 additions and 119 deletions.
42 changes: 38 additions & 4 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ func setup(r *bufio.Reader, w *bufio.Writer, thisUser *utils.User) (err error) {
} else {

err = utils.FileToStruct(utils.GetUserHome()+"/.mdfs/client/"+uname+"/.user_data", &thisUser)

}

return err
Expand Down Expand Up @@ -129,6 +130,10 @@ func main() {
panic(err)
}

idStr := strconv.FormatUint(thisUser.Uuid, 10)
w.WriteString(idStr + "\n")
w.Flush()

// assume we will always start in the root directory (for safety)
currentDir := "/"
reader := bufio.NewReader(os.Stdin)
Expand Down Expand Up @@ -433,6 +438,10 @@ func cd(r *bufio.Reader, w *bufio.Writer, currentDir *string, args []string) (er

fmt.Println("Not a directory")

} else if isDir == 2 {

fmt.Println("Permission denied")

} else { // success!

// get the new currentDir and clean up the end
Expand Down Expand Up @@ -989,6 +998,8 @@ func listGroups(r *bufio.Reader, w *bufio.Writer, args []string, thisUser *utils
w.WriteByte(25)
w.Flush()

verbose := false

if len(args) == 1 { // sendcode 25

w.WriteByte(3)
Expand All @@ -1007,13 +1018,33 @@ func listGroups(r *bufio.Reader, w *bufio.Writer, args []string, thisUser *utils
w.WriteByte(2)
w.Flush()

case "-mV": // sendcode 26
fmt.Println("You are a member of the following groups:")
w.WriteByte(1)
w.Flush()
verbose = true

case "-oV": // sendcode 27
fmt.Println("You are the owner of the following groups:")
w.WriteByte(2)
w.Flush()
verbose = true

case "-V": // sendcode 27
fmt.Println("You are the owner of the following groups:")
w.WriteByte(3)
w.Flush()
verbose = true

default:
w.WriteByte(4)
w.Flush()
fmt.Println("Not valid arguments to list-groups:")
fmt.Println("Format should be one of:")
fmt.Println("list-groups -m")
fmt.Println("list-groups -mV")
fmt.Println("list-groups -o")
fmt.Println("list-groups -oV")
fmt.Println("list-groups")
return nil
}
Expand All @@ -1029,11 +1060,14 @@ func listGroups(r *bufio.Reader, w *bufio.Writer, args []string, thisUser *utils
group, _ := r.ReadString('\n')
groupArr := strings.Split(strings.TrimSuffix(strings.TrimSpace(group), ","), ",")

fmt.Print("Name: " + groupArr[0] + "\tID: " + groupArr[1] + "\tMembers: ")
fmt.Print("Name: " + groupArr[0] + "\tID: " + groupArr[1])

for i, v := range groupArr {
if i > 1 {
fmt.Print(v + ", ")
if verbose {
fmt.Print("\tMembers: ")
for i, v := range groupArr {
if i > 1 {
fmt.Print(v + ", ")
}
}
}
fmt.Println()
Expand Down
Loading

0 comments on commit 21a0e07

Please sign in to comment.