[PATCH] convert to new File classes

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] convert to new File classes

Paolo Bonzini-2
This converts the rest of the system to use the new file classes.

---
 kernel/PkgLoader.st                  |   12 ++++++------
 packages/cpp/CPP.st                  |    2 +-
 packages/httpd/FileServer.st         |    7 +++----
 packages/i18n/GetText.st             |    9 +++++----
 packages/net/FTP.st                  |    4 ++--
 packages/net/URIResolver.st          |   23 ++++++++++-------------
 packages/seaside/core/Seaside-GST.st |    6 +++---
 packages/sport/sport.st              |    5 ++---
 scripts/Package.st                   |   17 +++++++----------
 9 files changed, 39 insertions(+), 46 deletions(-)

diff --git a/kernel/PkgLoader.st b/kernel/PkgLoader.st
index 1ef566d..fe14cee 100644
--- a/kernel/PkgLoader.st
+++ b/kernel/PkgLoader.st
@@ -819,13 +819,13 @@ XML.'>
     allFiles: prefix [
  <category: 'private - subpackages'>
  prefix isNil ifTrue: [^self allFiles].
- ^self allFiles collect: [:each | Directory append: each to: prefix]
+ ^self allFiles collect: [:each | File append: each to: prefix]
     ]
 
     allDistFiles: prefix [
  <category: 'private - subpackages'>
  prefix isNil ifTrue: [^self allDistFiles].
- ^self allDistFiles collect: [:each | Directory append: each to: prefix]
+ ^self allDistFiles collect: [:each | File append: each to: prefix]
     ]
 ]
 
@@ -966,7 +966,7 @@ PackageInfo subclass: StarPackage [
 
     directory [
  <category: 'accessing'>
- ^File name: self fileName, '#uzip'
+ ^(File name: self fileName) zip
     ]
 
     file [
@@ -993,7 +993,7 @@ PackageInfo subclass: StarPackage [
  <category: 'accessing'>
  | file package |
  loadedPackage isNil ifFalse: [^loadedPackage].
- package := self file , '#uzip/package.xml'
+ package := self file zip / 'package.xml'
  withReadStreamDo: [ :fileStream | Package parse: fileStream].
  package isNil
     ifTrue: [^self error: 'invalid disabled-package tag inside a star file'].
@@ -1413,12 +1413,12 @@ that package.
     ]
 
     baseDirectories [
- "Answer the namespace in which the package is loaded."
+ "Answer the directories in which package files are sought."
 
  <category: 'accessing'>
  ^super baseDirectories ifNil:
  [owner baseDirectories
-    collect: [:each | Directory append: owner relativeDirectory to: each]]
+    collect: [:each | each / owner relativeDirectory]]
     ]
 ]
 
diff --git a/packages/cpp/CPP.st b/packages/cpp/CPP.st
index 797e459..5921f79 100644
--- a/packages/cpp/CPP.st
+++ b/packages/cpp/CPP.st
@@ -673,7 +673,7 @@ findIncludeFile: fileName locally: locally
     paths _ self includePaths.
     locally ifTrue: [ paths addFirst: '.' ].
     paths do:
