| OLD | NEW |
| 1 package filetilestore | 1 package filetilestore |
| 2 | 2 |
| 3 import ( | 3 import ( |
| 4 "encoding/gob" | 4 "encoding/gob" |
| 5 "fmt" | 5 "fmt" |
| 6 "os" | 6 "os" |
| 7 "path" | 7 "path" |
| 8 "path/filepath" | 8 "path/filepath" |
| 9 "sort" | 9 "sort" |
| 10 "strconv" | 10 "strconv" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 return nil, err | 84 return nil, err |
| 85 } | 85 } |
| 86 f, err := os.Open(filename) | 86 f, err := os.Open(filename) |
| 87 if err != nil { | 87 if err != nil { |
| 88 return nil, fmt.Errorf("Failed to open tile %s for reading: %s",
filename, err) | 88 return nil, fmt.Errorf("Failed to open tile %s for reading: %s",
filename, err) |
| 89 } | 89 } |
| 90 defer f.Close() | 90 defer f.Close() |
| 91 t := types.NewTile() | 91 t := types.NewTile() |
| 92 dec := gob.NewDecoder(f) | 92 dec := gob.NewDecoder(f) |
| 93 if err := dec.Decode(t); err != nil { | 93 if err := dec.Decode(t); err != nil { |
| 94 » » return nil, fmt.Errorf("Failed to dencode tile %s: %s", filename
, err) | 94 » » return nil, fmt.Errorf("Failed to decode tile %s: %s", filename,
err) |
| 95 } | 95 } |
| 96 | 96 |
| 97 return t, nil | 97 return t, nil |
| 98 } | 98 } |
| 99 | 99 |
| 100 // NewFileTileStore creates a new TileStore that is back by the file system, | 100 // NewFileTileStore creates a new TileStore that is backed by the file system, |
| 101 // where dir is the directory name and datasetName is the name of the dataset. | 101 // where dir is the directory name and datasetName is the name of the dataset. |
| 102 func NewFileTileStore(dir, datasetName string) types.TileStore { | 102 func NewFileTileStore(dir, datasetName string) types.TileStore { |
| 103 return FileTileStore{ | 103 return FileTileStore{ |
| 104 dir: dir, | 104 dir: dir, |
| 105 datasetName: datasetName, | 105 datasetName: datasetName, |
| 106 } | 106 } |
| 107 } | 107 } |
| OLD | NEW |