1
// Copyright 2014 Canonical Ltd.
2
// Licensed under the LGPLv3, see LICENCE file for details.
12
// isNotExist returns true if the error is consistent with an attempt to
13
// reference a file that does not exist. This works around the occasionally
14
// unhelpful behaviour of os.IsNotExist, which does not recognise the error
15
// produced when trying to read a path in which some component appears to
16
// reference a directory but actually references a file. For example, if
17
// "foo" is a file, an attempt to read "foo/bar" will generate an error that
18
// does not satisfy os.IsNotExist, but will satisfy filetesting.isNotExist.
19
func isNotExist(err error) bool {
20
if os.IsNotExist(err) {
23
if e, ok := err.(*os.PathError); ok && e.Err == syscall.ENOTDIR {