func executeMv(parameters []string, remainingCommand string, executor *ShellExecutor) []string { sourceFilePath := util.ResolvePath(executor.Cwd, parameters[0]) targetFilePath := util.ResolvePath(executor.Cwd, parameters[1]) ret := make([]string, 1) err := executor.Rfs.MoveFileOrFolder(sourceFilePath, targetFilePath) if err == nil { ret[0] = fmt.Sprintf("Moved %s to %s", sourceFilePath, targetFilePath) } else { ret[0] = fmt.Sprintf("Source path %s, Error %v", sourceFilePath, err) } return ret }
func executeAppendLine(parameters []string, remainingCommand string, executor *ShellExecutor) []string { filePath := util.ResolvePath(executor.Cwd, parameters[0]) executor.Rfs.AppendFile(filePath, []byte("\n"+remainingCommand)) ret := make([]string, 1) ret[0] = fmt.Sprintf("Appended with cr to file %s", filePath) return ret }
func executeAddFile(parameters []string, remainingCommand string, executor *ShellExecutor) []string { filePath := util.ResolvePath(executor.Cwd, parameters[0]) executor.Rfs.WriteFile(filePath, []byte(remainingCommand)) ret := make([]string, 1) ret[0] = fmt.Sprintf("Created file %s", filePath) return ret }
func executeCD(parameters []string, remainingCommand string, executor *ShellExecutor) []string { //fmt.Printf("Running CD with parameters %v, remainingCommand %s", parameters, remainingCommand) executor.Cwd = util.ResolvePath(executor.Cwd, parameters[0]) ret := make([]string, 1) ret[0] = "changed directory" return ret }
func executeRm(parameters []string, remainingCommand string, executor *ShellExecutor) []string { filePath := util.ResolvePath(executor.Cwd, parameters[0]) executor.Rfs.DeleteFile(filePath) ret := make([]string, 1) ret[0] = fmt.Sprintf("Removed %s", filePath) return ret }
func executeTags(parameters []string, remainingCommand string, executor *ShellExecutor) []string { filePath := util.ResolvePath(executor.Cwd, parameters[0]) verList, err := executor.Rfs.GetTags(filePath) if err != nil { return makeError(err) } return verList }
func executeStat(parameters []string, remainingCommand string, executor *ShellExecutor) []string { filePath := util.ResolvePath(executor.Cwd, parameters[0]) fileNode, err := executor.Rfs.StatFile(filePath) if err == nil { fullString := fmt.Sprintf("Size : %d\nAccessed : %v\nCreated : %v\nModified : %v\nBlocks: %v\nDefault Route: %v\n", fileNode.Stats.Size, fileNode.Stats.Accessed, fileNode.Stats.Created, fileNode.Stats.Modified, fileNode.DataBlocks, fileNode.DefaultRoute) return strings.Split(fullString, "\n") } else { return makeError(err) } }
func executeCatTag(parameters []string, remainingCommand string, executor *ShellExecutor) []string { filePath := util.ResolvePath(executor.Cwd, parameters[0]) arr, _ := executor.Rfs.ReadFileTag(filePath, parameters[1]) // Need to convert it into a string, then split on \n return strings.Split(string(arr), "\n") }
func executeLS(parameters []string, remainingCommand string, executor *ShellExecutor) []string { filePath := util.ResolvePath(executor.Cwd, parameters[0]) ret, _ := executor.Rfs.ListDirectory(filePath) return ret }