From 9017024f6e3886e61ac040d2f2de265c6e47e278 Mon Sep 17 00:00:00 2001 From: John Howard Date: Fri, 18 Sep 2015 13:39:12 -0700 Subject: [PATCH] Windows: Fix warning on info Signed-off-by: John Howard --- fileutils/fileutils.go | 12 ------------ fileutils/fileutils_unix.go | 22 ++++++++++++++++++++++ fileutils/fileutils_windows.go | 7 +++++++ 3 files changed, 29 insertions(+), 12 deletions(-) create mode 100644 fileutils/fileutils_unix.go create mode 100644 fileutils/fileutils_windows.go diff --git a/fileutils/fileutils.go b/fileutils/fileutils.go index 3eaf7f8..08b9840 100644 --- a/fileutils/fileutils.go +++ b/fileutils/fileutils.go @@ -4,7 +4,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "os" "path/filepath" "strings" @@ -143,17 +142,6 @@ func CopyFile(src, dst string) (int64, error) { return io.Copy(df, sf) } -// GetTotalUsedFds Returns the number of used File Descriptors by -// reading it via /proc filesystem. -func GetTotalUsedFds() int { - if fds, err := ioutil.ReadDir(fmt.Sprintf("/proc/%d/fd", os.Getpid())); err != nil { - logrus.Errorf("Error opening /proc/%d/fd: %s", os.Getpid(), err) - } else { - return len(fds) - } - return -1 -} - // ReadSymlinkedDirectory returns the target directory of a symlink. // The target of the symbolic link may not be a file. func ReadSymlinkedDirectory(path string) (string, error) { diff --git a/fileutils/fileutils_unix.go b/fileutils/fileutils_unix.go new file mode 100644 index 0000000..d5c3abf --- /dev/null +++ b/fileutils/fileutils_unix.go @@ -0,0 +1,22 @@ +// +build linux freebsd + +package fileutils + +import ( + "fmt" + "io/ioutil" + "os" + + "github.com/Sirupsen/logrus" +) + +// GetTotalUsedFds Returns the number of used File Descriptors by +// reading it via /proc filesystem. +func GetTotalUsedFds() int { + if fds, err := ioutil.ReadDir(fmt.Sprintf("/proc/%d/fd", os.Getpid())); err != nil { + logrus.Errorf("Error opening /proc/%d/fd: %s", os.Getpid(), err) + } else { + return len(fds) + } + return -1 +} diff --git a/fileutils/fileutils_windows.go b/fileutils/fileutils_windows.go new file mode 100644 index 0000000..5ec21ca --- /dev/null +++ b/fileutils/fileutils_windows.go @@ -0,0 +1,7 @@ +package fileutils + +// GetTotalUsedFds Returns the number of used File Descriptors. Not supported +// on Windows. +func GetTotalUsedFds() int { + return -1 +}