// ParseFile parses passfile entries contained in file.
ParseFile parses passfile entries contained in file.
// ParseFile parses passfile entries contained in file .
func ParseFile(file string) ([]Entry, error) {
	fi, err := os.Stat(file)
	switch {
	case err != nil && os.IsNotExist(err):
		return nil, nil
	case err != nil:
		return nil, &FileError{file, err}
	case fi.IsDir():
		return nil, &FileError{file, ErrMustNotBeDirectory}
	case runtime.GOOS != "windows" && fi.Mode()&0x3f != 0:
		return nil, &FileError{file, ErrHasGroupOrWorldAccess}
	}
	f, err := os.OpenFile(file, os.O_RDONLY, 0)
	if err != nil {
		return nil, &FileError{file, err}
	}
	entries, err := Parse(f)
	if err != nil {
		defer f.Close()
		return nil, &FileError{file, err}
	}
	if err := f.Close(); err != nil {
		return nil, &FileError{file, err}
	}
	return entries, nil
}
func ParseFile ( file string ) ( [ ] Entry , error ) { fi , err := os . Stat ( file ) switch { case err != nil && os . IsNotExist ( err ) : return nil , nil case err != nil : return nil , & FileError { file , err } case fi . IsDir ( ) : return nil , & FileError { file , ErrMustNotBeDirectory } case runtime . GOOS != " " && fi . Mode ( ) & 0x3f != 0 : return nil , & FileError { file , ErrHasGroupOrWorldAccess } } f , err := os . OpenFile ( file , os . O_RDONLY , 0 ) if err != nil { return nil , & FileError { file , err } } entries , err := Parse ( f ) if err != nil { defer f . Close ( ) return nil , & FileError { file , err } } if err := f . Close ( ) ; err != nil { return nil , & FileError { file , err } } return entries , nil }
ParseFile parses passfile entries contained in file.
ParseFile parses passfile entries contained in file .
// ensure not a directory // ensure  not group/world readable/writable/executable // open // parse