Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3-files
Commits
a7bc21a3
Commit
a7bc21a3
authored
Aug 15, 2019
by
Steven Allen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
serialfile: fix handling of hidden paths on windows
fixes #11
parent
20be69d9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
28 deletions
+20
-28
is_hidden.go
is_hidden.go
+9
-10
is_hidden_windows.go
is_hidden_windows.go
+10
-17
serialfile.go
serialfile.go
+1
-1
No files found.
is_hidden.go
View file @
a7bc21a3
//
+build !windows
//+build !windows
package
files
import
(
"path/filepath"
"strings"
"os"
)
func
IsHidden
(
name
string
,
f
Node
)
bool
{
fName
:=
filepath
.
Base
(
name
)
if
strings
.
HasPrefix
(
fName
,
"."
)
&&
len
(
fName
)
>
1
{
return
true
func
isHidden
(
fi
os
.
FileInfo
)
bool
{
fName
:=
fi
.
Name
()
switch
fName
{
case
""
,
"."
,
".."
:
return
false
default
:
return
fName
[
0
]
==
'.'
}
return
false
}
is_hidden_windows.go
View file @
a7bc21a3
...
...
@@ -3,33 +3,26 @@
package
files
import
(
"path/filepath"
"strings"
"os"
windows
"golang.org/x/sys/windows"
)
func
IsHidden
(
name
string
,
f
Node
)
bool
{
fName
:=
filepath
.
Base
(
name
)
func
isHidden
(
fi
os
.
FileInfo
)
bool
{
fName
:=
fi
.
Name
()
switch
fName
{
case
""
,
"."
,
".."
:
return
false
}
if
strings
.
HasPrefix
(
fName
,
"."
)
&&
len
(
fName
)
>
1
{
if
fName
[
0
]
==
'.'
{
return
true
}
f
i
,
ok
:=
f
.
(
FileInfo
)
w
i
,
ok
:=
f
i
.
Sys
()
.
(
*
windows
.
Win32FileAttributeData
)
if
!
ok
{
return
false
}
p
,
e
:=
windows
.
UTF16PtrFromString
(
fi
.
AbsPath
())
if
e
!=
nil
{
return
false
}
attrs
,
e
:=
windows
.
GetFileAttributes
(
p
)
if
e
!=
nil
{
return
false
}
return
attrs
&
windows
.
FILE_ATTRIBUTE_HIDDEN
!=
0
return
wi
.
FileAttributes
&
windows
.
FILE_ATTRIBUTE_HIDDEN
!=
0
}
serialfile.go
View file @
a7bc21a3
...
...
@@ -75,7 +75,7 @@ func (it *serialIterator) Next() bool {
stat
:=
it
.
files
[
0
]
it
.
files
=
it
.
files
[
1
:
]
for
!
it
.
handleHiddenFiles
&&
strings
.
HasPrefix
(
stat
.
Name
(),
"."
)
{
for
!
it
.
handleHiddenFiles
&&
isHidden
(
stat
)
{
if
len
(
it
.
files
)
==
0
{
return
false
}
...
...
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