Skip to content

Commit

Permalink
replaced filepath.Separator with "/" (#2)
Browse files Browse the repository at this point in the history
This fixes an inconsistency when the library is used on Windows.

On Linux, the file path separator is "/", but on Windows it is "". As
"/" is already hardcoded elsewhere, and "/" is a forbidden character in
file names and folders on Windows already, all instances have been
replaced with "/".
  • Loading branch information
SoftPoison committed Feb 28, 2023
1 parent c027642 commit 7a08aef
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions xfs/xfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,15 @@ func (xfs *FileSystem) ReadDirInfo(name string) (fs.FileInfo, error) {
mode: fs.FileMode(inode.inodeCore.Mode),
}, nil
}
name = strings.TrimRight(name, string(filepath.Separator))
name = strings.TrimRight(name, "/")

dirs, dir := path.Split(name)
dirEntries, err := xfs.readDirEntry(dirs)
if err != nil {
return nil, xerrors.Errorf("failed to read dir entry: %w", err)
}
for _, entry := range dirEntries {
if entry.Name() == strings.Trim(dir, string(filepath.Separator)) {
if entry.Name() == strings.Trim(dir, "/") {
return entry.Info()
}
}
Expand Down Expand Up @@ -276,7 +276,7 @@ func (xfs *FileSystem) readDirEntry(name string) ([]fs.DirEntry, error) {
}

currentInode := inode
dirs := strings.Split(strings.Trim(filepath.Clean(name), string(filepath.Separator)), string(filepath.Separator))
dirs := strings.Split(strings.Trim(filepath.Clean(name), "/"), "/")
for i, dir := range dirs {
found := false
for _, fileInfo := range fileInfos {
Expand Down

0 comments on commit 7a08aef

Please sign in to comment.