func (ip *FileIP) Exists() bool {
	exists := false
	ip.lock.Lock()
	if _, err := os.Stat(ip.Path()); err == nil {
		exists = true
	}
	ip.lock.Unlock()
	return exists
}
Exists checks if the file exists (at its final file name)
package scipipe
import (
	"bytes"
	"encoding/json"
	"errors"
	"fmt"
	"io/ioutil"
	"os"
	"os/exec"
	"path/filepath"
	"regexp"
	"strings"
	"sync"
	"time"
)
type IP interface {
	ID() string
	FinalizePath()
}
type BaseIP struct {
	path      string
	id        string
	auditInfo *AuditInfo
}
func NewBaseIP(path string) *BaseIP {
	return &BaseIP{
		path: path,
		id:   randSeqLC(20),
	}
}
func (ip *BaseIP) ID() string {
	return ip.id
}
type FileIP struct {
	*BaseIP
	buffer    *bytes.Buffer
	doStream  bool
	lock      *sync.Mutex
	SubStream *InPort
}
func NewFileIP(path string) (*FileIP, error) {
	isValid, err := pathIsValid(path)
	if err != nil {
		return nil, err
	}
	if !isValid {
		return nil, errors.New(fmt.Sprintf(`Could not create new FileIP with filename "%s". File is invalid (perhaps contains invalid characters)`, path))
	}
	ip := &FileIP{
		BaseIP:    NewBaseIP(path),
		lock:      &sync.Mutex{},
		SubStream: NewInPort("in_substream"),
	}
	if ip.Exists() {
		ip.AuditInfo()  
	}
	return ip, nil
}
func pathIsValid(path string) (bool, error) {
	expr := `^[0-9A-Za-z\/\.\-_]+$`
	ptn, err := regexp.Compile(expr)
	if err != nil {
		return false, errors.New("Could not compile regex")
	}
	return ptn.MatchString(path), nil
}
func (ip *FileIP) Path() string {
	return ip.path
}
func (ip *FileIP) TempDir() string {
	return filepath.Dir(ip.TempPath())
}
func (ip *FileIP) TempPath() string {
	path := replaceParentDirsWithPlaceholder(ip.path)
	if path[0] == '/' {
		return FSRootPlaceHolder + path
	}
	return path
}
const FSRootPlaceHolder = "__fsroot__"
func (ip *FileIP) FifoPath() string {
	return ip.path + ".fifo"
}
func (ip *FileIP) Size() int64 {
	fi, err := os.Stat(ip.path)
	Check(err)
	return fi.Size()
}