Skip to content

Commit

Permalink
Merge pull request #592 from ApptiveGrid/add-fsync
Browse files Browse the repository at this point in the history
Added FFI calls for fsync() and fdatasync() and connected it to writi…
  • Loading branch information
noha authored Feb 13, 2024
2 parents 8a81468 + d551e8b commit 1804657
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Soil-Core/SoilJournalFragmentFile.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ SoilJournalFragmentFile >> appendEntry: aSoilJournalEntry [
position := stream position.
aSoilJournalEntry writeOn: stream.
stream flush.
stream fileStream dataSync.
^ position

]
Expand Down
6 changes: 6 additions & 0 deletions src/Soil-File/AbstractBinaryFileStream.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Extension { #name : #AbstractBinaryFileStream }

{ #category : #'*Soil-File' }
AbstractBinaryFileStream >> fileStream [
^ self
]
33 changes: 33 additions & 0 deletions src/Soil-File/BinaryFileStream.extension.st
Original file line number Diff line number Diff line change
@@ -1,11 +1,31 @@
Extension { #name : #BinaryFileStream }

{ #category : #'*Soil-File' }
BinaryFileStream >> dataSync [
^ self dataSync: (self fileno: self fileHandle)
]

{ #category : #'*Soil-File' }
BinaryFileStream >> dataSync: fd [
^ self
ffiCall: #(int fdatasync(int fd))
module: LibC
]

{ #category : #'*Soil-File' }
BinaryFileStream >> fileHandle [

^ handle pointerAt: 9
]

{ #category : #'*Soil-File' }
BinaryFileStream >> fileno: stream [

^ self
ffiCall: #(int fileno("FILE *"void *stream))
module: LibC
]

{ #category : #'*Soil-File' }
BinaryFileStream >> flockClass [
^ OSPlatform current flockClass
Expand Down Expand Up @@ -50,6 +70,19 @@ BinaryFileStream >> lockForAppendStartingAt: offset [
length: 0
]

{ #category : #'*Soil-File' }
BinaryFileStream >> sync [
^ self sync: (self fileno: self fileHandle).

]

{ #category : #'*Soil-File' }
BinaryFileStream >> sync: fd [
^ self
ffiCall: #(int fsync(int fd))
module: LibC
]

{ #category : #'*Soil-File' }
BinaryFileStream >> unlockAt: position length: length [

Expand Down
6 changes: 6 additions & 0 deletions src/Soil-File/ZnBufferedReadWriteStream.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Extension { #name : #ZnBufferedReadWriteStream }

{ #category : #'*Soil-File' }
ZnBufferedReadWriteStream >> fileStream [
^ writeStream fileStream
]
6 changes: 6 additions & 0 deletions src/Soil-File/ZnBufferedWriteStream.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Extension { #name : #ZnBufferedWriteStream }

{ #category : #'*Soil-File' }
ZnBufferedWriteStream >> fileStream [
^ stream fileStream
]
6 changes: 6 additions & 0 deletions src/Soil-File/ZnEncodedStream.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Extension { #name : #ZnEncodedStream }

{ #category : #'*Soil-File' }
ZnEncodedStream >> fileStream [
^ stream fileStream
]

0 comments on commit 1804657

Please sign in to comment.