Example #1
0
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
}
Example #2
0
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
}
Example #3
0
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
}
Example #4
0
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
}
Example #5
0
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
}
Example #6
0
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
}
Example #7
0
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)
	}
}
Example #8
0
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")
}
Example #9
0
func executeLS(parameters []string, remainingCommand string, executor *ShellExecutor) []string {
	filePath := util.ResolvePath(executor.Cwd, parameters[0])
	ret, _ := executor.Rfs.ListDirectory(filePath)
	return ret
}