-
Notifications
You must be signed in to change notification settings - Fork 1
/
format.go
40 lines (35 loc) · 1.09 KB
/
format.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Copyright (c) 2015, Ben Morgan. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// Package alpm works with parts of Arch Linux packages.
package alpm
import "strings"
// PackageGlob is a glob that should only find packages.
const PackageGlob = "-*.pkg.tar*"
// HasDatabaseFormat returns true if the filename matches a pacman package
// format that we can do anything with.
//
// Currently, only the following formats are supported:
// .db.tar.gz
//
func HasDatabaseFormat(filename string) bool {
return strings.HasSuffix(filename, ".db.tar.gz")
}
// HasPackageFormat returns true if the filename matches a pacman package
// format that we can do anything with.
//
// Currently, only the following formats are supported:
// .pkg.tar
// .pkg.tar.xz
// .pkg.tar.gz
// .pkg.tar.bz2
// .pkg.tar.zst
//
func HasPackageFormat(filename string) bool {
for _, ext := range []string{".pkg.tar", ".pkg.tar.xz", ".pkg.tar.gz", ".pkg.tar.bz2", ".pkg.tar.zst"} {
if strings.HasSuffix(filename, ext) {
return true
}
}
return false
}