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
85c79ef7
Commit
85c79ef7
authored
Mar 29, 2011
by
David Forsythe
Committed by
Russ Cox
Mar 29, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
os: fix FileInfo.Name returned by Stat
Fixes #1645. R=rsc CC=golang-dev
https://golang.org/cl/4321045
parent
04b7da80
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
21 deletions
+21
-21
src/pkg/os/file_unix.go
src/pkg/os/file_unix.go
+18
-0
src/pkg/os/stat_darwin.go
src/pkg/os/stat_darwin.go
+1
-7
src/pkg/os/stat_freebsd.go
src/pkg/os/stat_freebsd.go
+1
-7
src/pkg/os/stat_linux.go
src/pkg/os/stat_linux.go
+1
-7
No files found.
src/pkg/os/file_unix.go
View file @
85c79ef7
...
...
@@ -102,3 +102,21 @@ func Truncate(name string, size int64) Error {
}
return
nil
}
// basename removes trailing slashes and the leading directory name from path name
func
basename
(
name
string
)
string
{
i
:=
len
(
name
)
-
1
// Remove trailing slashes
for
;
i
>
0
&&
name
[
i
]
==
'/'
;
i
--
{
name
=
name
[
:
i
]
}
// Remove leading directory name
for
i
--
;
i
>=
0
;
i
--
{
if
name
[
i
]
==
'/'
{
name
=
name
[
i
+
1
:
]
break
}
}
return
name
}
src/pkg/os/stat_darwin.go
View file @
85c79ef7
...
...
@@ -24,13 +24,7 @@ func fileInfoFromStat(name string, fi *FileInfo, lstat, stat *syscall.Stat_t) *F
fi
.
Atime_ns
=
syscall
.
TimespecToNsec
(
stat
.
Atimespec
)
fi
.
Mtime_ns
=
syscall
.
TimespecToNsec
(
stat
.
Mtimespec
)
fi
.
Ctime_ns
=
syscall
.
TimespecToNsec
(
stat
.
Ctimespec
)
for
i
:=
len
(
name
)
-
1
;
i
>=
0
;
i
--
{
if
name
[
i
]
==
'/'
{
name
=
name
[
i
+
1
:
]
break
}
}
fi
.
Name
=
name
fi
.
Name
=
basename
(
name
)
if
isSymlink
(
lstat
)
&&
!
isSymlink
(
stat
)
{
fi
.
FollowedSymlink
=
true
}
...
...
src/pkg/os/stat_freebsd.go
View file @
85c79ef7
...
...
@@ -24,13 +24,7 @@ func fileInfoFromStat(name string, fi *FileInfo, lstat, stat *syscall.Stat_t) *F
fi
.
Atime_ns
=
syscall
.
TimespecToNsec
(
stat
.
Atimespec
)
fi
.
Mtime_ns
=
syscall
.
TimespecToNsec
(
stat
.
Mtimespec
)
fi
.
Ctime_ns
=
syscall
.
TimespecToNsec
(
stat
.
Ctimespec
)
for
i
:=
len
(
name
)
-
1
;
i
>=
0
;
i
--
{
if
name
[
i
]
==
'/'
{
name
=
name
[
i
+
1
:
]
break
}
}
fi
.
Name
=
name
fi
.
Name
=
basename
(
name
)
if
isSymlink
(
lstat
)
&&
!
isSymlink
(
stat
)
{
fi
.
FollowedSymlink
=
true
}
...
...
src/pkg/os/stat_linux.go
View file @
85c79ef7
...
...
@@ -24,13 +24,7 @@ func fileInfoFromStat(name string, fi *FileInfo, lstat, stat *syscall.Stat_t) *F
fi
.
Atime_ns
=
syscall
.
TimespecToNsec
(
stat
.
Atim
)
fi
.
Mtime_ns
=
syscall
.
TimespecToNsec
(
stat
.
Mtim
)
fi
.
Ctime_ns
=
syscall
.
TimespecToNsec
(
stat
.
Ctim
)
for
i
:=
len
(
name
)
-
1
;
i
>=
0
;
i
--
{
if
name
[
i
]
==
'/'
{
name
=
name
[
i
+
1
:
]
break
}
}
fi
.
Name
=
name
fi
.
Name
=
basename
(
name
)
if
isSymlink
(
lstat
)
&&
!
isSymlink
(
stat
)
{
fi
.
FollowedSymlink
=
true
}
...
...
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