github.com/TrueBlocks/trueblocks-core/src/apps/chifra@v0.0.0-20241022031540-b362680128f7/pkg/file/exists.go (about)

     1  // Copyright 2021 The TrueBlocks Authors. All rights reserved.
     2  // Use of this source code is governed by a license that can
     3  // be found in the LICENSE file.
     4  
     5  package file
     6  
     7  import (
     8  	"os"
     9  )
    10  
    11  func FileExists(filename string) bool {
    12  	info, err := os.Stat(filename)
    13  	if os.IsNotExist(err) {
    14  		return false
    15  	}
    16  	return !info.IsDir()
    17  }
    18  
    19  func FolderExists(path string) bool {
    20  	info, err := os.Stat(path)
    21  	if os.IsNotExist(err) {
    22  		return false
    23  	}
    24  	return info.IsDir()
    25  }