Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
e38a1053
Commit
e38a1053
authored
Nov 26, 2011
by
Alex Brainman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
os: fail if Open("") is called on windows
R=golang-dev, bradfitz CC=golang-dev
https://golang.org/cl/5432071
parent
5519b5d7
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
0 deletions
+11
-0
src/pkg/os/file_windows.go
src/pkg/os/file_windows.go
+3
-0
src/pkg/os/os_test.go
src/pkg/os/os_test.go
+8
-0
No files found.
src/pkg/os/file_windows.go
View file @
e38a1053
...
@@ -89,6 +89,9 @@ func openDir(name string) (file *File, err error) {
...
@@ -89,6 +89,9 @@ func openDir(name string) (file *File, err error) {
// methods on the returned File can be used for I/O.
// methods on the returned File can be used for I/O.
// It returns the File and an error, if any.
// It returns the File and an error, if any.
func
OpenFile
(
name
string
,
flag
int
,
perm
uint32
)
(
file
*
File
,
err
error
)
{
func
OpenFile
(
name
string
,
flag
int
,
perm
uint32
)
(
file
*
File
,
err
error
)
{
if
name
==
""
{
return
nil
,
&
PathError
{
"open"
,
name
,
syscall
.
ENOENT
}
}
// TODO(brainman): not sure about my logic of assuming it is dir first, then fall back to file
// TODO(brainman): not sure about my logic of assuming it is dir first, then fall back to file
r
,
e
:=
openDir
(
name
)
r
,
e
:=
openDir
(
name
)
if
e
==
nil
{
if
e
==
nil
{
...
...
src/pkg/os/os_test.go
View file @
e38a1053
...
@@ -901,6 +901,14 @@ func TestOpenError(t *testing.T) {
...
@@ -901,6 +901,14 @@ func TestOpenError(t *testing.T) {
}
}
}
}
func
TestOpenNoName
(
t
*
testing
.
T
)
{
f
,
err
:=
Open
(
""
)
if
err
==
nil
{
t
.
Fatal
(
`Open("") succeeded`
)
f
.
Close
()
}
}
func
run
(
t
*
testing
.
T
,
cmd
[]
string
)
string
{
func
run
(
t
*
testing
.
T
,
cmd
[]
string
)
string
{
// Run /bin/hostname and collect output.
// Run /bin/hostname and collect output.
r
,
w
,
err
:=
Pipe
()
r
,
w
,
err
:=
Pipe
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment