Skip to content
Permalink
Browse files

Fixes for Windows specific code introduced by latest refactoring

  • Loading branch information
akgrant committed Jun 12, 2018
1 parent df00ef8 commit 5cda1b47802e705515094179bdda334e3f57b41e
Showing with 28 additions and 9 deletions.
  1. +1 −1 src/FileSystem-Disk/DiskStore.class.st
  2. +1 −1 src/FileSystem-Disk/WindowsStore.class.st
  3. +26 −7 src/Files/File.class.st
@@ -346,7 +346,7 @@ DiskStore >> isCharacter: aPath [
{ #category : #accessing }
DiskStore >> isDirectory: aPath [
"Answer a boolean indicating whether the supplied path is a Directory file"
^File isDirectory: (self stringFromPath: aPath)
^aPath isRoot or: [File isDirectory: (self stringFromPath: aPath)]
]

{ #category : #testing }
@@ -80,7 +80,7 @@ WindowsStore >> nodesAt: aPath do: aBlock [
drive := String with: (Character value: ($A asciiValue + i)) with: $:.
node := Array
with: drive
with: drive asFileReference attributes statAttributes.
with: drive asFileReference entry statAttributes.
aBlock value: node.
]
].
@@ -157,7 +157,7 @@ File class >> createDirectory: fullPath [
{ #category : #'private-encoding' }
File class >> decode: aString [

^ (ZnCharacterEncoder newForEncoding: 'utf8') decodeBytes: aString asByteArray
^ Encoder decodeBytes: aString asByteArray
]

{ #category : #'primitives-encoding' }
@@ -198,7 +198,7 @@ File class >> delimiter [
{ #category : #'private-encoding' }
File class >> encode: aString [

^ ((ZnCharacterEncoder newForEncoding: 'utf8') encodeString: aString) asString
^ (Encoder encodeString: aString) asString
]

{ #category : #'primitives-encoding' }
@@ -318,7 +318,6 @@ File class >> getPosition: id [
File class >> initialize [

SessionManager default registerSystemClassNamed: self name.
Encoder := ZnCharacterEncoder newForEncoding: 'utf8'.
self reset.
]

@@ -407,8 +406,7 @@ File class >> isSymlink: aPath [
"Answer a boolean indicating whether the supplied path is a Symlink file.
Note that this should only be called on platforms that support symlinks (e.g. not Windows)"

^self fileAttribute: aPath number: 16

^self supportsSymbolicLinks and: [ self fileAttribute: aPath number: 16 ]
]

{ #category : #'primitives-file modes' }
@@ -633,7 +631,7 @@ symbolic link information
"
<primitive: 'primitiveFileAttribute' module: 'FileAttributesPlugin' error: error>
^error isPrimitiveError ifTrue: [
(error errorCode = self cantStatPath and: [ attributeNumber ~= 16 ]) ifTrue:
(self retrySymbolicLinkOnAttribute: attributeNumber error: error) ifTrue:
[ (self fileAttributeNumberMap at: attributeNumber) value:
(DiskSymlinkDirectoryEntry fileSystem: DiskStore currentFileSystem path: aString asPath) ]
ifFalse:
@@ -782,10 +780,14 @@ File class >> rename: oldFileFullName to: newFileFullName [

{ #category : #'class initialization' }
File class >> reset [
"Reload the masks"
"Initialise the receiver for the current platform"

| masks |

Encoder := OSPlatform current isWindows
ifTrue: [ ZnCharacterEncoder newForEncoding: 'null' ]
ifFalse: [ ZnCharacterEncoder newForEncoding: 'utf8' ].

masks := self primFileMasks.
S_IFMT := masks at: 1.
S_IFSOCK := masks at: 2.
@@ -798,6 +800,16 @@ File class >> reset [

]

{ #category : #private }
File class >> retrySymbolicLinkOnAttribute: attributeNumber error: error [
"Answer a boolean indicating whether the operation can be retried assuming a symbolic link"
"This is part of some obscure backward compatibility code and can probably be removed."

^attributeNumber ~= 16 and:
[ error errorCode = self cantStatPath and:
[ OSPlatform current isUnix ] ]
]

{ #category : #registry }
File class >> retryWithGC: execBlock until: testBlock forFileNamed: fullName [
"Some platforms, like Windows, will fail if we try to open a file twice.
@@ -935,6 +947,13 @@ File class >> stringTooLong [
^-1
]

{ #category : #testing }
File class >> supportsSymbolicLinks [
"Answer a boolean indicating whether the current platform supports symbolic links"

^OSPlatform current isUnix
]

{ #category : #'primitives-file' }
File class >> sync: id [
"On Unix, this syncs any written or flushed data still in the kernel file

0 comments on commit 5cda1b4

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