github.com/mvdan/u-root-coreutils@v0.0.0-20230122170626-c2eef2898555/cmds/core/ls/ls_unix.go (about)

     1  // Copyright 2021 the u-root Authors. All rights reserved
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  //go:build !plan9 && !windows
     6  // +build !plan9,!windows
     7  
     8  package main
     9  
    10  import (
    11  	"fmt"
    12  	"io"
    13  	"strings"
    14  
    15  	"github.com/mvdan/u-root-coreutils/pkg/ls"
    16  )
    17  
    18  func printFile(w io.Writer, stringer ls.Stringer, f file) {
    19  	if f.err != nil {
    20  		fmt.Fprintln(w, f.err)
    21  		return
    22  	}
    23  	// Hide .files unless -a was given
    24  	if *all || !strings.HasPrefix(f.lsfi.Name, ".") {
    25  		// Print the file in the proper format.
    26  		if *classify {
    27  			f.lsfi.Name = f.lsfi.Name + indicator(f.lsfi)
    28  		}
    29  		fmt.Fprintln(w, stringer.FileString(f.lsfi))
    30  	}
    31  }