Mercurial > gemma
comparison pkg/common/zip.go @ 1225:4d7c44f7044e
Factored out som zip lookup code to be reusable in sounding result upload controller.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Mon, 19 Nov 2018 17:28:35 +0100 |
parents | |
children | 6a021108410b |
comparison
equal
deleted
inserted
replaced
1224:bc4b642c8d04 | 1225:4d7c44f7044e |
---|---|
1 // This is Free Software under GNU Affero General Public License v >= 3.0 | |
2 // without warranty, see README.md and license for details. | |
3 // | |
4 // SPDX-License-Identifier: AGPL-3.0-or-later | |
5 // License-Filename: LICENSES/AGPL-3.0.txt | |
6 // | |
7 // Copyright (C) 2018 by via donau | |
8 // – Österreichische Wasserstraßen-Gesellschaft mbH | |
9 // Software engineering by Intevation GmbH | |
10 // | |
11 // Author(s): | |
12 // * Sascha L. Teichmann <sascha.teichmann@intevation.de> | |
13 | |
14 package common | |
15 | |
16 import ( | |
17 "archive/zip" | |
18 "strings" | |
19 ) | |
20 | |
21 func FindInZIP(z *zip.ReadCloser, needle string) *zip.File { | |
22 needle = strings.ToLower(needle) | |
23 for _, straw := range z.File { | |
24 if strings.HasSuffix(strings.ToLower(straw.Name), needle) { | |
25 return straw | |
26 } | |
27 } | |
28 return nil | |
29 } |