- [ :path | file _ File name: path , '/', fileName.
+ [ :path | file _ path / fileName.
   file exists ifTrue: [ ^file readStream ] ].
     ^nil
 !
diff --git a/packages/httpd/FileServer.st b/packages/httpd/FileServer.st
index 6e5ba95..e1b8977 100644
--- a/packages/httpd/FileServer.st
+++ b/packages/httpd/FileServer.st
@@ -128,10 +128,9 @@ A DirectoryResponse formats output of the contents of a Directory object.'>
 
     sendFileProperties: each [
  <category: 'response'>
- | isDirectory choppedName name fullName subDirFile parent slash |
+ | isDirectory choppedName name subDirFile parent slash |
  each = '.' ifTrue: [^self].
- fullName := Directory append: each to: file name.
- subDirFile := File name: fullName.
+ subDirFile := file / each.
  subDirFile isReadable ifFalse: [^self].
  isDirectory := subDirFile isDirectory.
  choppedName := isDirectory
@@ -775,7 +774,7 @@ and DirectoryResponses.'>
  self indexFileNames do:
  [:each |
  | indexFile |
- indexFile := File name: (Directory append: each to: aDirectory name).
+ indexFile := aDirectory / each.
  indexFile isReadable
     ifTrue: [^self fileResponse: indexFile request: aRequest]].
  ^nil
diff --git a/packages/i18n/GetText.st b/packages/i18n/GetText.st
index 1dd8564..10b42a2 100644
--- a/packages/i18n/GetText.st
+++ b/packages/i18n/GetText.st
@@ -134,7 +134,7 @@ LocaleConventions subclass: LcMessages [
  | catalog |
  self isPosixLocale ifTrue: [^self dummyDomain].
  ^LcMessagesDomain id: self id
-    on: (Directory append: aString , '.mo' to: dirName)
+    on: dirName / aString , '.mo'
     ]
 
     dummyDomain [
@@ -175,11 +175,12 @@ longer than the traditional
  from a path to the MO file"
 
  <category: 'opening MO files'>
- | stream found |
+ | stream found file |
  found := false.
- (File exists: aFileName)
+ file := aFileName asFile.
+ file exists
     ifTrue:
- [stream := FileStream open: aFileName mode: FileStream read.
+ [stream := file readStream.
  found :=
  [stream littleEndianMagicNumber: #[222 18 4 149]
     bigEndianMagicNumber: #[149 4 18 222].
diff --git a/packages/net/FTP.st b/packages/net/FTP.st
index 22a4fdf..8c606c8 100644
--- a/packages/net/FTP.st
+++ b/packages/net/FTP.st
@@ -259,7 +259,7 @@ Copyright (c) Kazuki Yasumatsu, 1995. All rights reserved.
  <category: 'ftp'>
  | fname directory tail |
  self login.
- fname := File name: fileName.
+ fname := File path: fileName.
  directory := fname path asString.
  tail := fname stripPath asString.
  tail isEmpty
@@ -280,7 +280,7 @@ Copyright (c) Kazuki Yasumatsu, 1995. All rights reserved.
  <category: 'ftp'>
  | fname directory tail |
  self login.
- fname := File name: pathName.
+ fname := File path: pathName.
  directory := fname path asString.
  tail := fname stripPath asString.
  self clientPI ftpCwd: directory.
diff --git a/packages/net/URIResolver.st b/packages/net/URIResolver.st
index 9d900c2..0152257 100644
--- a/packages/net/URIResolver.st
+++ b/packages/net/URIResolver.st
@@ -279,13 +279,10 @@ Copyright (c) Kazuki Yasumatsu, 1995. All rights reserved.
     getFileContents [
  <category: 'file accessing'>
  | file result |
- file := url path isNil
-    ifTrue: [File name: '/']
-    ifFalse: [File name: url path].
- file exists not ifTrue: [^self errorContents: 'No such file'].
+ file := File name: (url path ifNil: '/').
+ file exists ifFalse: [^self errorContents: 'No such file'].
  file isReadable ifFalse: [^self errorContents: 'Cannot read'].
- file isDirectory
-    ifTrue: [^self getDirectoryContentsOf: (File name: file name)].
+ file isDirectory ifTrue: [^self getDirectoryContentsOf: file].
  ^(WebEntity new)
     url: url;
     canCache: false;
@@ -328,7 +325,7 @@ Copyright (c) Kazuki Yasumatsu, 1995. All rights reserved.
     ifTrue: [path := '/']
     ifFalse: [path := url path].
  stream := self tmpFile.
- tmpFile := File name: stream name.
+ tmpFile := stream file.
  ^
  [
  [client
@@ -364,7 +361,7 @@ Copyright (c) Kazuki Yasumatsu, 1995. All rights reserved.
  baseURL := url copy.
  baseURL path isNil
     ifTrue: [baseURL path: '/junk']
-    ifFalse: [baseURL path: (Directory append: 'junk' to: baseURL path)].
+    ifFalse: [baseURL path: (File append: 'junk' to: baseURL path)].
  maxSize := 32.
  stream := ReadWriteStream on: (String new: 512).
  title := 'Directory listing of ' , url printString.
@@ -507,7 +504,7 @@ Copyright (c) Kazuki Yasumatsu, 1995. All rights reserved.
  client reporter
     statusString: 'Connect: Host contacted. Waiting for reply...'.
  stream := self tmpFile.
- tmpFile := File name: stream name.
+ tmpFile := stream file.
 
  [
  [
@@ -579,7 +576,7 @@ Copyright (c) Kazuki Yasumatsu, 1995. All rights reserved.
  client reporter
     statusString: 'Connect: Host contacted. Waiting for reply...'.
  stream := self tmpFile.
- tmpFile := File name: stream name.
+ tmpFile := stream file.
  protocolError := false.
 
  [
@@ -653,7 +650,7 @@ Copyright (c) Kazuki Yasumatsu, 1995. All rights reserved.
  client reporter
     statusString: 'Connect: Host contacted. Waiting for reply...'.
  stream := self tmpFile.
- tmpFile := File name: stream name.
+ tmpFile := stream file.
  protocolError := false.
 
  [
@@ -763,7 +760,7 @@ Copyright (c) Kazuki Yasumatsu, 1995. All rights reserved.
  <category: 'news accessing'>
  | tmpFile stream contents |
  stream := self tmpFile.
- tmpFile := File name: stream name.
+ tmpFile := stream file.
 
  [
  [client articleAt: '<' , articleId , '>' into: stream.
@@ -787,7 +784,7 @@ Copyright (c) Kazuki Yasumatsu, 1995. All rights reserved.
  <category: 'news accessing'>
  | tmpFile stream contents |
  stream := self tmpFile.
- tmpFile := File name: stream name.
+ tmpFile := stream file.
 
  [
  [client
diff --git a/packages/seaside/core/Seaside-GST.st b/packages/seaside/core/Seaside-GST.st
index b49b110..251710d 100644
--- a/packages/seaside/core/Seaside-GST.st
+++ b/packages/seaside/core/Seaside-GST.st
@@ -555,13 +555,13 @@ Object subclass: WAGNUSmalltalkPlatform [
  must not include file names that start with ."
  | directory |
  directory := File name: aPathString.
- ^(directory entryNames
+ ^(directory files
  reject: [ :each | each first = $. ])
- collect: [ :each | Directory append: each to: directory name ]
+ collect: [ :each | each asString ]
     ]
 
     localNameOf: aFilename [
- ^(File name: aFilename) name
+ ^File fullNameFor: aFilename
     ]
 
     mimeDocumentClass [
diff --git a/packages/sport/sport.st b/packages/sport/sport.st
index 549d713..b66b9c2 100644
--- a/packages/sport/sport.st
+++ b/packages/sport/sport.st
@@ -723,7 +723,7 @@ Object subclass: SpFileStream [
 
  <category: 'initialize-release'>
  filename := aString.
- underlyingStream := (File name: aString) readStream.
+ underlyingStream := (File path: aString) readStream.
  ^self
     ]
 
@@ -778,8 +778,7 @@ Object subclass: SpFileStream [
 
  <category: 'initialize-release'>
  filename := aString.
- underlyingStream := (File name: aString) writeStream.
- underlyingStream lineEndTransparent.
+ underlyingStream := (File path: aString) writeStream.
  ^self
     ]
 
diff --git a/scripts/Package.st b/scripts/Package.st
index 1a9d04d..4110dd4 100644
--- a/scripts/Package.st
+++ b/scripts/Package.st
@@ -35,14 +35,14 @@ Package extend [
     ]
 
     isStarPackageBody [
- ^'*.star#uzip' match: self baseDirectories first name
+ ^self baseDirectories first isKindOf: VFS.ArchiveFile
     ]
 
     starFileName [
  | dir |
  self isStarPackageBody ifFalse: [ self halt ].
- dir := self baseDirectories first.
- ^dir name allButLast: 5 ]
+ ^self baseDirectories first asString
+    ]
 
     runCommand: aCommand [
  self isStarPackageBody
@@ -89,7 +89,7 @@ Kernel.PackageDirectories subclass: PackageFiles [
     ifTrue: [
  StarPackageFile
     on: file
-    baseDirectories: [ {File name: fileName, '#uzip'} ] ].
+    baseDirectories: [ {(File name: fileName) zip} ] ].
 
  packageFile refresh.
  ^packageFile
@@ -180,9 +180,7 @@ File extend [
  destFile mode: mode
     ].
     ]
-]
 
-File extend [
     emitMkdir [
  | doThat |
  self exists ifTrue: [ ^self ].
@@ -238,8 +236,7 @@ Object subclass: Command [
     destDir: destdir installDir: instDir [
  self validateDestDir: destdir installDir: instDir.
  installDir :=
-    File name:
-        destdir, (instDir ifNil: [ self defaultInstallDir ])
+    File name: destdir, (instDir ifNil: [ self defaultInstallDir ])
     ]
 
     defaultInstallDir [ ^Directory image ]
@@ -596,7 +593,7 @@ AC_OUTPUT
 
  pkgSrcDir := srcPath size < buildPath size
     ifTrue: [ File pathFor: srcPath ifNone: [ self srcdir ] ]
-    ifFalse: [ Directory append: (File pathFor: buildPath) to: self srcdir ].
+    ifFalse: [ File append: (File pathFor: buildPath) to: self srcdir ].
 
  relPkgSrcDir := (File name: self srcdir) pathTo: pkgSrcDir.
 
@@ -783,4 +780,4 @@ The default target directory is ', Directory image name, '
     do: [ :ex |
  ('gst-package: ', ex messageText, '
 ') displayOn: stderr.
- "ex pass." ObjectMemory quit: 1 ].
+ ex pass. ObjectMemory quit: 1 ].
--
1.5.3.4.910.gc5122-dirty



_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk