Skip to content
Permalink
Browse files

Add DiskDirectoryEntry>>isHidden

For Windows, this will be the FILE_ATTRIBUTE_HIDDEN bit, see https://docs.microsoft.com/en-us/windows/win32/fileio/file-attribute-constants.

For Unix, this will use the file naming convention that files beginning with a '.' are not listed.

Fixes: #4201
  • Loading branch information
akgrant committed Aug 6, 2019
1 parent 470e9cb commit 4377e45af3bc02b5abccf30574408c2daefc4c2e
@@ -282,6 +282,13 @@ DiskDirectoryEntry >> isFile [
do: [ false ].
]

{ #category : #testing }
DiskDirectoryEntry >> isHidden [
"Answer a boolean indicating whether the receiver is hidden"

^reference fileSystem isHidden: reference attributes: self statAttributes
]

{ #category : #testing }
DiskDirectoryEntry >> isReadable [
"Answer a boolean indicating whether the VM can read the receivers file"
@@ -564,6 +564,14 @@ FileSystem >> isFile: aResolvable [
^ store isFile: (self resolve: aResolvable)
]

{ #category : #'public-testing' }
FileSystem >> isHidden: aResolvable attributes: statAttributesArray [
"Resolve the argument, and answer a boolean indicating whether the file is hidden or not.
statAttributesArray is optional and may be supplied for performance. It is the result of File>>fileAttributes:mask: or nil"

^ store isHidden: (self resolve: aResolvable) attributes: statAttributesArray
]

{ #category : #'public-testing' }
FileSystem >> isReadable: aResolvable [
"Resolve the argument, and answer true if the there is
@@ -194,6 +194,13 @@ FileSystemDirectoryEntry >> isFile [
^false
]

{ #category : #testing }
FileSystemDirectoryEntry >> isHidden [
"Return whether the receiver is hidden"

^false
]

{ #category : #testing }
FileSystemDirectoryEntry >> isReadable [

@@ -53,3 +53,11 @@ UnixStore >> checkName: aFileName fixErrors: fixing [

^ fName copyReplaceAll: self delimiter asString with: '#'
]

{ #category : #testing }
UnixStore >> isHidden: aResolvable attributes: statAttributesArray [
"Answer a boolean indicating whether the file is hidden or not.
On Unix, use the file naming convention that file names beginning with a dot are not displayed"

^aResolvable basename first = $.
]
@@ -170,6 +170,19 @@ WindowsStore >> isFIFO: aPath [
^super isFIFO: aPath
]

{ #category : #testing }
WindowsStore >> isHidden: aPath attributes: statAttributesArray [
"Answer a boolean indicating whether the file is hidden or not.
statAttributesArray is optional and may be supplied for performance. It is the result of File>>fileAttributes:mask: or nil"

| attributesArray |

attributesArray := statAttributesArray ifNil:
[ File fileAttributes: (self stringFromPath: aPath) mask: 1 ].

^(attributesArray at: 13) anyMask: 16r2
]

{ #category : #testing }
WindowsStore >> isReadable: aPath [
"Answer a boolean indicating whether the supplied path is readable"
@@ -166,6 +166,12 @@ DiskFileAttributesTest >> testIsFIFO [
self collectionAssert: [ :each | each isFIFO ] equals: false.
]

{ #category : #tests }
DiskFileAttributesTest >> testIsHidden [

self collectionAssert: [ :each | each isHidden ] equals: false.
]

{ #category : #tests }
DiskFileAttributesTest >> testIsReadable [

0 comments on commit 4377e45

Please sign in to comment.
You can’t perform that action at this time.