Skip to content

Commit 8d56108

Browse files
author
John Howard
committed
Windows: Fix warning on info
Signed-off-by: John Howard <jhoward@microsoft.com>
1 parent e61abac commit 8d56108

File tree

3 files changed

+29
-12
lines changed

3 files changed

+29
-12
lines changed

pkg/fileutils/fileutils.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"errors"
55
"fmt"
66
"io"
7-
"io/ioutil"
87
"os"
98
"path/filepath"
109
"strings"
@@ -143,17 +142,6 @@ func CopyFile(src, dst string) (int64, error) {
143142
return io.Copy(df, sf)
144143
}
145144

146-
// GetTotalUsedFds Returns the number of used File Descriptors by
147-
// reading it via /proc filesystem.
148-
func GetTotalUsedFds() int {
149-
if fds, err := ioutil.ReadDir(fmt.Sprintf("/proc/%d/fd", os.Getpid())); err != nil {
150-
logrus.Errorf("Error opening /proc/%d/fd: %s", os.Getpid(), err)
151-
} else {
152-
return len(fds)
153-
}
154-
return -1
155-
}
156-
157145
// ReadSymlinkedDirectory returns the target directory of a symlink.
158146
// The target of the symbolic link may not be a file.
159147
func ReadSymlinkedDirectory(path string) (string, error) {

pkg/fileutils/fileutils_unix.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// +build linux freebsd
2+
3+
package fileutils
4+
5+
import (
6+
"fmt"
7+
"io/ioutil"
8+
"os"
9+
10+
"github.com/Sirupsen/logrus"
11+
)
12+
13+
// GetTotalUsedFds Returns the number of used File Descriptors by
14+
// reading it via /proc filesystem.
15+
func GetTotalUsedFds() int {
16+
if fds, err := ioutil.ReadDir(fmt.Sprintf("/proc/%d/fd", os.Getpid())); err != nil {
17+
logrus.Errorf("Error opening /proc/%d/fd: %s", os.Getpid(), err)
18+
} else {
19+
return len(fds)
20+
}
21+
return -1
22+
}

pkg/fileutils/fileutils_windows.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package fileutils
2+
3+
// GetTotalUsedFds Returns the number of used File Descriptors. Not supported
4+
// on Windows.
5+
func GetTotalUsedFds() int {
6+
return -1
7+
}

0 commit comments

Comments
 (0)