2 // Armadillo File Manager
3 // Copyright (c) 2010, Robert Sesek <http://www.bluestatic.org>
5 // This program is free software: you can redistribute it and/or modify it under
6 // the terms of the GNU General Public License as published by the Free Software
7 // Foundation, either version 3 of the License, or any later version.
20 func canonicalizePath(raw_path string) string {
21 raw_path = path.Join(JailRoot, raw_path)
22 return path.Clean(raw_path)
25 func checkInJail(path string) bool {
29 func List(the_path string) (files vector.StringVector, err os.Error) {
30 full_path := canonicalizePath(the_path)
31 if !checkInJail(full_path) {
32 return nil, os.NewError("path outside of jail")
35 fd, file_error := os.Open(full_path, os.O_RDONLY, 0)
36 if file_error != nil {
37 return nil, file_error
40 fileinfos, read_err := fd.Readdir(-1)
45 for _, info := range fileinfos {
47 if info.IsDirectory() {