Skip to content

Commit

Permalink
PathContainsArchive -> FilepathContainsArchive (make platform-indepen…
Browse files Browse the repository at this point in the history
…dent)
  • Loading branch information
mholt committed Nov 28, 2024
1 parent a574a7e commit 00ef3ce
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -837,14 +837,15 @@ var archiveExtensions = []string{
".tar.lz",
}

// PathContainsArchive returns true if the path contains an archive file (i.e.
// FilepathContainsArchive returns true if the path contains an archive file (i.e.
// whether the path traverses into an archive) solely by lexical analysis (no
// reading of files or headers is performed). Such a path is not typically
// usable by the OS, but can be used by the DeepFS type. Example:
// "/foo/bar/example.zip/path/in/archive"
func PathContainsArchive(path string) bool {
// usable by the OS, but can be used by the DeepFS type. Examples:
// "/foo/example.zip/path/in/archive" or "C:\example.zip\path\in\archive"
func FilepathContainsArchive(path string) bool {
pathPlusSep := path + string(filepath.Separator)
for _, ext := range archiveExtensions {
if strings.Contains(path+"/", ext+"/") {
if strings.Contains(pathPlusSep, ext+string(filepath.Separator)) {
return true
}
}
Expand Down

0 comments on commit 00ef3ce

Please sign in to comment.