Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(111)

Unified Diff: src/pkg/os/file_unix.go

Issue 4321045: code review 4321045: os: fix FileInfo.Name returned by Stat
Patch Set: diff -r 90b229dbdd2c https://go.googlecode.com/hg/ Created 14 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/pkg/os/stat_darwin.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pkg/os/file_unix.go
===================================================================
--- a/src/pkg/os/file_unix.go
+++ b/src/pkg/os/file_unix.go
@@ -102,3 +102,21 @@
}
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
+}
« no previous file with comments | « no previous file | src/pkg/os/stat_darwin.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b