#REFACTORING by cg
authorClaus Gittinger <cg@exept.de>
Sun, 30 Sep 2018 11:02:47 +0200
changeset 23393 6f06e66359ca
parent 23392 224ad96ff678
child 23394 2395d4bffaa1
#REFACTORING by cg class: Filename added: #filesMatchingGLOB comment/format in: #filesMatching:do: #filesMatchingGLOB:do: category of: #directories #files #filesWithSuffix:
Filename.st
--- a/Filename.st	Thu Sep 27 10:05:25 2018 +0200
+++ b/Filename.st	Sun Sep 30 11:02:47 2018 +0200
@@ -2324,19 +2324,6 @@
     "
 !
 
-directories
-    "return a collection of directories contained in the directory represented by the receiver."
-
-    ^ OrderedCollection withCollectedContents:[:coll |
-        self directoriesDo:[:eachDirectory | coll add:eachDirectory]]
-
-    "
-     '.' asFilename directories.
-    "
-
-    "Modified: / 29-05-2007 / 12:02:56 / cg"
-!
-
 directoriesDo:aBlock
     "evaluate aBlock for directories contained in the directory represented by the receiver.
      The block is invoked with a filename-argument.
@@ -2445,20 +2432,6 @@
     "Modified: / 23.12.1999 / 20:56:35 / cg"
 !
 
-files
-    "return a collection of regular files
-     contained in the directory represented by the receiver."
-
-    ^ OrderedCollection withCollectedContents:[:coll |
-        self filesDo:[:eachFileName | coll add:eachFileName]].
-
-    "
-     '.' asFilename files.
-    "
-
-    "Modified: / 29-05-2007 / 12:02:15 / cg"
-!
-
 filesDo:aBlock
     "evaluate aBlock for all regular files (i.e. subdirs are ignored)
      contained in the directory represented by the receiver."
@@ -2488,7 +2461,10 @@
     "
      '..' asFilename filesMatchingGLOB:'A*' do:[:fn | Transcript showCR:fn].
      '../..' asFilename filesMatchingGLOB:'lib*/*.st' do:[:fn | Transcript showCR:fn].
-    "
+     '/Library/Java/JavaVirtualMachines' asFilename filesMatchingGLOB:'*.jdk' do:[:fn | Transcript showCR:fn].    
+    "
+
+    "Modified (comment): / 30-09-2018 / 10:59:19 / Claus Gittinger"
 !
 
 filesMatchingGLOBComponents:patternComponents do:aBlock
@@ -2600,20 +2576,6 @@
     "
 !
 
-filesWithSuffix:suffix
-    "return a collection of regular files (i.e. not subdirectories)
-     with a given suffix which are contained in the directory
-     represented by the receiver."
-
-    ^ OrderedCollection withCollectedContents:[:coll |
-        self filesWithSuffix:suffix do:[:eachFileName | coll add:eachFileName]].
-
-    "
-     '.' asFilename filesWithSuffix:'so'.
-     'packages' asFilename filesWithSuffix:'so'.
-    "
-!
-
 filesWithSuffix:suffix do:aBlock
     "evaluate aBlock for all regular files with a given suffix
      contained in the directory represented by the receiver.
@@ -4755,6 +4717,19 @@
 
 !Filename methodsFor:'queries'!
 
+directories
+    "return a collection of directories contained in the directory represented by the receiver."
+
+    ^ OrderedCollection withCollectedContents:[:coll |
+        self directoriesDo:[:eachDirectory | coll add:eachDirectory]]
+
+    "
+     '.' asFilename directories.
+    "
+
+    "Modified: / 29-05-2007 / 12:02:56 / cg"
+!
+
 exists
     "return true, if such a file exists."
 
@@ -4781,6 +4756,20 @@
     "Modified: / 3.8.1998 / 21:22:15 / cg"
 !
 
+files
+    "return a collection of regular files
+     contained in the directory represented by the receiver."
+
+    ^ OrderedCollection withCollectedContents:[:coll |
+        self filesDo:[:eachFileName | coll add:eachFileName]].
+
+    "
+     '.' asFilename files.
+    "
+
+    "Modified: / 29-05-2007 / 12:02:15 / cg"
+!
+
 filesMatching:aPattern
     "given the receiver, representing a directory;
      return a collection of files matching a pattern.
@@ -4827,14 +4816,29 @@
      The pattern may be a simple matchPattern, or a set of
      multiple patterns separated by semicolons."
 
-    self filesMatching:aPattern caseSensitive:self species isCaseSensitive do:aBlock
+    self filesMatching:aPattern caseSensitive:(self species isCaseSensitive) do:aBlock
 
     "
      '/etc' asFilename filesMatching:'a*;c*' do:[:f | Transcript showCR:f]
-    "
-
-    "Created: / 15.4.1997 / 15:40:02 / cg"
-    "Modified: / 3.8.1998 / 21:22:15 / cg"
+     '/etc' asFilename filesMatching:'a*;c*'
+    "
+
+    "Created: / 15-04-1997 / 15:40:02 / cg"
+    "Modified: / 03-08-1998 / 21:22:15 / cg"
+    "Modified (comment): / 30-09-2018 / 11:01:40 / Claus Gittinger"
+!
+
+filesMatchingGLOB
+    "Interpreting myself as a GLOB pattern,
+     Return filenames matching me"
+
+    ^ Array streamContents:[:s | self filesMatchingGLOBDo:[:each | s nextPut:each]].
+    
+    "
+     '../../*/A*' asFilename filesMatchingGLOB.
+    "
+
+    "Created: / 30-09-2018 / 10:56:42 / Claus Gittinger"
 !
 
 filesMatchingWithoutDotDirs:aPattern
@@ -4906,6 +4910,20 @@
     "Modified: / 3.8.1998 / 21:22:30 / cg"
 !
 
+filesWithSuffix:suffix
+    "return a collection of regular files (i.e. not subdirectories)
+     with a given suffix which are contained in the directory
+     represented by the receiver."
+
+    ^ OrderedCollection withCollectedContents:[:coll |
+        self filesWithSuffix:suffix do:[:eachFileName | coll add:eachFileName]].
+
+    "
+     '.' asFilename filesWithSuffix:'so'.
+     'packages' asFilename filesWithSuffix:'so'.
+    "
+!
+
 fullAlternativePathName
     "some filesystems (aka: windows) have alternative (short) filenames.
      Those systems redefine this method to return it.