Skip to content

Commit

Permalink
Isolate the FileDirectory and FileStream class references in a single
Browse files Browse the repository at this point in the history
method to make porting to platforms with different class names easier to
maintain....

Issue #4
  • Loading branch information
Dale Henrichs committed Jul 30, 2012
1 parent 88840db commit 53a9e63
Show file tree
Hide file tree
Showing 22 changed files with 46 additions and 36 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
paths
baseNameFor: fileName
^ (FileDirectory root directoryEntryFor: fileName) name
^ (self fileDirectoryClass root directoryEntryFor: fileName) name
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
defaults
defaultDirectory
^ FileDirectory default
^ self fileDirectoryClass default
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
defaults
defaultDirectoryPath
^ FileDirectory default fullName
^ self fileDirectoryClass default fullName
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
paths
delete: path
^ FileDirectory default deleteFileNamed: path
^ self fileDirectoryClass default deleteFileNamed: path
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
paths
downloadPathTo: directoryOrFileName for: baseName
| downloadPath |
downloadPath := FileDirectory on: directoryOrFileName.
downloadPath := self fileDirectoryClass on: directoryOrFileName.
^ (downloadPath exists and: [ downloadPath directoryEntry isDirectory ])
ifTrue: [
baseName ifNil: [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
paths
exists: path
^ FileDirectory default fileExists: path
^ self fileDirectoryClass default fileExists: path
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
paths
extensionFor: fileName
^ FileDirectory extensionFor: fileName
^ self fileDirectoryClass extensionFor: fileName
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
private
fileDirectoryClass

^FileDirectory
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
streams
fileNamed: fileName do: block
^ FileStream
^ self fileDirectoryClass
fileNamed: fileName
do: block
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
queries
fileSizeFor: fileName
^ (FileDirectory root directoryEntryFor: fileName) fileSize
^ (self fileDirectoryClass root directoryEntryFor: fileName) fileSize
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
private
fileStreamClass

^FileStream
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
streams
fileStreamFor: fileName
^ FileStream fileNamed: fileName
^ self fileStreamClass fileNamed: fileName
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
paths
fullNameFor: fileName
^ (FileDirectory default / fileName) fullName
^ (self fileDirectoryClass default / fileName) fullName
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
queries
modificationTimeFor: path
^ (FileDirectory default directoryEntryFor: path) modificationDateAndTime
^ (self fileDirectoryClass default directoryEntryFor: path) modificationDateAndTime
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
streams
newFileNamed: fileName do: block
^ FileStream
^ self fileDirectoryClass
newFileNamed: fileName
do: block
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
streams
oldFileNamed: fileName do: block
^ FileStream
^ self fileDirectoryClass
oldFileNamed: fileName
do: block
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
streams
oldFileStreamFor: fileName
^ FileStream oldFileNamed: fileName
^ self fileDirectoryClass oldFileNamed: fileName
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
{
"class" : {
"baseNameFor:" : "SvenVanCaekenberghe 7/2/2012 16:10",
"defaultDirectory" : "SvenVanCaekenberghe 7/3/2012 00:37",
"defaultDirectoryPath" : "SvenVanCaekenberghe 7/2/2012 22:36",
"delete:" : "SvenVanCaekenberghe 7/2/2012 16:44",
"baseNameFor:" : "dkh 07/29/2012 17:53",
"defaultDirectory" : "dkh 07/29/2012 17:53",
"defaultDirectoryPath" : "dkh 07/29/2012 17:54",
"delete:" : "dkh 07/29/2012 17:54",
"deleteIfExists:" : "SvenVanCaekenberghe 7/2/2012 16:57",
"downloadPathTo:for:" : "SvenVanCaekenberghe 7/20/2012 13:06",
"exists:" : "SvenVanCaekenberghe 7/2/2012 16:43",
"extensionFor:" : "SvenVanCaekenberghe 7/2/2012 16:01",
"fileNamed:do:" : "SvenVanCaekenberghe 7/2/2012 16:23",
"fileSizeFor:" : "SvenVanCaekenberghe 7/2/2012 16:08",
"fileStreamFor:" : "SvenVanCaekenberghe 7/2/2012 16:13",
"fullNameFor:" : "SvenVanCaekenberghe 7/3/2012 00:34",
"modificationTimeFor:" : "SvenVanCaekenberghe 7/3/2012 00:40",
"newFileNamed:do:" : "SvenVanCaekenberghe 7/3/2012 00:32",
"oldFileNamed:do:" : "SvenVanCaekenberghe 7/2/2012 22:33",
"oldFileStreamFor:" : "SvenVanCaekenberghe 7/2/2012 16:13" },
"downloadPathTo:for:" : "dkh 07/29/2012 17:54",
"exists:" : "dkh 07/29/2012 17:54",
"extensionFor:" : "dkh 07/29/2012 17:54",
"fileDirectoryClass" : "dkh 07/29/2012 17:55",
"fileNamed:do:" : "dkh 07/29/2012 17:54",
"fileSizeFor:" : "dkh 07/29/2012 17:54",
"fileStreamClass" : "dkh 07/29/2012 17:54",
"fileStreamFor:" : "dkh 07/29/2012 17:55",
"fullNameFor:" : "dkh 07/29/2012 17:55",
"modificationTimeFor:" : "dkh 07/29/2012 17:55",
"newFileNamed:do:" : "dkh 07/29/2012 17:55",
"oldFileNamed:do:" : "dkh 07/29/2012 17:55",
"oldFileStreamFor:" : "dkh 07/29/2012 17:55" },
"instance" : {
} }
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
private
responseForFile: filename fromRequest: aRequest
| entry size time mimeType fileStream entity response modified |
entry := ServerFileDirectory root directoryEntryFor: filename.
entry := ZnFileSystemUtils fileDirectoryClass root directoryEntryFor: filename.
size := entry fileSize.
time := entry modificationDateAndTime.
modified := true.
Expand All @@ -10,8 +10,8 @@ responseForFile: filename fromRequest: aRequest
ifPresent: [ modified := time > (ZnUtils parseHttpDate: (aRequest headers at: 'If-Modified-Since')) ].
modified
ifTrue: [
mimeType := ZnMimeType forFilenameExtension: (ServerFileDirectory extensionFor: filename).
fileStream := ServerFileDirectory root oldFileNamed: filename.
mimeType := ZnMimeType forFilenameExtension: (ZnFileSystemUtils fileDirectoryClass extensionFor: filename).
fileStream := ZnFileSystemUtils fileDirectoryClass root oldFileNamed: filename.
mimeType isBinary
ifTrue: [ fileStream binary ].
(entity := ZnStreamingEntity type: mimeType length: size) stream: fileStream.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
"prefix:" : "SvenVanCaekenberghe 4/26/2011 11:08",
"prefixFromString:" : "SvenVanCaekenberghe 4/26/2011 11:09",
"redirectNeededFor:actualFilename:" : "SvenVanCaekenberghe 4/26/2011 13:11",
"responseForFile:fromRequest:" : "SvenVanCaekenberghe 5/14/2012 09:53" } }
"responseForFile:fromRequest:" : "dkh 07/29/2012 17:58" } }
Original file line number Diff line number Diff line change
@@ -1 +1 @@
SystemOrganization addCategory: #'Zinc-FileSystem-Legacy'!
SystemOrganization addCategory: 'Zinc-FileSystem-Legacy'!
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(name 'Zinc-FileSystem-Legacy-SvenVanCaekenberghe.2' message 'fixed a logic problem in ZnFileSystemUtils class>>#downloadPathTo:for:' id '30263aa4-76ea-4db1-8c10-9fd5eae0e1fb' date '20 July 2012' time '1:14:58 pm' author 'SvenVanCaekenberghe' ancestors ((name 'Zinc-FileSystem-Legacy-SvenVanCaekenberghe.1' message 'introduction of the Zinc-FileSystem-Legacy package (including the new ZnFileSystemUtils class) to deal with pre/post FIleSystem introduction in Pharo 2.0 - this is the old code' id '207f349a-f8a3-41da-b78b-8ae9107259a8' date '3 July 2012' time '1:48:48.041 pm' author 'SvenVanCaekenberghe' ancestors () stepChildren ())) stepChildren ())
(name 'Zinc-FileSystem-Legacy-dkh.3' message 'Zinc Issue #4 (sven)' id '48f4a37c-039c-4b3c-a10f-0d5bcf30dd5e' date '07/29/2012' time '18:01:20' author 'dkh' ancestors ((name 'Zinc-FileSystem-Legacy-SvenVanCaekenberghe.2' message 'fixed a logic problem in ZnFileSystemUtils class>>#downloadPathTo:for:' id '30263aa4-76ea-4db1-8c10-9fd5eae0e1fb' date '07/20/2012' time '13:14:58' author 'SvenVanCaekenberghe' ancestors ((name 'Zinc-FileSystem-Legacy-SvenVanCaekenberghe.1' message 'introduction of the Zinc-FileSystem-Legacy package (including the new ZnFileSystemUtils class) to deal with pre/post FIleSystem introduction in Pharo 2.0 - this is the old code' id '207f349a-f8a3-41da-b78b-8ae9107259a8' date '07/03/2012' time '01:48:48' author 'SvenVanCaekenberghe' ancestors () stepChildren ())) stepChildren ())) stepChildren ())

0 comments on commit 53a9e63

Please sign in to comment.